From 53b81e51d5ca944f6cbafc0046c579474de7d5eb Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Tue, 16 Apr 2024 16:38:24 -0400 Subject: [PATCH 1/8] Add default HTTP route for all methods --- transcoder.go | 8 ++++++++ vanguard.go | 41 ++++++++++++--------------------------- vanguard_restxrpc_test.go | 31 +++++++++++++++++++++++++++++ vanguard_test.go | 11 ----------- 4 files changed, 51 insertions(+), 40 deletions(-) diff --git a/transcoder.go b/transcoder.go index a532383..4410b6f 100644 --- a/transcoder.go +++ b/transcoder.go @@ -216,6 +216,14 @@ func (t *Transcoder) registerMethod(handler http.Handler, methodDesc protoreflec methodConf.streamType = connect.StreamTypeUnary } + // Add the default HTTP POST route for the method. + if err := t.addRule(&annotations.HttpRule{ + Pattern: &annotations.HttpRule_Post{Post: methodPath}, + Body: "*", + }, methodConf); err != nil { + return err + } + // Add the declared HTTP rules for the method. if httpRule, ok := getHTTPRuleExtension(methodDesc); ok { if err := t.addRule(httpRule, methodConf); err != nil { return err diff --git a/vanguard.go b/vanguard.go index f9cf3f2..8da744f 100644 --- a/vanguard.go +++ b/vanguard.go @@ -71,9 +71,17 @@ const ( // The returned handler does the routing and dispatch to the RPC handlers // associated with each provided service. Routing supports more than just the // service path provided to NewService since HTTP transcoding annotations are -// used to also support REST-ful URI paths for each method. +// used to also support RESTful URI paths for each method. // -// The returned handler also acts like a middleware, transparently "upgrading" +// RESTful routing can be established either through google.api.http annotations in the +// service's schema or by configuration using [WithRules]. These annotations define mappings +// between HTTP methods and paths to RPC methods. Refer to the [annotations.HttpRule] message +// for detailed information. By default, transcoding is provided for a POST request to the +// service's fully-qualified name and method name. This is effectively the mapping of a +// request of POST /GRPC_SERVICE_FULL_NAME/METHOD_NAME. No additional mappings conflicting +// with this default mapping may be added. +// +// Additionally, the returned handler also acts as a middleware, transparently "upgrading" // the RPC handlers to support incoming request protocols they wouldn't otherwise // support. This can be used to upgrade Connect handlers to support REST requests // (based on HTTP transcoding configuration) or gRPC handlers to support Connect, @@ -81,9 +89,8 @@ const ( // translate all incoming requests to a single protocol that another backend server // supports. // -// If any options given implement ServiceOption, they are treated as default service -// options and apply to all configured services, unless overridden by a particular -// service. +// Any options implementing ServiceOption are considered default service options and are applied +// to all configured services, unless overridden by a specific service. func NewTranscoder(services []*Service, opts ...TranscoderOption) (*Transcoder, error) { for _, svc := range services { if svc.err != nil { @@ -127,7 +134,6 @@ func NewTranscoder(services []*Service, opts ...TranscoderOption) (*Transcoder, methods: map[string]*methodConfig{}, } - var restOnlyServices []protoreflect.ServiceDescriptor for _, svc := range services { resolvedOpts := defaultServiceOptions for _, opt := range svc.opts { @@ -136,33 +142,10 @@ func NewTranscoder(services []*Service, opts ...TranscoderOption) (*Transcoder, if err := transcoder.registerService(svc, resolvedOpts); err != nil { return nil, err } - if len(resolvedOpts.protocols) == 1 { - _, ok := resolvedOpts.protocols[ProtocolREST] - if ok { - restOnlyServices = append(restOnlyServices, svc.schema) - } - } } if err := transcoder.registerRules(transcoderOpts.rules); err != nil { return nil, err } - - // Finally, check that any services with only REST as target protocol - // actually have at least one method with REST mappings. - for _, svcDesc := range restOnlyServices { - methods := svcDesc.Methods() - var numSupportedMethods int - for i, length := 0, methods.Len(); i < length; i++ { - methodDesc := methods.Get(i) - if transcoder.methods[methodPath(methodDesc)].httpRule != nil { - numSupportedMethods++ - } - } - if numSupportedMethods == 0 { - return nil, fmt.Errorf("service %s only supports REST target protocol but has no methods with HTTP rules", svcDesc.FullName()) - } - } - return transcoder, nil } diff --git a/vanguard_restxrpc_test.go b/vanguard_restxrpc_test.go index 0ee6686..8d8c097 100644 --- a/vanguard_restxrpc_test.go +++ b/vanguard_restxrpc_test.go @@ -237,6 +237,37 @@ func TestMux_RESTxRPC(t *testing.T) { code: http.StatusOK, body: &testv1.Book{Name: "shelves/1/books/1"}, }, + }, { + name: "GetBook-DefaultMethod", + input: input{ + method: http.MethodPost, + path: "/vanguard.test.v1.LibraryService/GetBook", + body: &testv1.GetBookRequest{Name: "shelves/1/books/1"}, + meta: http.Header{ + "Message": []string{"hello"}, + }, + }, + stream: testStream{ + method: testv1connect.LibraryServiceGetBookProcedure, + reqHeader: http.Header{ + "Message": []string{"hello"}, + }, + rspHeader: http.Header{ + "Message": []string{"world"}, + }, + msgs: []testMsg{ + {in: &testMsgIn{ + msg: &testv1.GetBookRequest{Name: "shelves/1/books/1"}, + }}, + {out: &testMsgOut{ + msg: &testv1.Book{Name: "shelves/1/books/1"}, + }}, + }, + }, + output: output{ + code: http.StatusOK, + body: &testv1.Book{Name: "shelves/1/books/1"}, + }, }, { name: "GetBook-NotAllowed", input: input{ diff --git a/vanguard_test.go b/vanguard_test.go index bca59cf..a805f7c 100644 --- a/vanguard_test.go +++ b/vanguard_test.go @@ -124,17 +124,6 @@ func TestServiceWithSchema(t *testing.T) { _, ok := timestampType.New().Interface().(*timestamppb.Timestamp) assert.True(t, ok) }) - t.Run("fails_for_rest_only_because_no_http_rules", func(t *testing.T) { - t.Parallel() - svc := NewServiceWithSchema( - svcDesc, - http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}), - WithTargetProtocols(ProtocolREST), - ) - - _, err := NewTranscoder([]*Service{svc}) - require.ErrorContains(t, err, "service foo.bar.baz.v1.BlahService only supports REST target protocol but has no methods with HTTP rules") - }) } func TestRuleSelector(t *testing.T) { From 244db9f72f2c0f87a674d4e97868581ca67b9c10 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Tue, 16 Apr 2024 16:41:10 -0400 Subject: [PATCH 2/8] Regenerate for tests --- .../examples/pets/internal/proto/buf.lock | 4 +- internal/gen/vanguard/test/v1/content.pb.go | 223 ++++++++++++------ .../gen/vanguard/test/v1/content_grpc.pb.go | 39 +++ .../test/v1/testv1connect/content.connect.go | 31 +++ internal/proto/buf.lock | 4 +- internal/proto/vanguard/test/v1/content.proto | 10 + 6 files changed, 231 insertions(+), 80 deletions(-) diff --git a/internal/examples/pets/internal/proto/buf.lock b/internal/examples/pets/internal/proto/buf.lock index 6c4355d..1b0eba1 100644 --- a/internal/examples/pets/internal/proto/buf.lock +++ b/internal/examples/pets/internal/proto/buf.lock @@ -4,5 +4,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 28151c0d0a1641bf938a7672c500e01d - digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de + commit: 4ed3bc159a8b4ac68fe253218760d035 + digest: shake256:7149cf5e9955c692d381e557830555d4e93f205a0f1b8e2dfdae46d029369aa3fc1980e35df0d310f7cc3b622f93e19ad276769a283a967dd3065ddfd3a40e13 diff --git a/internal/gen/vanguard/test/v1/content.pb.go b/internal/gen/vanguard/test/v1/content.pb.go index 6337b96..82ffc72 100644 --- a/internal/gen/vanguard/test/v1/content.pb.go +++ b/internal/gen/vanguard/test/v1/content.pb.go @@ -239,6 +239,54 @@ func (x *DownloadResponse) GetFile() *httpbody.HttpBody { return nil } +type DeleteRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The path to the file to delete. + Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` +} + +func (x *DeleteRequest) Reset() { + *x = DeleteRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_vanguard_test_v1_content_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequest) ProtoMessage() {} + +func (x *DeleteRequest) ProtoReflect() protoreflect.Message { + mi := &file_vanguard_test_v1_content_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRequest.ProtoReflect.Descriptor instead. +func (*DeleteRequest) Descriptor() ([]byte, []int) { + return file_vanguard_test_v1_content_proto_rawDescGZIP(), []int{4} +} + +func (x *DeleteRequest) GetFilename() string { + if x != nil { + return x.Filename + } + return "" +} + type SubscribeRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -250,7 +298,7 @@ type SubscribeRequest struct { func (x *SubscribeRequest) Reset() { *x = SubscribeRequest{} if protoimpl.UnsafeEnabled { - mi := &file_vanguard_test_v1_content_proto_msgTypes[4] + mi := &file_vanguard_test_v1_content_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -263,7 +311,7 @@ func (x *SubscribeRequest) String() string { func (*SubscribeRequest) ProtoMessage() {} func (x *SubscribeRequest) ProtoReflect() protoreflect.Message { - mi := &file_vanguard_test_v1_content_proto_msgTypes[4] + mi := &file_vanguard_test_v1_content_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -276,7 +324,7 @@ func (x *SubscribeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead. func (*SubscribeRequest) Descriptor() ([]byte, []int) { - return file_vanguard_test_v1_content_proto_rawDescGZIP(), []int{4} + return file_vanguard_test_v1_content_proto_rawDescGZIP(), []int{5} } func (x *SubscribeRequest) GetFilenamePatterns() []string { @@ -299,7 +347,7 @@ type SubscribeResponse struct { func (x *SubscribeResponse) Reset() { *x = SubscribeResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vanguard_test_v1_content_proto_msgTypes[5] + mi := &file_vanguard_test_v1_content_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -312,7 +360,7 @@ func (x *SubscribeResponse) String() string { func (*SubscribeResponse) ProtoMessage() {} func (x *SubscribeResponse) ProtoReflect() protoreflect.Message { - mi := &file_vanguard_test_v1_content_proto_msgTypes[5] + mi := &file_vanguard_test_v1_content_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -325,7 +373,7 @@ func (x *SubscribeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeResponse.ProtoReflect.Descriptor instead. func (*SubscribeResponse) Descriptor() ([]byte, []int) { - return file_vanguard_test_v1_content_proto_rawDescGZIP(), []int{5} + return file_vanguard_test_v1_content_proto_rawDescGZIP(), []int{6} } func (x *SubscribeResponse) GetFilenameChanged() string { @@ -377,59 +425,67 @@ var file_vanguard_test_v1_content_proto_rawDesc = []byte{ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x66, 0x69, 0x6c, - 0x65, 0x22, 0x3f, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, - 0x65, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x10, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, - 0x6e, 0x73, 0x22, 0x95, 0x01, 0x0a, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x69, 0x6c, 0x65, - 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0f, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x43, 0x68, 0x61, 0x6e, - 0x67, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x32, 0xa3, 0x03, 0x0a, 0x0e, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, - 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1e, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, - 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x22, 0x12, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x0c, 0x12, 0x0a, 0x2f, 0x7b, 0x70, 0x61, 0x67, 0x65, 0x3d, 0x2a, 0x2a, 0x7d, - 0x12, 0x68, 0x0a, 0x06, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1f, 0x2e, 0x76, 0x61, 0x6e, - 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, - 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x3a, 0x04, 0x66, 0x69, 0x6c, - 0x65, 0x22, 0x15, 0x2f, 0x7b, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x2a, 0x2a, - 0x7d, 0x3a, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x28, 0x01, 0x12, 0x7a, 0x0a, 0x08, 0x44, 0x6f, - 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x21, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, + 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3f, + 0x0a, 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x66, + 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x73, 0x22, + 0x95, 0x01, 0x0a, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, + 0x65, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0f, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, + 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x32, 0xe8, 0x03, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x05, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x12, 0x1e, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x48, 0x74, 0x74, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x0c, 0x12, 0x0a, 0x2f, 0x7b, 0x70, 0x61, 0x67, 0x65, 0x3d, 0x2a, 0x2a, 0x7d, 0x12, 0x68, 0x0a, + 0x06, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1f, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, + 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x3a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x15, + 0x2f, 0x7b, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x2a, 0x2a, 0x7d, 0x3a, 0x75, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x28, 0x01, 0x12, 0x7a, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, + 0x6f, 0x61, 0x64, 0x12, 0x21, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, - 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x76, 0x61, 0x6e, 0x67, - 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, - 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x62, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x17, 0x2f, 0x7b, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x2a, 0x2a, 0x7d, 0x3a, 0x64, 0x6f, 0x77, 0x6e, - 0x6c, 0x6f, 0x61, 0x64, 0x30, 0x01, 0x12, 0x58, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x62, 0x65, 0x12, 0x22, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, - 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, - 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, - 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, - 0x42, 0xc4, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, - 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, - 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, - 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, - 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x76, 0x31, - 0x3b, 0x74, 0x65, 0x73, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x56, 0x54, 0x58, 0xaa, 0x02, 0x10, - 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x2e, 0x56, 0x31, - 0xca, 0x02, 0x10, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x5c, 0x54, 0x65, 0x73, 0x74, - 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x5c, 0x54, - 0x65, 0x73, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x12, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x3a, 0x3a, 0x54, - 0x65, 0x73, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x1f, 0x62, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x17, 0x2f, 0x7b, 0x66, 0x69, 0x6c, 0x65, + 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x2a, 0x2a, 0x7d, 0x3a, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x30, 0x01, 0x12, 0x58, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, + 0x12, 0x22, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x43, 0x0a, + 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1f, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, + 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x22, 0x00, 0x42, 0xc4, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, + 0x61, 0x72, 0x64, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x61, 0x6e, 0x67, + 0x75, 0x61, 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, + 0x6e, 0x2f, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, + 0x76, 0x31, 0x3b, 0x74, 0x65, 0x73, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x56, 0x54, 0x58, 0xaa, + 0x02, 0x10, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x2e, + 0x56, 0x31, 0xca, 0x02, 0x10, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x5c, 0x54, 0x65, + 0x73, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, + 0x5c, 0x54, 0x65, 0x73, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x3a, + 0x3a, 0x54, 0x65, 0x73, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -444,32 +500,35 @@ func file_vanguard_test_v1_content_proto_rawDescGZIP() []byte { return file_vanguard_test_v1_content_proto_rawDescData } -var file_vanguard_test_v1_content_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_vanguard_test_v1_content_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_vanguard_test_v1_content_proto_goTypes = []interface{}{ (*IndexRequest)(nil), // 0: vanguard.test.v1.IndexRequest (*UploadRequest)(nil), // 1: vanguard.test.v1.UploadRequest (*DownloadRequest)(nil), // 2: vanguard.test.v1.DownloadRequest (*DownloadResponse)(nil), // 3: vanguard.test.v1.DownloadResponse - (*SubscribeRequest)(nil), // 4: vanguard.test.v1.SubscribeRequest - (*SubscribeResponse)(nil), // 5: vanguard.test.v1.SubscribeResponse - (*httpbody.HttpBody)(nil), // 6: google.api.HttpBody - (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp - (*emptypb.Empty)(nil), // 8: google.protobuf.Empty + (*DeleteRequest)(nil), // 4: vanguard.test.v1.DeleteRequest + (*SubscribeRequest)(nil), // 5: vanguard.test.v1.SubscribeRequest + (*SubscribeResponse)(nil), // 6: vanguard.test.v1.SubscribeResponse + (*httpbody.HttpBody)(nil), // 7: google.api.HttpBody + (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp + (*emptypb.Empty)(nil), // 9: google.protobuf.Empty } var file_vanguard_test_v1_content_proto_depIdxs = []int32{ - 6, // 0: vanguard.test.v1.UploadRequest.file:type_name -> google.api.HttpBody - 6, // 1: vanguard.test.v1.DownloadResponse.file:type_name -> google.api.HttpBody - 7, // 2: vanguard.test.v1.SubscribeResponse.update_time:type_name -> google.protobuf.Timestamp + 7, // 0: vanguard.test.v1.UploadRequest.file:type_name -> google.api.HttpBody + 7, // 1: vanguard.test.v1.DownloadResponse.file:type_name -> google.api.HttpBody + 8, // 2: vanguard.test.v1.SubscribeResponse.update_time:type_name -> google.protobuf.Timestamp 0, // 3: vanguard.test.v1.ContentService.Index:input_type -> vanguard.test.v1.IndexRequest 1, // 4: vanguard.test.v1.ContentService.Upload:input_type -> vanguard.test.v1.UploadRequest 2, // 5: vanguard.test.v1.ContentService.Download:input_type -> vanguard.test.v1.DownloadRequest - 4, // 6: vanguard.test.v1.ContentService.Subscribe:input_type -> vanguard.test.v1.SubscribeRequest - 6, // 7: vanguard.test.v1.ContentService.Index:output_type -> google.api.HttpBody - 8, // 8: vanguard.test.v1.ContentService.Upload:output_type -> google.protobuf.Empty - 3, // 9: vanguard.test.v1.ContentService.Download:output_type -> vanguard.test.v1.DownloadResponse - 5, // 10: vanguard.test.v1.ContentService.Subscribe:output_type -> vanguard.test.v1.SubscribeResponse - 7, // [7:11] is the sub-list for method output_type - 3, // [3:7] is the sub-list for method input_type + 5, // 6: vanguard.test.v1.ContentService.Subscribe:input_type -> vanguard.test.v1.SubscribeRequest + 4, // 7: vanguard.test.v1.ContentService.Delete:input_type -> vanguard.test.v1.DeleteRequest + 7, // 8: vanguard.test.v1.ContentService.Index:output_type -> google.api.HttpBody + 9, // 9: vanguard.test.v1.ContentService.Upload:output_type -> google.protobuf.Empty + 3, // 10: vanguard.test.v1.ContentService.Download:output_type -> vanguard.test.v1.DownloadResponse + 6, // 11: vanguard.test.v1.ContentService.Subscribe:output_type -> vanguard.test.v1.SubscribeResponse + 9, // 12: vanguard.test.v1.ContentService.Delete:output_type -> google.protobuf.Empty + 8, // [8:13] is the sub-list for method output_type + 3, // [3:8] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -530,7 +589,7 @@ func file_vanguard_test_v1_content_proto_init() { } } file_vanguard_test_v1_content_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SubscribeRequest); i { + switch v := v.(*DeleteRequest); i { case 0: return &v.state case 1: @@ -542,6 +601,18 @@ func file_vanguard_test_v1_content_proto_init() { } } file_vanguard_test_v1_content_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SubscribeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_vanguard_test_v1_content_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SubscribeResponse); i { case 0: return &v.state @@ -560,7 +631,7 @@ func file_vanguard_test_v1_content_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vanguard_test_v1_content_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/gen/vanguard/test/v1/content_grpc.pb.go b/internal/gen/vanguard/test/v1/content_grpc.pb.go index 46351ee..7d00958 100644 --- a/internal/gen/vanguard/test/v1/content_grpc.pb.go +++ b/internal/gen/vanguard/test/v1/content_grpc.pb.go @@ -39,6 +39,7 @@ const ( ContentService_Upload_FullMethodName = "/vanguard.test.v1.ContentService/Upload" ContentService_Download_FullMethodName = "/vanguard.test.v1.ContentService/Download" ContentService_Subscribe_FullMethodName = "/vanguard.test.v1.ContentService/Subscribe" + ContentService_Delete_FullMethodName = "/vanguard.test.v1.ContentService/Delete" ) // ContentServiceClient is the client API for ContentService service. @@ -53,6 +54,8 @@ type ContentServiceClient interface { Download(ctx context.Context, in *DownloadRequest, opts ...grpc.CallOption) (ContentService_DownloadClient, error) // Subscribe to updates for changes to content. Subscribe(ctx context.Context, opts ...grpc.CallOption) (ContentService_SubscribeClient, error) + // Delete a file at the given path. + Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type contentServiceClient struct { @@ -169,6 +172,15 @@ func (x *contentServiceSubscribeClient) Recv() (*SubscribeResponse, error) { return m, nil } +func (c *contentServiceClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, ContentService_Delete_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ContentServiceServer is the server API for ContentService service. // All implementations must embed UnimplementedContentServiceServer // for forward compatibility @@ -181,6 +193,8 @@ type ContentServiceServer interface { Download(*DownloadRequest, ContentService_DownloadServer) error // Subscribe to updates for changes to content. Subscribe(ContentService_SubscribeServer) error + // Delete a file at the given path. + Delete(context.Context, *DeleteRequest) (*emptypb.Empty, error) mustEmbedUnimplementedContentServiceServer() } @@ -200,6 +214,9 @@ func (UnimplementedContentServiceServer) Download(*DownloadRequest, ContentServi func (UnimplementedContentServiceServer) Subscribe(ContentService_SubscribeServer) error { return status.Errorf(codes.Unimplemented, "method Subscribe not implemented") } +func (UnimplementedContentServiceServer) Delete(context.Context, *DeleteRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} func (UnimplementedContentServiceServer) mustEmbedUnimplementedContentServiceServer() {} // UnsafeContentServiceServer may be embedded to opt out of forward compatibility for this service. @@ -304,6 +321,24 @@ func (x *contentServiceSubscribeServer) Recv() (*SubscribeRequest, error) { return m, nil } +func _ContentService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentServiceServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ContentService_Delete_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentServiceServer).Delete(ctx, req.(*DeleteRequest)) + } + return interceptor(ctx, in, info, handler) +} + // ContentService_ServiceDesc is the grpc.ServiceDesc for ContentService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -315,6 +350,10 @@ var ContentService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Index", Handler: _ContentService_Index_Handler, }, + { + MethodName: "Delete", + Handler: _ContentService_Delete_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/internal/gen/vanguard/test/v1/testv1connect/content.connect.go b/internal/gen/vanguard/test/v1/testv1connect/content.connect.go index 63b0cf0..7a3d48d 100644 --- a/internal/gen/vanguard/test/v1/testv1connect/content.connect.go +++ b/internal/gen/vanguard/test/v1/testv1connect/content.connect.go @@ -58,6 +58,8 @@ const ( // ContentServiceSubscribeProcedure is the fully-qualified name of the ContentService's Subscribe // RPC. ContentServiceSubscribeProcedure = "/vanguard.test.v1.ContentService/Subscribe" + // ContentServiceDeleteProcedure is the fully-qualified name of the ContentService's Delete RPC. + ContentServiceDeleteProcedure = "/vanguard.test.v1.ContentService/Delete" ) // These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. @@ -67,6 +69,7 @@ var ( contentServiceUploadMethodDescriptor = contentServiceServiceDescriptor.Methods().ByName("Upload") contentServiceDownloadMethodDescriptor = contentServiceServiceDescriptor.Methods().ByName("Download") contentServiceSubscribeMethodDescriptor = contentServiceServiceDescriptor.Methods().ByName("Subscribe") + contentServiceDeleteMethodDescriptor = contentServiceServiceDescriptor.Methods().ByName("Delete") ) // ContentServiceClient is a client for the vanguard.test.v1.ContentService service. @@ -79,6 +82,8 @@ type ContentServiceClient interface { Download(context.Context, *connect.Request[v1.DownloadRequest]) (*connect.ServerStreamForClient[v1.DownloadResponse], error) // Subscribe to updates for changes to content. Subscribe(context.Context) *connect.BidiStreamForClient[v1.SubscribeRequest, v1.SubscribeResponse] + // Delete a file at the given path. + Delete(context.Context, *connect.Request[v1.DeleteRequest]) (*connect.Response[emptypb.Empty], error) } // NewContentServiceClient constructs a client for the vanguard.test.v1.ContentService service. By @@ -115,6 +120,12 @@ func NewContentServiceClient(httpClient connect.HTTPClient, baseURL string, opts connect.WithSchema(contentServiceSubscribeMethodDescriptor), connect.WithClientOptions(opts...), ), + delete: connect.NewClient[v1.DeleteRequest, emptypb.Empty]( + httpClient, + baseURL+ContentServiceDeleteProcedure, + connect.WithSchema(contentServiceDeleteMethodDescriptor), + connect.WithClientOptions(opts...), + ), } } @@ -124,6 +135,7 @@ type contentServiceClient struct { upload *connect.Client[v1.UploadRequest, emptypb.Empty] download *connect.Client[v1.DownloadRequest, v1.DownloadResponse] subscribe *connect.Client[v1.SubscribeRequest, v1.SubscribeResponse] + delete *connect.Client[v1.DeleteRequest, emptypb.Empty] } // Index calls vanguard.test.v1.ContentService.Index. @@ -146,6 +158,11 @@ func (c *contentServiceClient) Subscribe(ctx context.Context) *connect.BidiStrea return c.subscribe.CallBidiStream(ctx) } +// Delete calls vanguard.test.v1.ContentService.Delete. +func (c *contentServiceClient) Delete(ctx context.Context, req *connect.Request[v1.DeleteRequest]) (*connect.Response[emptypb.Empty], error) { + return c.delete.CallUnary(ctx, req) +} + // ContentServiceHandler is an implementation of the vanguard.test.v1.ContentService service. type ContentServiceHandler interface { // Index returns a html index page at the given path. @@ -156,6 +173,8 @@ type ContentServiceHandler interface { Download(context.Context, *connect.Request[v1.DownloadRequest], *connect.ServerStream[v1.DownloadResponse]) error // Subscribe to updates for changes to content. Subscribe(context.Context, *connect.BidiStream[v1.SubscribeRequest, v1.SubscribeResponse]) error + // Delete a file at the given path. + Delete(context.Context, *connect.Request[v1.DeleteRequest]) (*connect.Response[emptypb.Empty], error) } // NewContentServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -188,6 +207,12 @@ func NewContentServiceHandler(svc ContentServiceHandler, opts ...connect.Handler connect.WithSchema(contentServiceSubscribeMethodDescriptor), connect.WithHandlerOptions(opts...), ) + contentServiceDeleteHandler := connect.NewUnaryHandler( + ContentServiceDeleteProcedure, + svc.Delete, + connect.WithSchema(contentServiceDeleteMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) return "/vanguard.test.v1.ContentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case ContentServiceIndexProcedure: @@ -198,6 +223,8 @@ func NewContentServiceHandler(svc ContentServiceHandler, opts ...connect.Handler contentServiceDownloadHandler.ServeHTTP(w, r) case ContentServiceSubscribeProcedure: contentServiceSubscribeHandler.ServeHTTP(w, r) + case ContentServiceDeleteProcedure: + contentServiceDeleteHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } @@ -222,3 +249,7 @@ func (UnimplementedContentServiceHandler) Download(context.Context, *connect.Req func (UnimplementedContentServiceHandler) Subscribe(context.Context, *connect.BidiStream[v1.SubscribeRequest, v1.SubscribeResponse]) error { return connect.NewError(connect.CodeUnimplemented, errors.New("vanguard.test.v1.ContentService.Subscribe is not implemented")) } + +func (UnimplementedContentServiceHandler) Delete(context.Context, *connect.Request[v1.DeleteRequest]) (*connect.Response[emptypb.Empty], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("vanguard.test.v1.ContentService.Delete is not implemented")) +} diff --git a/internal/proto/buf.lock b/internal/proto/buf.lock index 3435191..1b0eba1 100644 --- a/internal/proto/buf.lock +++ b/internal/proto/buf.lock @@ -4,5 +4,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 711e289f6a384c4caeebaff7c6931ade - digest: shake256:e08fb55dad7469f69df00304eed31427d2d1576e9aab31e6bf86642688e04caaf0372f15fe6974cf79432779a635b3ea401ca69c943976dc42749524e4c25d94 + commit: 4ed3bc159a8b4ac68fe253218760d035 + digest: shake256:7149cf5e9955c692d381e557830555d4e93f205a0f1b8e2dfdae46d029369aa3fc1980e35df0d310f7cc3b622f93e19ad276769a283a967dd3065ddfd3a40e13 diff --git a/internal/proto/vanguard/test/v1/content.proto b/internal/proto/vanguard/test/v1/content.proto index 5fef8fd..5c36dd7 100644 --- a/internal/proto/vanguard/test/v1/content.proto +++ b/internal/proto/vanguard/test/v1/content.proto @@ -42,6 +42,11 @@ service ContentService { } // Subscribe to updates for changes to content. rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeResponse); + // Delete a file at the given path. + rpc Delete(DeleteRequest) returns (google.protobuf.Empty) { + // This method does not have an HTTP mapping, but is still callable via its + // default POST HTTP mapping. + } } message IndexRequest { @@ -66,6 +71,11 @@ message DownloadResponse { google.api.HttpBody file = 1; } +message DeleteRequest { + // The path to the file to delete. + string filename = 1; +} + message SubscribeRequest { repeated string filename_patterns = 1; } From 6cb215f5199d837de5e6e986456b6da75dc74651 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Tue, 16 Apr 2024 16:50:41 -0400 Subject: [PATCH 3/8] Add test for default route --- vanguard_rpcxrest_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vanguard_rpcxrest_test.go b/vanguard_rpcxrest_test.go index fd44740..2ac321d 100644 --- a/vanguard_rpcxrest_test.go +++ b/vanguard_rpcxrest_test.go @@ -417,6 +417,28 @@ func TestMux_RPCxREST(t *testing.T) { }, }}, }, + }, { + name: "Delete", + input: func(clients testClients, hdr http.Header) (http.Header, []proto.Message, http.Header, error) { + msgs := []proto.Message{ + &testv1.DeleteRequest{Filename: "message.txt"}, + } + return outputFromUnary(ctx, clients.contentClient.Delete, hdr, msgs) + }, + stream: testStream{ + method: "/vanguard.test.v1.ContentService/Delete", + msgs: []testMsg{ + {in: &testMsgIn{ + msg: &testv1.DeleteRequest{Filename: "message.txt"}, + }}, + {out: &testMsgOut{ + msg: &emptypb.Empty{}, + }}, + }, + }, + output: output{ + messages: []proto.Message{&emptypb.Empty{}}, + }, }} for _, opts := range testOpts { From 71205ee84f12ea0dae3097428db6b62e9523492d Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Wed, 17 Apr 2024 18:18:56 -0400 Subject: [PATCH 4/8] Create implicit overwritable default route target --- router.go | 65 +++++++++++++++++++++++++++++++++++++++----------- router_test.go | 4 ++-- transcoder.go | 41 ++++++++++++++++++------------- vanguard.go | 12 +++++++++- 4 files changed, 88 insertions(+), 34 deletions(-) diff --git a/router.go b/router.go index e86c015..41c9edc 100644 --- a/router.go +++ b/router.go @@ -72,7 +72,18 @@ func (t *routeTrie) addRoute(config *methodConfig, rule *annotations.HttpRule) ( if err != nil { return nil, err } - if err := t.insert(method, target, segments); err != nil { + if err := t.insert(target); err != nil { + return nil, err + } + return target, nil +} + +// addDefaultRoute adds a default target to the router for the given method. +// This may be overridden by a explicit rule. The default route is of the form +// POST /service/method. +func (t *routeTrie) addDefaultRoute(config *methodConfig) (*routeTarget, error) { + target := makeDefaultTarget(config) + if err := t.insert(target); err != nil { return nil, err } return target, nil @@ -103,17 +114,15 @@ func (t *routeTrie) insertVerb(verb string) routeMethods { // insert the target into the trie using the given method and segment path. // The path is followed until the final segment is reached. -func (t *routeTrie) insert(method string, target *routeTarget, segments pathSegments) error { +func (t *routeTrie) insert(target *routeTarget) error { cursor := t - for _, segment := range segments.path { + for _, segment := range target.path { cursor = cursor.insertChild(segment) } - if existing := cursor.verbs[segments.verb][method]; existing != nil { - return alreadyExistsError{ - existing: existing, pathPattern: segments.String(), method: method, - } + if existing := cursor.verbs[target.verb][target.method]; existing != nil && !existing.isImplicit { + return alreadyExistsError{target: target, existing: existing} } - cursor.insertVerb(segments.verb)[method] = target + cursor.insertVerb(target.verb)[target.method] = target return nil } @@ -124,9 +133,8 @@ func (t *routeTrie) match(uriPath, httpMethod string) (*routeTarget, []routeTarg // Must start with "/" or if it ends with ":" it won't match return nil, nil, nil } - uriPath = uriPath[1:] // skip the leading slash - path := strings.Split(uriPath, "/") + path := strings.Split(uriPath[1:], "/") // skip the leading slash var verb string if len(path) > 0 { lastElement := path[len(path)-1] @@ -208,6 +216,14 @@ type routeTarget struct { responseBodyFieldPath string responseBodyFields []protoreflect.FieldDescriptor vars []routeTargetVar + + // isImplicit is true if the target was created implicitly, such as for a + // default method. This is used to prevent overwriting an explicit target. + isImplicit bool +} + +func (t *routeTarget) String() string { + return t.method + " " + pathSegments{path: t.path, verb: t.verb}.String() } func makeTarget( @@ -266,6 +282,25 @@ func makeTarget( }, nil } +// makeDefaultTarget of the form POST /service/method. +func makeDefaultTarget( + config *methodConfig, +) *routeTarget { + return &routeTarget{ + config: config, + method: http.MethodPost, + path: []string{ + string(config.descriptor.Parent().FullName()), + string(config.descriptor.Name()), + }, + requestBodyFieldPath: "*", + requestBodyFields: []protoreflect.FieldDescriptor{}, + responseBodyFieldPath: "*", + responseBodyFields: []protoreflect.FieldDescriptor{}, + isImplicit: true, + } +} + type routeTargetVar struct { pathVariable @@ -359,7 +394,7 @@ func resolvePathToDescriptors(msg protoreflect.MessageDescriptor, path string) ( msg = field.Message() if msg == nil { return nil, fmt.Errorf("in field path %q: field %q of type %s should be a message but is instead %s", - path, part, msg.FullName(), field.Kind()) + path, part, protoreflect.MessageKind, field.Kind()) } fields = msg.Fields() } @@ -380,10 +415,12 @@ func resolveFieldDescriptorsToPath(fields []protoreflect.FieldDescriptor) string } type alreadyExistsError struct { - existing *routeTarget - pathPattern, method string + target, existing *routeTarget } func (a alreadyExistsError) Error() string { - return fmt.Sprintf("target for %s, method %s already exists: %s", a.pathPattern, a.method, a.existing.config.descriptor.FullName()) + return fmt.Sprintf( + "target for %s already exists: %s", + a.target.String(), a.existing.config.descriptor.FullName(), + ) } diff --git a/router_test.go b/router_test.go index 904eb2e..a5bfea4 100644 --- a/router_test.go +++ b/router_test.go @@ -234,9 +234,9 @@ func initTrie(tb testing.TB) *routeTrie { name: fmt.Sprintf("%s %s", method, route), }, } - target, err := makeTarget(config, "POST", "*", "*", segments, variables) + target, err := makeTarget(config, method, "*", "*", segments, variables) require.NoError(tb, err) - err = trie.insert(method, target, segments) + err = trie.insert(target) require.NoError(tb, err) } } diff --git a/transcoder.go b/transcoder.go index 4410b6f..51685cb 100644 --- a/transcoder.go +++ b/transcoder.go @@ -163,10 +163,12 @@ func (t *Transcoder) registerRules(rules []*annotations.HttpRule) error { } for methodConf, rules := range methodRules { for _, rule := range rules { - if err := t.addRule(rule, methodConf); err != nil { + targets, err := t.addRule(rule, methodConf) + if err != nil { // TODO: use the multi-error type errors.Join() return err } + methodConf.restTargets = append(methodConf.restTargets, targets...) } } return nil @@ -216,38 +218,43 @@ func (t *Transcoder) registerMethod(handler http.Handler, methodDesc protoreflec methodConf.streamType = connect.StreamTypeUnary } - // Add the default HTTP POST route for the method. - if err := t.addRule(&annotations.HttpRule{ - Pattern: &annotations.HttpRule_Post{Post: methodPath}, - Body: "*", - }, methodConf); err != nil { - return err + // Add the implicit HTTP POST route for the method. + defaultTarget, err := t.restRoutes.addDefaultRoute(methodConf) + if err != nil { + return fmt.Errorf("failed to add default REST route for method %s: %w", methodPath, err) } - // Add the declared HTTP rules for the method. + methodConf.restDefaultTarget = defaultTarget + // Add the explict declared HTTP rules for the method. if httpRule, ok := getHTTPRuleExtension(methodDesc); ok { - if err := t.addRule(httpRule, methodConf); err != nil { + targets, err := t.addRule(httpRule, methodConf) + if err != nil { return err } + methodConf.restTargets = targets } return nil } -func (t *Transcoder) addRule(httpRule *annotations.HttpRule, methodConf *methodConfig) error { +// addRule adds an HTTP rule to the transcoder, creating a route for each binding. +func (t *Transcoder) addRule(httpRule *annotations.HttpRule, methodConf *methodConfig) ([]*routeTarget, error) { + var targets []*routeTarget methodPath := methodConf.methodPath firstTarget, err := t.restRoutes.addRoute(methodConf, httpRule) if err != nil { - return fmt.Errorf("failed to add REST route for method %s: %w", methodPath, err) + return nil, fmt.Errorf("failed to add REST route for method %s: %w", methodPath, err) } - methodConf.httpRule = firstTarget + targets = append(targets, firstTarget) for i, rule := range httpRule.GetAdditionalBindings() { if len(rule.GetAdditionalBindings()) > 0 { - return fmt.Errorf("nested additional bindings are not supported (method %s)", methodPath) + return nil, fmt.Errorf("nested additional bindings are not supported (method %s)", methodPath) } - if _, err := t.restRoutes.addRoute(methodConf, rule); err != nil { - return fmt.Errorf("failed to add REST route (add'l binding #%d) for method %s: %w", i+1, methodPath, err) + addTarget, err := t.restRoutes.addRoute(methodConf, rule) + if err != nil { + return nil, fmt.Errorf("failed to add REST route (add'l binding #%d) for method %s: %w", i+1, methodPath, err) } + targets = append(targets, addTarget) } - return nil + return targets, nil } func (t *Transcoder) newOperation(writer http.ResponseWriter, request *http.Request) *operation { @@ -640,7 +647,7 @@ func (o *operation) resolveMethod(transcoder *Transcoder) error { if methodConf == nil { return errNotFound } - o.restTarget = methodConf.httpRule + o.restTarget = methodConf.getRestTarget() if o.request.Method != http.MethodPost { mayAllowGet, ok := o.client.protocol.(clientProtocolAllowsGet) allowsGet := ok && mayAllowGet.allowsGetRequests(methodConf) diff --git a/vanguard.go b/vanguard.go index 8da744f..9a13616 100644 --- a/vanguard.go +++ b/vanguard.go @@ -412,7 +412,17 @@ type methodConfig struct { methodPath string streamType connect.StreamType handler http.Handler - httpRule *routeTarget // First HTTP rule, if any. + restTargets []*routeTarget + restDefaultTarget *routeTarget +} + +// getRestTarget returns the explicit HTTP target for the method, or the default +// HTTP target if none is specified. +func (m *methodConfig) getRestTarget() *routeTarget { + if len(m.restTargets) > 0 { + return m.restTargets[0] // The first rule is preferred. + } + return m.restDefaultTarget } func descKind(desc protoreflect.Descriptor) string { From 6ca7a807a58b47832f03df91c4a6357687b33af7 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Wed, 17 Apr 2024 18:20:51 -0400 Subject: [PATCH 5/8] Fix lint --- transcoder.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transcoder.go b/transcoder.go index 51685cb..6ff5800 100644 --- a/transcoder.go +++ b/transcoder.go @@ -224,7 +224,7 @@ func (t *Transcoder) registerMethod(handler http.Handler, methodDesc protoreflec return fmt.Errorf("failed to add default REST route for method %s: %w", methodPath, err) } methodConf.restDefaultTarget = defaultTarget - // Add the explict declared HTTP rules for the method. + // Add the explicit declared HTTP rules for the method. if httpRule, ok := getHTTPRuleExtension(methodDesc); ok { targets, err := t.addRule(httpRule, methodConf) if err != nil { @@ -237,7 +237,7 @@ func (t *Transcoder) registerMethod(handler http.Handler, methodDesc protoreflec // addRule adds an HTTP rule to the transcoder, creating a route for each binding. func (t *Transcoder) addRule(httpRule *annotations.HttpRule, methodConf *methodConfig) ([]*routeTarget, error) { - var targets []*routeTarget + targets := make([]*routeTarget, 0, 1+len(httpRule.GetAdditionalBindings())) methodPath := methodConf.methodPath firstTarget, err := t.restRoutes.addRoute(methodConf, httpRule) if err != nil { From d8738f31435b25e4071a38607f46109e32ef7be1 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Wed, 17 Apr 2024 18:22:38 -0400 Subject: [PATCH 6/8] Change wording to allow overriding --- router.go | 2 +- vanguard.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/router.go b/router.go index 41c9edc..96ea6b2 100644 --- a/router.go +++ b/router.go @@ -79,7 +79,7 @@ func (t *routeTrie) addRoute(config *methodConfig, rule *annotations.HttpRule) ( } // addDefaultRoute adds a default target to the router for the given method. -// This may be overridden by a explicit rule. The default route is of the form +// This may be overridden by an explicit rule. The default route is of the form // POST /service/method. func (t *routeTrie) addDefaultRoute(config *methodConfig) (*routeTarget, error) { target := makeDefaultTarget(config) diff --git a/vanguard.go b/vanguard.go index 9a13616..f5e5a69 100644 --- a/vanguard.go +++ b/vanguard.go @@ -78,8 +78,8 @@ const ( // between HTTP methods and paths to RPC methods. Refer to the [annotations.HttpRule] message // for detailed information. By default, transcoding is provided for a POST request to the // service's fully-qualified name and method name. This is effectively the mapping of a -// request of POST /GRPC_SERVICE_FULL_NAME/METHOD_NAME. No additional mappings conflicting -// with this default mapping may be added. +// request of POST /GRPC_SERVICE_FULL_NAME/METHOD_NAME. Additional mappings may override +// the default mapping if required. // // Additionally, the returned handler also acts as a middleware, transparently "upgrading" // the RPC handlers to support incoming request protocols they wouldn't otherwise From 8fd333578e2adc659215843e64da6cc215753cef Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Thu, 18 Apr 2024 00:06:20 -0400 Subject: [PATCH 7/8] Generate test for stream types --- .../gen/io/swagger/petstore/v2/pets.pb.go | 1079 +++++++++++++++++ .../io/swagger/petstore/v2/pets_grpc.pb.go | 396 ++++++ .../v2/petstorev2connect/pets.connect.go | 352 ++++++ .../gen/vanguard/test/v1/restricted.pb.go | 121 ++ .../vanguard/test/v1/restricted_grpc.pb.go | 297 +++++ .../v1/testv1connect/restricted.connect.go | 194 +++ .../proto/vanguard/test/v1/restricted.proto | 45 + 7 files changed, 2484 insertions(+) create mode 100644 internal/gen/io/swagger/petstore/v2/pets.pb.go create mode 100644 internal/gen/io/swagger/petstore/v2/pets_grpc.pb.go create mode 100644 internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go create mode 100644 internal/gen/vanguard/test/v1/restricted.pb.go create mode 100644 internal/gen/vanguard/test/v1/restricted_grpc.pb.go create mode 100644 internal/gen/vanguard/test/v1/testv1connect/restricted.connect.go create mode 100644 internal/proto/vanguard/test/v1/restricted.proto diff --git a/internal/gen/io/swagger/petstore/v2/pets.pb.go b/internal/gen/io/swagger/petstore/v2/pets.pb.go new file mode 100644 index 0000000..fa02d6c --- /dev/null +++ b/internal/gen/io/swagger/petstore/v2/pets.pb.go @@ -0,0 +1,1079 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc (unknown) +// source: io/swagger/petstore/v2/pets.proto + +// The service defined herein comes from v2 of the Petstore service, which +// is used as an example for Swagger/OpenAPI. The Swagger spec can be found +// here: https://petstore.swagger.io/v2/swagger.json +// A human-friendly HTML view of this API is also available at +// https://petstore.swagger.io. +// +// This file defines only the "pet" service. The spec for this site also +// includes "store" and "user" services which are not supported via these +// RPC definitions. + +package petstorev2 + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Status int32 + +const ( + Status_unknown Status = 0 + Status_available Status = 1 + Status_pending Status = 2 + Status_sold Status = 3 +) + +// Enum value maps for Status. +var ( + Status_name = map[int32]string{ + 0: "unknown", + 1: "available", + 2: "pending", + 3: "sold", + } + Status_value = map[string]int32{ + "unknown": 0, + "available": 1, + "pending": 2, + "sold": 3, + } +) + +func (x Status) Enum() *Status { + p := new(Status) + *p = x + return p +} + +func (x Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Status) Descriptor() protoreflect.EnumDescriptor { + return file_io_swagger_petstore_v2_pets_proto_enumTypes[0].Descriptor() +} + +func (Status) Type() protoreflect.EnumType { + return &file_io_swagger_petstore_v2_pets_proto_enumTypes[0] +} + +func (x Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Status.Descriptor instead. +func (Status) EnumDescriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{0} +} + +type Category struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Category) Reset() { + *x = Category{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Category) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Category) ProtoMessage() {} + +func (x *Category) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Category.ProtoReflect.Descriptor instead. +func (*Category) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{0} +} + +func (x *Category) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Category) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type Tag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Tag) Reset() { + *x = Tag{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Tag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tag) ProtoMessage() {} + +func (x *Tag) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tag.ProtoReflect.Descriptor instead. +func (*Tag) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{1} +} + +func (x *Tag) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Tag) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type PetID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PetId int64 `protobuf:"varint,1,opt,name=pet_id,json=petId,proto3" json:"pet_id,omitempty"` +} + +func (x *PetID) Reset() { + *x = PetID{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PetID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PetID) ProtoMessage() {} + +func (x *PetID) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PetID.ProtoReflect.Descriptor instead. +func (*PetID) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{2} +} + +func (x *PetID) GetPetId() int64 { + if x != nil { + return x.PetId + } + return 0 +} + +type Pet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Category *Category `protobuf:"bytes,2,opt,name=category,proto3" json:"category,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + PhotoUrls []string `protobuf:"bytes,4,rep,name=photo_urls,json=photoUrls,proto3" json:"photo_urls,omitempty"` + Tags []*Tag `protobuf:"bytes,5,rep,name=tags,proto3" json:"tags,omitempty"` + Status string `protobuf:"bytes,6,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *Pet) Reset() { + *x = Pet{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pet) ProtoMessage() {} + +func (x *Pet) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pet.ProtoReflect.Descriptor instead. +func (*Pet) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{3} +} + +func (x *Pet) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Pet) GetCategory() *Category { + if x != nil { + return x.Category + } + return nil +} + +func (x *Pet) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Pet) GetPhotoUrls() []string { + if x != nil { + return x.PhotoUrls + } + return nil +} + +func (x *Pet) GetTags() []*Tag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *Pet) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +type UpdatePetWithFormReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PetId int64 `protobuf:"varint,1,opt,name=pet_id,json=petId,proto3" json:"pet_id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *UpdatePetWithFormReq) Reset() { + *x = UpdatePetWithFormReq{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdatePetWithFormReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePetWithFormReq) ProtoMessage() {} + +func (x *UpdatePetWithFormReq) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePetWithFormReq.ProtoReflect.Descriptor instead. +func (*UpdatePetWithFormReq) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{4} +} + +func (x *UpdatePetWithFormReq) GetPetId() int64 { + if x != nil { + return x.PetId + } + return 0 +} + +func (x *UpdatePetWithFormReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdatePetWithFormReq) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +type UploadFileReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PetId int64 `protobuf:"varint,1,opt,name=pet_id,json=petId,proto3" json:"pet_id,omitempty"` + AdditionalMetadata string `protobuf:"bytes,2,opt,name=additional_metadata,json=additionalMetadata,proto3" json:"additional_metadata,omitempty"` + File string `protobuf:"bytes,3,opt,name=file,proto3" json:"file,omitempty"` +} + +func (x *UploadFileReq) Reset() { + *x = UploadFileReq{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadFileReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadFileReq) ProtoMessage() {} + +func (x *UploadFileReq) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UploadFileReq.ProtoReflect.Descriptor instead. +func (*UploadFileReq) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{5} +} + +func (x *UploadFileReq) GetPetId() int64 { + if x != nil { + return x.PetId + } + return 0 +} + +func (x *UploadFileReq) GetAdditionalMetadata() string { + if x != nil { + return x.AdditionalMetadata + } + return "" +} + +func (x *UploadFileReq) GetFile() string { + if x != nil { + return x.File + } + return "" +} + +type PetBody struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PetId int64 `protobuf:"varint,1,opt,name=pet_id,json=petId,proto3" json:"pet_id,omitempty"` + Body string `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` +} + +func (x *PetBody) Reset() { + *x = PetBody{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PetBody) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PetBody) ProtoMessage() {} + +func (x *PetBody) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PetBody.ProtoReflect.Descriptor instead. +func (*PetBody) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{6} +} + +func (x *PetBody) GetPetId() int64 { + if x != nil { + return x.PetId + } + return 0 +} + +func (x *PetBody) GetBody() string { + if x != nil { + return x.Body + } + return "" +} + +type StatusReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status []string `protobuf:"bytes,1,rep,name=status,proto3" json:"status,omitempty"` +} + +func (x *StatusReq) Reset() { + *x = StatusReq{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusReq) ProtoMessage() {} + +func (x *StatusReq) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StatusReq.ProtoReflect.Descriptor instead. +func (*StatusReq) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{7} +} + +func (x *StatusReq) GetStatus() []string { + if x != nil { + return x.Status + } + return nil +} + +type TagReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag []string `protobuf:"bytes,1,rep,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *TagReq) Reset() { + *x = TagReq{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TagReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TagReq) ProtoMessage() {} + +func (x *TagReq) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TagReq.ProtoReflect.Descriptor instead. +func (*TagReq) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{8} +} + +func (x *TagReq) GetTag() []string { + if x != nil { + return x.Tag + } + return nil +} + +type Pets struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Pets []*Pet `protobuf:"bytes,1,rep,name=pets,proto3" json:"pets,omitempty"` +} + +func (x *Pets) Reset() { + *x = Pets{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pets) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pets) ProtoMessage() {} + +func (x *Pets) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pets.ProtoReflect.Descriptor instead. +func (*Pets) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{9} +} + +func (x *Pets) GetPets() []*Pet { + if x != nil { + return x.Pets + } + return nil +} + +type ApiResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *ApiResponse) Reset() { + *x = ApiResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApiResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApiResponse) ProtoMessage() {} + +func (x *ApiResponse) ProtoReflect() protoreflect.Message { + mi := &file_io_swagger_petstore_v2_pets_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApiResponse.ProtoReflect.Descriptor instead. +func (*ApiResponse) Descriptor() ([]byte, []int) { + return file_io_swagger_petstore_v2_pets_proto_rawDescGZIP(), []int{10} +} + +func (x *ApiResponse) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *ApiResponse) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *ApiResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_io_swagger_petstore_v2_pets_proto protoreflect.FileDescriptor + +var file_io_swagger_petstore_v2_pets_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x69, 0x6f, 0x2f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x70, 0x65, 0x74, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x65, 0x74, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, + 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2e, 0x0a, 0x08, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, + 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x22, 0x1e, 0x0a, 0x05, 0x50, 0x65, 0x74, 0x49, 0x44, 0x12, 0x15, 0x0a, 0x06, 0x70, 0x65, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x65, 0x74, 0x49, + 0x64, 0x22, 0xcf, 0x01, 0x0a, 0x03, 0x50, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x63, 0x61, 0x74, + 0x65, 0x67, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6f, + 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x08, 0x63, + 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, + 0x68, 0x6f, 0x74, 0x6f, 0x5f, 0x75, 0x72, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x09, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x55, 0x72, 0x6c, 0x73, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, + 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x22, 0x59, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, + 0x57, 0x69, 0x74, 0x68, 0x46, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x15, 0x0a, 0x06, 0x70, + 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x65, 0x74, + 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x6b, + 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x12, + 0x15, 0x0a, 0x06, 0x70, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x05, 0x70, 0x65, 0x74, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x13, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x12, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x34, 0x0a, 0x07, 0x50, + 0x65, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x15, 0x0a, 0x06, 0x70, 0x65, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x65, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, + 0x79, 0x22, 0x23, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x1a, 0x0a, 0x06, 0x54, 0x61, 0x67, 0x52, 0x65, 0x71, + 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x74, + 0x61, 0x67, 0x22, 0x37, 0x0a, 0x04, 0x50, 0x65, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x04, 0x70, 0x65, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, + 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x32, 0x2e, 0x50, 0x65, 0x74, 0x52, 0x04, 0x70, 0x65, 0x74, 0x73, 0x22, 0x4f, 0x0a, 0x0b, 0x41, + 0x70, 0x69, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x3b, 0x0a, 0x06, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x12, + 0x08, 0x0a, 0x04, 0x73, 0x6f, 0x6c, 0x64, 0x10, 0x03, 0x32, 0xda, 0x06, 0x0a, 0x0a, 0x50, 0x65, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, + 0x65, 0x74, 0x42, 0x79, 0x49, 0x44, 0x12, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, + 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, + 0x50, 0x65, 0x74, 0x49, 0x44, 0x1a, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, + 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, + 0x65, 0x74, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x70, 0x65, 0x74, + 0x2f, 0x7b, 0x70, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x7d, 0x90, 0x02, 0x01, 0x12, 0x73, 0x0a, 0x11, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, 0x57, 0x69, 0x74, 0x68, 0x46, 0x6f, 0x72, + 0x6d, 0x12, 0x2c, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, + 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x50, 0x65, 0x74, 0x57, 0x69, 0x74, 0x68, 0x46, 0x6f, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x1a, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, + 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x70, 0x65, 0x74, 0x2f, 0x7b, 0x70, 0x65, 0x74, 0x5f, 0x69, 0x64, + 0x7d, 0x12, 0x59, 0x0a, 0x09, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x74, 0x12, 0x1d, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, 0x74, 0x49, 0x44, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x2a, 0x0d, 0x2f, + 0x70, 0x65, 0x74, 0x2f, 0x7b, 0x70, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x7e, 0x0a, 0x0a, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x25, 0x2e, 0x69, 0x6f, 0x2e, + 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x1a, 0x23, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, + 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x41, 0x70, 0x69, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x01, + 0x2a, 0x22, 0x19, 0x2f, 0x70, 0x65, 0x74, 0x2f, 0x7b, 0x70, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x7d, + 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x53, 0x0a, 0x06, + 0x41, 0x64, 0x64, 0x50, 0x65, 0x74, 0x12, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, + 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, + 0x50, 0x65, 0x74, 0x1a, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, + 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, 0x74, + 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x3a, 0x01, 0x2a, 0x22, 0x04, 0x2f, 0x70, 0x65, + 0x74, 0x12, 0x56, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, 0x12, 0x1b, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, 0x74, 0x1a, 0x1b, 0x2e, 0x69, 0x6f, + 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, 0x74, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, + 0x3a, 0x01, 0x2a, 0x1a, 0x04, 0x2f, 0x70, 0x65, 0x74, 0x12, 0x72, 0x0a, 0x0d, 0x46, 0x69, 0x6e, + 0x64, 0x50, 0x65, 0x74, 0x73, 0x42, 0x79, 0x54, 0x61, 0x67, 0x12, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, + 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, + 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, 0x74, 0x73, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, + 0x62, 0x04, 0x70, 0x65, 0x74, 0x73, 0x12, 0x0f, 0x2f, 0x70, 0x65, 0x74, 0x2f, 0x66, 0x69, 0x6e, + 0x64, 0x42, 0x79, 0x54, 0x61, 0x67, 0x73, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0x77, 0x0a, + 0x10, 0x46, 0x69, 0x6e, 0x64, 0x50, 0x65, 0x74, 0x73, 0x42, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x21, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, + 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, + 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, + 0x74, 0x73, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x62, 0x04, 0x70, 0x65, 0x74, 0x73, + 0x12, 0x11, 0x2f, 0x70, 0x65, 0x74, 0x2f, 0x66, 0x69, 0x6e, 0x64, 0x42, 0x79, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x90, 0x02, 0x01, 0x42, 0xea, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x69, + 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x09, 0x50, 0x65, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x46, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6f, 0x2f, 0x73, 0x77, 0x61, 0x67, + 0x67, 0x65, 0x72, 0x2f, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x32, 0x3b, + 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x49, 0x53, 0x50, + 0xaa, 0x02, 0x16, 0x49, 0x6f, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x50, 0x65, + 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x49, 0x6f, 0x5c, 0x53, + 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x5c, 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, + 0x56, 0x32, 0xe2, 0x02, 0x22, 0x49, 0x6f, 0x5c, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x5c, + 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x49, 0x6f, 0x3a, 0x3a, 0x53, 0x77, + 0x61, 0x67, 0x67, 0x65, 0x72, 0x3a, 0x3a, 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3a, + 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_io_swagger_petstore_v2_pets_proto_rawDescOnce sync.Once + file_io_swagger_petstore_v2_pets_proto_rawDescData = file_io_swagger_petstore_v2_pets_proto_rawDesc +) + +func file_io_swagger_petstore_v2_pets_proto_rawDescGZIP() []byte { + file_io_swagger_petstore_v2_pets_proto_rawDescOnce.Do(func() { + file_io_swagger_petstore_v2_pets_proto_rawDescData = protoimpl.X.CompressGZIP(file_io_swagger_petstore_v2_pets_proto_rawDescData) + }) + return file_io_swagger_petstore_v2_pets_proto_rawDescData +} + +var file_io_swagger_petstore_v2_pets_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_io_swagger_petstore_v2_pets_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_io_swagger_petstore_v2_pets_proto_goTypes = []interface{}{ + (Status)(0), // 0: io.swagger.petstore.v2.Status + (*Category)(nil), // 1: io.swagger.petstore.v2.Category + (*Tag)(nil), // 2: io.swagger.petstore.v2.Tag + (*PetID)(nil), // 3: io.swagger.petstore.v2.PetID + (*Pet)(nil), // 4: io.swagger.petstore.v2.Pet + (*UpdatePetWithFormReq)(nil), // 5: io.swagger.petstore.v2.UpdatePetWithFormReq + (*UploadFileReq)(nil), // 6: io.swagger.petstore.v2.UploadFileReq + (*PetBody)(nil), // 7: io.swagger.petstore.v2.PetBody + (*StatusReq)(nil), // 8: io.swagger.petstore.v2.StatusReq + (*TagReq)(nil), // 9: io.swagger.petstore.v2.TagReq + (*Pets)(nil), // 10: io.swagger.petstore.v2.Pets + (*ApiResponse)(nil), // 11: io.swagger.petstore.v2.ApiResponse + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_io_swagger_petstore_v2_pets_proto_depIdxs = []int32{ + 1, // 0: io.swagger.petstore.v2.Pet.category:type_name -> io.swagger.petstore.v2.Category + 2, // 1: io.swagger.petstore.v2.Pet.tags:type_name -> io.swagger.petstore.v2.Tag + 4, // 2: io.swagger.petstore.v2.Pets.pets:type_name -> io.swagger.petstore.v2.Pet + 3, // 3: io.swagger.petstore.v2.PetService.GetPetByID:input_type -> io.swagger.petstore.v2.PetID + 5, // 4: io.swagger.petstore.v2.PetService.UpdatePetWithForm:input_type -> io.swagger.petstore.v2.UpdatePetWithFormReq + 3, // 5: io.swagger.petstore.v2.PetService.DeletePet:input_type -> io.swagger.petstore.v2.PetID + 6, // 6: io.swagger.petstore.v2.PetService.UploadFile:input_type -> io.swagger.petstore.v2.UploadFileReq + 4, // 7: io.swagger.petstore.v2.PetService.AddPet:input_type -> io.swagger.petstore.v2.Pet + 4, // 8: io.swagger.petstore.v2.PetService.UpdatePet:input_type -> io.swagger.petstore.v2.Pet + 9, // 9: io.swagger.petstore.v2.PetService.FindPetsByTag:input_type -> io.swagger.petstore.v2.TagReq + 8, // 10: io.swagger.petstore.v2.PetService.FindPetsByStatus:input_type -> io.swagger.petstore.v2.StatusReq + 4, // 11: io.swagger.petstore.v2.PetService.GetPetByID:output_type -> io.swagger.petstore.v2.Pet + 12, // 12: io.swagger.petstore.v2.PetService.UpdatePetWithForm:output_type -> google.protobuf.Empty + 12, // 13: io.swagger.petstore.v2.PetService.DeletePet:output_type -> google.protobuf.Empty + 11, // 14: io.swagger.petstore.v2.PetService.UploadFile:output_type -> io.swagger.petstore.v2.ApiResponse + 4, // 15: io.swagger.petstore.v2.PetService.AddPet:output_type -> io.swagger.petstore.v2.Pet + 4, // 16: io.swagger.petstore.v2.PetService.UpdatePet:output_type -> io.swagger.petstore.v2.Pet + 10, // 17: io.swagger.petstore.v2.PetService.FindPetsByTag:output_type -> io.swagger.petstore.v2.Pets + 10, // 18: io.swagger.petstore.v2.PetService.FindPetsByStatus:output_type -> io.swagger.petstore.v2.Pets + 11, // [11:19] is the sub-list for method output_type + 3, // [3:11] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_io_swagger_petstore_v2_pets_proto_init() } +func file_io_swagger_petstore_v2_pets_proto_init() { + if File_io_swagger_petstore_v2_pets_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_io_swagger_petstore_v2_pets_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Category); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Tag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PetID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Pet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdatePetWithFormReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadFileReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PetBody); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TagReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Pets); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_swagger_petstore_v2_pets_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApiResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_io_swagger_petstore_v2_pets_proto_rawDesc, + NumEnums: 1, + NumMessages: 11, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_io_swagger_petstore_v2_pets_proto_goTypes, + DependencyIndexes: file_io_swagger_petstore_v2_pets_proto_depIdxs, + EnumInfos: file_io_swagger_petstore_v2_pets_proto_enumTypes, + MessageInfos: file_io_swagger_petstore_v2_pets_proto_msgTypes, + }.Build() + File_io_swagger_petstore_v2_pets_proto = out.File + file_io_swagger_petstore_v2_pets_proto_rawDesc = nil + file_io_swagger_petstore_v2_pets_proto_goTypes = nil + file_io_swagger_petstore_v2_pets_proto_depIdxs = nil +} diff --git a/internal/gen/io/swagger/petstore/v2/pets_grpc.pb.go b/internal/gen/io/swagger/petstore/v2/pets_grpc.pb.go new file mode 100644 index 0000000..59c3a61 --- /dev/null +++ b/internal/gen/io/swagger/petstore/v2/pets_grpc.pb.go @@ -0,0 +1,396 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: io/swagger/petstore/v2/pets.proto + +// The service defined herein comes from v2 of the Petstore service, which +// is used as an example for Swagger/OpenAPI. The Swagger spec can be found +// here: https://petstore.swagger.io/v2/swagger.json +// A human-friendly HTML view of this API is also available at +// https://petstore.swagger.io. +// +// This file defines only the "pet" service. The spec for this site also +// includes "store" and "user" services which are not supported via these +// RPC definitions. + +package petstorev2 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + PetService_GetPetByID_FullMethodName = "/io.swagger.petstore.v2.PetService/GetPetByID" + PetService_UpdatePetWithForm_FullMethodName = "/io.swagger.petstore.v2.PetService/UpdatePetWithForm" + PetService_DeletePet_FullMethodName = "/io.swagger.petstore.v2.PetService/DeletePet" + PetService_UploadFile_FullMethodName = "/io.swagger.petstore.v2.PetService/UploadFile" + PetService_AddPet_FullMethodName = "/io.swagger.petstore.v2.PetService/AddPet" + PetService_UpdatePet_FullMethodName = "/io.swagger.petstore.v2.PetService/UpdatePet" + PetService_FindPetsByTag_FullMethodName = "/io.swagger.petstore.v2.PetService/FindPetsByTag" + PetService_FindPetsByStatus_FullMethodName = "/io.swagger.petstore.v2.PetService/FindPetsByStatus" +) + +// PetServiceClient is the client API for PetService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type PetServiceClient interface { + GetPetByID(ctx context.Context, in *PetID, opts ...grpc.CallOption) (*Pet, error) + UpdatePetWithForm(ctx context.Context, in *UpdatePetWithFormReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + DeletePet(ctx context.Context, in *PetID, opts ...grpc.CallOption) (*emptypb.Empty, error) + UploadFile(ctx context.Context, in *UploadFileReq, opts ...grpc.CallOption) (*ApiResponse, error) + AddPet(ctx context.Context, in *Pet, opts ...grpc.CallOption) (*Pet, error) + UpdatePet(ctx context.Context, in *Pet, opts ...grpc.CallOption) (*Pet, error) + // Deprecated: Do not use. + FindPetsByTag(ctx context.Context, in *TagReq, opts ...grpc.CallOption) (*Pets, error) + FindPetsByStatus(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Pets, error) +} + +type petServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPetServiceClient(cc grpc.ClientConnInterface) PetServiceClient { + return &petServiceClient{cc} +} + +func (c *petServiceClient) GetPetByID(ctx context.Context, in *PetID, opts ...grpc.CallOption) (*Pet, error) { + out := new(Pet) + err := c.cc.Invoke(ctx, PetService_GetPetByID_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *petServiceClient) UpdatePetWithForm(ctx context.Context, in *UpdatePetWithFormReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, PetService_UpdatePetWithForm_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *petServiceClient) DeletePet(ctx context.Context, in *PetID, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, PetService_DeletePet_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *petServiceClient) UploadFile(ctx context.Context, in *UploadFileReq, opts ...grpc.CallOption) (*ApiResponse, error) { + out := new(ApiResponse) + err := c.cc.Invoke(ctx, PetService_UploadFile_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *petServiceClient) AddPet(ctx context.Context, in *Pet, opts ...grpc.CallOption) (*Pet, error) { + out := new(Pet) + err := c.cc.Invoke(ctx, PetService_AddPet_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *petServiceClient) UpdatePet(ctx context.Context, in *Pet, opts ...grpc.CallOption) (*Pet, error) { + out := new(Pet) + err := c.cc.Invoke(ctx, PetService_UpdatePet_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Deprecated: Do not use. +func (c *petServiceClient) FindPetsByTag(ctx context.Context, in *TagReq, opts ...grpc.CallOption) (*Pets, error) { + out := new(Pets) + err := c.cc.Invoke(ctx, PetService_FindPetsByTag_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *petServiceClient) FindPetsByStatus(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Pets, error) { + out := new(Pets) + err := c.cc.Invoke(ctx, PetService_FindPetsByStatus_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PetServiceServer is the server API for PetService service. +// All implementations must embed UnimplementedPetServiceServer +// for forward compatibility +type PetServiceServer interface { + GetPetByID(context.Context, *PetID) (*Pet, error) + UpdatePetWithForm(context.Context, *UpdatePetWithFormReq) (*emptypb.Empty, error) + DeletePet(context.Context, *PetID) (*emptypb.Empty, error) + UploadFile(context.Context, *UploadFileReq) (*ApiResponse, error) + AddPet(context.Context, *Pet) (*Pet, error) + UpdatePet(context.Context, *Pet) (*Pet, error) + // Deprecated: Do not use. + FindPetsByTag(context.Context, *TagReq) (*Pets, error) + FindPetsByStatus(context.Context, *StatusReq) (*Pets, error) + mustEmbedUnimplementedPetServiceServer() +} + +// UnimplementedPetServiceServer must be embedded to have forward compatible implementations. +type UnimplementedPetServiceServer struct { +} + +func (UnimplementedPetServiceServer) GetPetByID(context.Context, *PetID) (*Pet, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPetByID not implemented") +} +func (UnimplementedPetServiceServer) UpdatePetWithForm(context.Context, *UpdatePetWithFormReq) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePetWithForm not implemented") +} +func (UnimplementedPetServiceServer) DeletePet(context.Context, *PetID) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeletePet not implemented") +} +func (UnimplementedPetServiceServer) UploadFile(context.Context, *UploadFileReq) (*ApiResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadFile not implemented") +} +func (UnimplementedPetServiceServer) AddPet(context.Context, *Pet) (*Pet, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddPet not implemented") +} +func (UnimplementedPetServiceServer) UpdatePet(context.Context, *Pet) (*Pet, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePet not implemented") +} +func (UnimplementedPetServiceServer) FindPetsByTag(context.Context, *TagReq) (*Pets, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindPetsByTag not implemented") +} +func (UnimplementedPetServiceServer) FindPetsByStatus(context.Context, *StatusReq) (*Pets, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindPetsByStatus not implemented") +} +func (UnimplementedPetServiceServer) mustEmbedUnimplementedPetServiceServer() {} + +// UnsafePetServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PetServiceServer will +// result in compilation errors. +type UnsafePetServiceServer interface { + mustEmbedUnimplementedPetServiceServer() +} + +func RegisterPetServiceServer(s grpc.ServiceRegistrar, srv PetServiceServer) { + s.RegisterService(&PetService_ServiceDesc, srv) +} + +func _PetService_GetPetByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PetID) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).GetPetByID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_GetPetByID_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).GetPetByID(ctx, req.(*PetID)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_UpdatePetWithForm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePetWithFormReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).UpdatePetWithForm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_UpdatePetWithForm_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).UpdatePetWithForm(ctx, req.(*UpdatePetWithFormReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_DeletePet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PetID) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).DeletePet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_DeletePet_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).DeletePet(ctx, req.(*PetID)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_UploadFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UploadFileReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).UploadFile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_UploadFile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).UploadFile(ctx, req.(*UploadFileReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_AddPet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Pet) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).AddPet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_AddPet_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).AddPet(ctx, req.(*Pet)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_UpdatePet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Pet) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).UpdatePet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_UpdatePet_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).UpdatePet(ctx, req.(*Pet)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_FindPetsByTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TagReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).FindPetsByTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_FindPetsByTag_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).FindPetsByTag(ctx, req.(*TagReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _PetService_FindPetsByStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PetServiceServer).FindPetsByStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PetService_FindPetsByStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PetServiceServer).FindPetsByStatus(ctx, req.(*StatusReq)) + } + return interceptor(ctx, in, info, handler) +} + +// PetService_ServiceDesc is the grpc.ServiceDesc for PetService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PetService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "io.swagger.petstore.v2.PetService", + HandlerType: (*PetServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPetByID", + Handler: _PetService_GetPetByID_Handler, + }, + { + MethodName: "UpdatePetWithForm", + Handler: _PetService_UpdatePetWithForm_Handler, + }, + { + MethodName: "DeletePet", + Handler: _PetService_DeletePet_Handler, + }, + { + MethodName: "UploadFile", + Handler: _PetService_UploadFile_Handler, + }, + { + MethodName: "AddPet", + Handler: _PetService_AddPet_Handler, + }, + { + MethodName: "UpdatePet", + Handler: _PetService_UpdatePet_Handler, + }, + { + MethodName: "FindPetsByTag", + Handler: _PetService_FindPetsByTag_Handler, + }, + { + MethodName: "FindPetsByStatus", + Handler: _PetService_FindPetsByStatus_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "io/swagger/petstore/v2/pets.proto", +} diff --git a/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go b/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go new file mode 100644 index 0000000..996e893 --- /dev/null +++ b/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go @@ -0,0 +1,352 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: io/swagger/petstore/v2/pets.proto + +// The service defined herein comes from v2 of the Petstore service, which +// is used as an example for Swagger/OpenAPI. The Swagger spec can be found +// here: https://petstore.swagger.io/v2/swagger.json +// A human-friendly HTML view of this API is also available at +// https://petstore.swagger.io. +// +// This file defines only the "pet" service. The spec for this site also +// includes "store" and "user" services which are not supported via these +// RPC definitions. +package petstorev2connect + +import ( + connect "connectrpc.com/connect" + v2 "connectrpc.com/vanguard/internal/gen/io/swagger/petstore/v2" + context "context" + errors "errors" + emptypb "google.golang.org/protobuf/types/known/emptypb" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // PetServiceName is the fully-qualified name of the PetService service. + PetServiceName = "io.swagger.petstore.v2.PetService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // PetServiceGetPetByIDProcedure is the fully-qualified name of the PetService's GetPetByID RPC. + PetServiceGetPetByIDProcedure = "/io.swagger.petstore.v2.PetService/GetPetByID" + // PetServiceUpdatePetWithFormProcedure is the fully-qualified name of the PetService's + // UpdatePetWithForm RPC. + PetServiceUpdatePetWithFormProcedure = "/io.swagger.petstore.v2.PetService/UpdatePetWithForm" + // PetServiceDeletePetProcedure is the fully-qualified name of the PetService's DeletePet RPC. + PetServiceDeletePetProcedure = "/io.swagger.petstore.v2.PetService/DeletePet" + // PetServiceUploadFileProcedure is the fully-qualified name of the PetService's UploadFile RPC. + PetServiceUploadFileProcedure = "/io.swagger.petstore.v2.PetService/UploadFile" + // PetServiceAddPetProcedure is the fully-qualified name of the PetService's AddPet RPC. + PetServiceAddPetProcedure = "/io.swagger.petstore.v2.PetService/AddPet" + // PetServiceUpdatePetProcedure is the fully-qualified name of the PetService's UpdatePet RPC. + PetServiceUpdatePetProcedure = "/io.swagger.petstore.v2.PetService/UpdatePet" + // PetServiceFindPetsByTagProcedure is the fully-qualified name of the PetService's FindPetsByTag + // RPC. + PetServiceFindPetsByTagProcedure = "/io.swagger.petstore.v2.PetService/FindPetsByTag" + // PetServiceFindPetsByStatusProcedure is the fully-qualified name of the PetService's + // FindPetsByStatus RPC. + PetServiceFindPetsByStatusProcedure = "/io.swagger.petstore.v2.PetService/FindPetsByStatus" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + petServiceServiceDescriptor = v2.File_io_swagger_petstore_v2_pets_proto.Services().ByName("PetService") + petServiceGetPetByIDMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("GetPetByID") + petServiceUpdatePetWithFormMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("UpdatePetWithForm") + petServiceDeletePetMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("DeletePet") + petServiceUploadFileMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("UploadFile") + petServiceAddPetMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("AddPet") + petServiceUpdatePetMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("UpdatePet") + petServiceFindPetsByTagMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("FindPetsByTag") + petServiceFindPetsByStatusMethodDescriptor = petServiceServiceDescriptor.Methods().ByName("FindPetsByStatus") +) + +// PetServiceClient is a client for the io.swagger.petstore.v2.PetService service. +type PetServiceClient interface { + GetPetByID(context.Context, *connect.Request[v2.PetID]) (*connect.Response[v2.Pet], error) + UpdatePetWithForm(context.Context, *connect.Request[v2.UpdatePetWithFormReq]) (*connect.Response[emptypb.Empty], error) + DeletePet(context.Context, *connect.Request[v2.PetID]) (*connect.Response[emptypb.Empty], error) + UploadFile(context.Context, *connect.Request[v2.UploadFileReq]) (*connect.Response[v2.ApiResponse], error) + AddPet(context.Context, *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) + UpdatePet(context.Context, *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) + // Deprecated: do not use. + FindPetsByTag(context.Context, *connect.Request[v2.TagReq]) (*connect.Response[v2.Pets], error) + FindPetsByStatus(context.Context, *connect.Request[v2.StatusReq]) (*connect.Response[v2.Pets], error) +} + +// NewPetServiceClient constructs a client for the io.swagger.petstore.v2.PetService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewPetServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) PetServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &petServiceClient{ + getPetByID: connect.NewClient[v2.PetID, v2.Pet]( + httpClient, + baseURL+PetServiceGetPetByIDProcedure, + connect.WithSchema(petServiceGetPetByIDMethodDescriptor), + connect.WithIdempotency(connect.IdempotencyNoSideEffects), + connect.WithClientOptions(opts...), + ), + updatePetWithForm: connect.NewClient[v2.UpdatePetWithFormReq, emptypb.Empty]( + httpClient, + baseURL+PetServiceUpdatePetWithFormProcedure, + connect.WithSchema(petServiceUpdatePetWithFormMethodDescriptor), + connect.WithClientOptions(opts...), + ), + deletePet: connect.NewClient[v2.PetID, emptypb.Empty]( + httpClient, + baseURL+PetServiceDeletePetProcedure, + connect.WithSchema(petServiceDeletePetMethodDescriptor), + connect.WithClientOptions(opts...), + ), + uploadFile: connect.NewClient[v2.UploadFileReq, v2.ApiResponse]( + httpClient, + baseURL+PetServiceUploadFileProcedure, + connect.WithSchema(petServiceUploadFileMethodDescriptor), + connect.WithClientOptions(opts...), + ), + addPet: connect.NewClient[v2.Pet, v2.Pet]( + httpClient, + baseURL+PetServiceAddPetProcedure, + connect.WithSchema(petServiceAddPetMethodDescriptor), + connect.WithClientOptions(opts...), + ), + updatePet: connect.NewClient[v2.Pet, v2.Pet]( + httpClient, + baseURL+PetServiceUpdatePetProcedure, + connect.WithSchema(petServiceUpdatePetMethodDescriptor), + connect.WithClientOptions(opts...), + ), + findPetsByTag: connect.NewClient[v2.TagReq, v2.Pets]( + httpClient, + baseURL+PetServiceFindPetsByTagProcedure, + connect.WithSchema(petServiceFindPetsByTagMethodDescriptor), + connect.WithIdempotency(connect.IdempotencyNoSideEffects), + connect.WithClientOptions(opts...), + ), + findPetsByStatus: connect.NewClient[v2.StatusReq, v2.Pets]( + httpClient, + baseURL+PetServiceFindPetsByStatusProcedure, + connect.WithSchema(petServiceFindPetsByStatusMethodDescriptor), + connect.WithIdempotency(connect.IdempotencyNoSideEffects), + connect.WithClientOptions(opts...), + ), + } +} + +// petServiceClient implements PetServiceClient. +type petServiceClient struct { + getPetByID *connect.Client[v2.PetID, v2.Pet] + updatePetWithForm *connect.Client[v2.UpdatePetWithFormReq, emptypb.Empty] + deletePet *connect.Client[v2.PetID, emptypb.Empty] + uploadFile *connect.Client[v2.UploadFileReq, v2.ApiResponse] + addPet *connect.Client[v2.Pet, v2.Pet] + updatePet *connect.Client[v2.Pet, v2.Pet] + findPetsByTag *connect.Client[v2.TagReq, v2.Pets] + findPetsByStatus *connect.Client[v2.StatusReq, v2.Pets] +} + +// GetPetByID calls io.swagger.petstore.v2.PetService.GetPetByID. +func (c *petServiceClient) GetPetByID(ctx context.Context, req *connect.Request[v2.PetID]) (*connect.Response[v2.Pet], error) { + return c.getPetByID.CallUnary(ctx, req) +} + +// UpdatePetWithForm calls io.swagger.petstore.v2.PetService.UpdatePetWithForm. +func (c *petServiceClient) UpdatePetWithForm(ctx context.Context, req *connect.Request[v2.UpdatePetWithFormReq]) (*connect.Response[emptypb.Empty], error) { + return c.updatePetWithForm.CallUnary(ctx, req) +} + +// DeletePet calls io.swagger.petstore.v2.PetService.DeletePet. +func (c *petServiceClient) DeletePet(ctx context.Context, req *connect.Request[v2.PetID]) (*connect.Response[emptypb.Empty], error) { + return c.deletePet.CallUnary(ctx, req) +} + +// UploadFile calls io.swagger.petstore.v2.PetService.UploadFile. +func (c *petServiceClient) UploadFile(ctx context.Context, req *connect.Request[v2.UploadFileReq]) (*connect.Response[v2.ApiResponse], error) { + return c.uploadFile.CallUnary(ctx, req) +} + +// AddPet calls io.swagger.petstore.v2.PetService.AddPet. +func (c *petServiceClient) AddPet(ctx context.Context, req *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) { + return c.addPet.CallUnary(ctx, req) +} + +// UpdatePet calls io.swagger.petstore.v2.PetService.UpdatePet. +func (c *petServiceClient) UpdatePet(ctx context.Context, req *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) { + return c.updatePet.CallUnary(ctx, req) +} + +// FindPetsByTag calls io.swagger.petstore.v2.PetService.FindPetsByTag. +// +// Deprecated: do not use. +func (c *petServiceClient) FindPetsByTag(ctx context.Context, req *connect.Request[v2.TagReq]) (*connect.Response[v2.Pets], error) { + return c.findPetsByTag.CallUnary(ctx, req) +} + +// FindPetsByStatus calls io.swagger.petstore.v2.PetService.FindPetsByStatus. +func (c *petServiceClient) FindPetsByStatus(ctx context.Context, req *connect.Request[v2.StatusReq]) (*connect.Response[v2.Pets], error) { + return c.findPetsByStatus.CallUnary(ctx, req) +} + +// PetServiceHandler is an implementation of the io.swagger.petstore.v2.PetService service. +type PetServiceHandler interface { + GetPetByID(context.Context, *connect.Request[v2.PetID]) (*connect.Response[v2.Pet], error) + UpdatePetWithForm(context.Context, *connect.Request[v2.UpdatePetWithFormReq]) (*connect.Response[emptypb.Empty], error) + DeletePet(context.Context, *connect.Request[v2.PetID]) (*connect.Response[emptypb.Empty], error) + UploadFile(context.Context, *connect.Request[v2.UploadFileReq]) (*connect.Response[v2.ApiResponse], error) + AddPet(context.Context, *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) + UpdatePet(context.Context, *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) + // Deprecated: do not use. + FindPetsByTag(context.Context, *connect.Request[v2.TagReq]) (*connect.Response[v2.Pets], error) + FindPetsByStatus(context.Context, *connect.Request[v2.StatusReq]) (*connect.Response[v2.Pets], error) +} + +// NewPetServiceHandler builds an HTTP handler from the service implementation. It returns the path +// on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewPetServiceHandler(svc PetServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + petServiceGetPetByIDHandler := connect.NewUnaryHandler( + PetServiceGetPetByIDProcedure, + svc.GetPetByID, + connect.WithSchema(petServiceGetPetByIDMethodDescriptor), + connect.WithIdempotency(connect.IdempotencyNoSideEffects), + connect.WithHandlerOptions(opts...), + ) + petServiceUpdatePetWithFormHandler := connect.NewUnaryHandler( + PetServiceUpdatePetWithFormProcedure, + svc.UpdatePetWithForm, + connect.WithSchema(petServiceUpdatePetWithFormMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + petServiceDeletePetHandler := connect.NewUnaryHandler( + PetServiceDeletePetProcedure, + svc.DeletePet, + connect.WithSchema(petServiceDeletePetMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + petServiceUploadFileHandler := connect.NewUnaryHandler( + PetServiceUploadFileProcedure, + svc.UploadFile, + connect.WithSchema(petServiceUploadFileMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + petServiceAddPetHandler := connect.NewUnaryHandler( + PetServiceAddPetProcedure, + svc.AddPet, + connect.WithSchema(petServiceAddPetMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + petServiceUpdatePetHandler := connect.NewUnaryHandler( + PetServiceUpdatePetProcedure, + svc.UpdatePet, + connect.WithSchema(petServiceUpdatePetMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + petServiceFindPetsByTagHandler := connect.NewUnaryHandler( + PetServiceFindPetsByTagProcedure, + svc.FindPetsByTag, + connect.WithSchema(petServiceFindPetsByTagMethodDescriptor), + connect.WithIdempotency(connect.IdempotencyNoSideEffects), + connect.WithHandlerOptions(opts...), + ) + petServiceFindPetsByStatusHandler := connect.NewUnaryHandler( + PetServiceFindPetsByStatusProcedure, + svc.FindPetsByStatus, + connect.WithSchema(petServiceFindPetsByStatusMethodDescriptor), + connect.WithIdempotency(connect.IdempotencyNoSideEffects), + connect.WithHandlerOptions(opts...), + ) + return "/io.swagger.petstore.v2.PetService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case PetServiceGetPetByIDProcedure: + petServiceGetPetByIDHandler.ServeHTTP(w, r) + case PetServiceUpdatePetWithFormProcedure: + petServiceUpdatePetWithFormHandler.ServeHTTP(w, r) + case PetServiceDeletePetProcedure: + petServiceDeletePetHandler.ServeHTTP(w, r) + case PetServiceUploadFileProcedure: + petServiceUploadFileHandler.ServeHTTP(w, r) + case PetServiceAddPetProcedure: + petServiceAddPetHandler.ServeHTTP(w, r) + case PetServiceUpdatePetProcedure: + petServiceUpdatePetHandler.ServeHTTP(w, r) + case PetServiceFindPetsByTagProcedure: + petServiceFindPetsByTagHandler.ServeHTTP(w, r) + case PetServiceFindPetsByStatusProcedure: + petServiceFindPetsByStatusHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedPetServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedPetServiceHandler struct{} + +func (UnimplementedPetServiceHandler) GetPetByID(context.Context, *connect.Request[v2.PetID]) (*connect.Response[v2.Pet], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.GetPetByID is not implemented")) +} + +func (UnimplementedPetServiceHandler) UpdatePetWithForm(context.Context, *connect.Request[v2.UpdatePetWithFormReq]) (*connect.Response[emptypb.Empty], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.UpdatePetWithForm is not implemented")) +} + +func (UnimplementedPetServiceHandler) DeletePet(context.Context, *connect.Request[v2.PetID]) (*connect.Response[emptypb.Empty], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.DeletePet is not implemented")) +} + +func (UnimplementedPetServiceHandler) UploadFile(context.Context, *connect.Request[v2.UploadFileReq]) (*connect.Response[v2.ApiResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.UploadFile is not implemented")) +} + +func (UnimplementedPetServiceHandler) AddPet(context.Context, *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.AddPet is not implemented")) +} + +func (UnimplementedPetServiceHandler) UpdatePet(context.Context, *connect.Request[v2.Pet]) (*connect.Response[v2.Pet], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.UpdatePet is not implemented")) +} + +func (UnimplementedPetServiceHandler) FindPetsByTag(context.Context, *connect.Request[v2.TagReq]) (*connect.Response[v2.Pets], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.FindPetsByTag is not implemented")) +} + +func (UnimplementedPetServiceHandler) FindPetsByStatus(context.Context, *connect.Request[v2.StatusReq]) (*connect.Response[v2.Pets], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("io.swagger.petstore.v2.PetService.FindPetsByStatus is not implemented")) +} diff --git a/internal/gen/vanguard/test/v1/restricted.pb.go b/internal/gen/vanguard/test/v1/restricted.pb.go new file mode 100644 index 0000000..5d25bca --- /dev/null +++ b/internal/gen/vanguard/test/v1/restricted.pb.go @@ -0,0 +1,121 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc (unknown) +// source: vanguard/test/v1/restricted.proto + +package testv1 + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_vanguard_test_v1_restricted_proto protoreflect.FileDescriptor + +var file_vanguard_test_v1_restricted_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, + 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x74, 0x65, + 0x73, 0x74, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x32, 0xab, 0x02, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5a, 0x0a, 0x0a, 0x42, 0x69, 0x64, 0x69, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, + 0x0d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x73, 0x2f, 0x62, 0x69, 0x64, 0x69, 0x28, 0x01, + 0x30, 0x01, 0x12, 0x5c, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x28, 0x01, + 0x12, 0x5c, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x73, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x01, 0x42, 0xc7, + 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x52, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, + 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x61, 0x6e, 0x67, 0x75, + 0x61, 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x76, + 0x31, 0x3b, 0x74, 0x65, 0x73, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x56, 0x54, 0x58, 0xaa, 0x02, + 0x10, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x2e, 0x56, + 0x31, 0xca, 0x02, 0x10, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x5c, 0x54, 0x65, 0x73, + 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x5c, + 0x54, 0x65, 0x73, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x56, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x3a, 0x3a, + 0x54, 0x65, 0x73, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_vanguard_test_v1_restricted_proto_goTypes = []interface{}{ + (*emptypb.Empty)(nil), // 0: google.protobuf.Empty +} +var file_vanguard_test_v1_restricted_proto_depIdxs = []int32{ + 0, // 0: vanguard.test.v1.RestrictedService.BidiStream:input_type -> google.protobuf.Empty + 0, // 1: vanguard.test.v1.RestrictedService.ClientStream:input_type -> google.protobuf.Empty + 0, // 2: vanguard.test.v1.RestrictedService.ServerStream:input_type -> google.protobuf.Empty + 0, // 3: vanguard.test.v1.RestrictedService.BidiStream:output_type -> google.protobuf.Empty + 0, // 4: vanguard.test.v1.RestrictedService.ClientStream:output_type -> google.protobuf.Empty + 0, // 5: vanguard.test.v1.RestrictedService.ServerStream:output_type -> google.protobuf.Empty + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_vanguard_test_v1_restricted_proto_init() } +func file_vanguard_test_v1_restricted_proto_init() { + if File_vanguard_test_v1_restricted_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_vanguard_test_v1_restricted_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_vanguard_test_v1_restricted_proto_goTypes, + DependencyIndexes: file_vanguard_test_v1_restricted_proto_depIdxs, + }.Build() + File_vanguard_test_v1_restricted_proto = out.File + file_vanguard_test_v1_restricted_proto_rawDesc = nil + file_vanguard_test_v1_restricted_proto_goTypes = nil + file_vanguard_test_v1_restricted_proto_depIdxs = nil +} diff --git a/internal/gen/vanguard/test/v1/restricted_grpc.pb.go b/internal/gen/vanguard/test/v1/restricted_grpc.pb.go new file mode 100644 index 0000000..9d34428 --- /dev/null +++ b/internal/gen/vanguard/test/v1/restricted_grpc.pb.go @@ -0,0 +1,297 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: vanguard/test/v1/restricted.proto + +package testv1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + RestrictedService_BidiStream_FullMethodName = "/vanguard.test.v1.RestrictedService/BidiStream" + RestrictedService_ClientStream_FullMethodName = "/vanguard.test.v1.RestrictedService/ClientStream" + RestrictedService_ServerStream_FullMethodName = "/vanguard.test.v1.RestrictedService/ServerStream" +) + +// RestrictedServiceClient is the client API for RestrictedService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type RestrictedServiceClient interface { + // BidiStream is a bidi stream, unsupported request and response type. + BidiStream(ctx context.Context, opts ...grpc.CallOption) (RestrictedService_BidiStreamClient, error) + // ClientStream is a client stream, unsupported request type. + ClientStream(ctx context.Context, opts ...grpc.CallOption) (RestrictedService_ClientStreamClient, error) + // ServerStream is a server stream, unsupported response type. + ServerStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (RestrictedService_ServerStreamClient, error) +} + +type restrictedServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewRestrictedServiceClient(cc grpc.ClientConnInterface) RestrictedServiceClient { + return &restrictedServiceClient{cc} +} + +func (c *restrictedServiceClient) BidiStream(ctx context.Context, opts ...grpc.CallOption) (RestrictedService_BidiStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &RestrictedService_ServiceDesc.Streams[0], RestrictedService_BidiStream_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &restrictedServiceBidiStreamClient{stream} + return x, nil +} + +type RestrictedService_BidiStreamClient interface { + Send(*emptypb.Empty) error + Recv() (*emptypb.Empty, error) + grpc.ClientStream +} + +type restrictedServiceBidiStreamClient struct { + grpc.ClientStream +} + +func (x *restrictedServiceBidiStreamClient) Send(m *emptypb.Empty) error { + return x.ClientStream.SendMsg(m) +} + +func (x *restrictedServiceBidiStreamClient) Recv() (*emptypb.Empty, error) { + m := new(emptypb.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *restrictedServiceClient) ClientStream(ctx context.Context, opts ...grpc.CallOption) (RestrictedService_ClientStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &RestrictedService_ServiceDesc.Streams[1], RestrictedService_ClientStream_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &restrictedServiceClientStreamClient{stream} + return x, nil +} + +type RestrictedService_ClientStreamClient interface { + Send(*emptypb.Empty) error + CloseAndRecv() (*emptypb.Empty, error) + grpc.ClientStream +} + +type restrictedServiceClientStreamClient struct { + grpc.ClientStream +} + +func (x *restrictedServiceClientStreamClient) Send(m *emptypb.Empty) error { + return x.ClientStream.SendMsg(m) +} + +func (x *restrictedServiceClientStreamClient) CloseAndRecv() (*emptypb.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(emptypb.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *restrictedServiceClient) ServerStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (RestrictedService_ServerStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &RestrictedService_ServiceDesc.Streams[2], RestrictedService_ServerStream_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &restrictedServiceServerStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type RestrictedService_ServerStreamClient interface { + Recv() (*emptypb.Empty, error) + grpc.ClientStream +} + +type restrictedServiceServerStreamClient struct { + grpc.ClientStream +} + +func (x *restrictedServiceServerStreamClient) Recv() (*emptypb.Empty, error) { + m := new(emptypb.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// RestrictedServiceServer is the server API for RestrictedService service. +// All implementations must embed UnimplementedRestrictedServiceServer +// for forward compatibility +type RestrictedServiceServer interface { + // BidiStream is a bidi stream, unsupported request and response type. + BidiStream(RestrictedService_BidiStreamServer) error + // ClientStream is a client stream, unsupported request type. + ClientStream(RestrictedService_ClientStreamServer) error + // ServerStream is a server stream, unsupported response type. + ServerStream(*emptypb.Empty, RestrictedService_ServerStreamServer) error + mustEmbedUnimplementedRestrictedServiceServer() +} + +// UnimplementedRestrictedServiceServer must be embedded to have forward compatible implementations. +type UnimplementedRestrictedServiceServer struct { +} + +func (UnimplementedRestrictedServiceServer) BidiStream(RestrictedService_BidiStreamServer) error { + return status.Errorf(codes.Unimplemented, "method BidiStream not implemented") +} +func (UnimplementedRestrictedServiceServer) ClientStream(RestrictedService_ClientStreamServer) error { + return status.Errorf(codes.Unimplemented, "method ClientStream not implemented") +} +func (UnimplementedRestrictedServiceServer) ServerStream(*emptypb.Empty, RestrictedService_ServerStreamServer) error { + return status.Errorf(codes.Unimplemented, "method ServerStream not implemented") +} +func (UnimplementedRestrictedServiceServer) mustEmbedUnimplementedRestrictedServiceServer() {} + +// UnsafeRestrictedServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RestrictedServiceServer will +// result in compilation errors. +type UnsafeRestrictedServiceServer interface { + mustEmbedUnimplementedRestrictedServiceServer() +} + +func RegisterRestrictedServiceServer(s grpc.ServiceRegistrar, srv RestrictedServiceServer) { + s.RegisterService(&RestrictedService_ServiceDesc, srv) +} + +func _RestrictedService_BidiStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(RestrictedServiceServer).BidiStream(&restrictedServiceBidiStreamServer{stream}) +} + +type RestrictedService_BidiStreamServer interface { + Send(*emptypb.Empty) error + Recv() (*emptypb.Empty, error) + grpc.ServerStream +} + +type restrictedServiceBidiStreamServer struct { + grpc.ServerStream +} + +func (x *restrictedServiceBidiStreamServer) Send(m *emptypb.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *restrictedServiceBidiStreamServer) Recv() (*emptypb.Empty, error) { + m := new(emptypb.Empty) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _RestrictedService_ClientStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(RestrictedServiceServer).ClientStream(&restrictedServiceClientStreamServer{stream}) +} + +type RestrictedService_ClientStreamServer interface { + SendAndClose(*emptypb.Empty) error + Recv() (*emptypb.Empty, error) + grpc.ServerStream +} + +type restrictedServiceClientStreamServer struct { + grpc.ServerStream +} + +func (x *restrictedServiceClientStreamServer) SendAndClose(m *emptypb.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *restrictedServiceClientStreamServer) Recv() (*emptypb.Empty, error) { + m := new(emptypb.Empty) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _RestrictedService_ServerStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(emptypb.Empty) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(RestrictedServiceServer).ServerStream(m, &restrictedServiceServerStreamServer{stream}) +} + +type RestrictedService_ServerStreamServer interface { + Send(*emptypb.Empty) error + grpc.ServerStream +} + +type restrictedServiceServerStreamServer struct { + grpc.ServerStream +} + +func (x *restrictedServiceServerStreamServer) Send(m *emptypb.Empty) error { + return x.ServerStream.SendMsg(m) +} + +// RestrictedService_ServiceDesc is the grpc.ServiceDesc for RestrictedService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var RestrictedService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "vanguard.test.v1.RestrictedService", + HandlerType: (*RestrictedServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "BidiStream", + Handler: _RestrictedService_BidiStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "ClientStream", + Handler: _RestrictedService_ClientStream_Handler, + ClientStreams: true, + }, + { + StreamName: "ServerStream", + Handler: _RestrictedService_ServerStream_Handler, + ServerStreams: true, + }, + }, + Metadata: "vanguard/test/v1/restricted.proto", +} diff --git a/internal/gen/vanguard/test/v1/testv1connect/restricted.connect.go b/internal/gen/vanguard/test/v1/testv1connect/restricted.connect.go new file mode 100644 index 0000000..bc4e610 --- /dev/null +++ b/internal/gen/vanguard/test/v1/testv1connect/restricted.connect.go @@ -0,0 +1,194 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: vanguard/test/v1/restricted.proto + +package testv1connect + +import ( + connect "connectrpc.com/connect" + v1 "connectrpc.com/vanguard/internal/gen/vanguard/test/v1" + context "context" + errors "errors" + emptypb "google.golang.org/protobuf/types/known/emptypb" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // RestrictedServiceName is the fully-qualified name of the RestrictedService service. + RestrictedServiceName = "vanguard.test.v1.RestrictedService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // RestrictedServiceBidiStreamProcedure is the fully-qualified name of the RestrictedService's + // BidiStream RPC. + RestrictedServiceBidiStreamProcedure = "/vanguard.test.v1.RestrictedService/BidiStream" + // RestrictedServiceClientStreamProcedure is the fully-qualified name of the RestrictedService's + // ClientStream RPC. + RestrictedServiceClientStreamProcedure = "/vanguard.test.v1.RestrictedService/ClientStream" + // RestrictedServiceServerStreamProcedure is the fully-qualified name of the RestrictedService's + // ServerStream RPC. + RestrictedServiceServerStreamProcedure = "/vanguard.test.v1.RestrictedService/ServerStream" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + restrictedServiceServiceDescriptor = v1.File_vanguard_test_v1_restricted_proto.Services().ByName("RestrictedService") + restrictedServiceBidiStreamMethodDescriptor = restrictedServiceServiceDescriptor.Methods().ByName("BidiStream") + restrictedServiceClientStreamMethodDescriptor = restrictedServiceServiceDescriptor.Methods().ByName("ClientStream") + restrictedServiceServerStreamMethodDescriptor = restrictedServiceServiceDescriptor.Methods().ByName("ServerStream") +) + +// RestrictedServiceClient is a client for the vanguard.test.v1.RestrictedService service. +type RestrictedServiceClient interface { + // BidiStream is a bidi stream, unsupported request and response type. + BidiStream(context.Context) *connect.BidiStreamForClient[emptypb.Empty, emptypb.Empty] + // ClientStream is a client stream, unsupported request type. + ClientStream(context.Context) *connect.ClientStreamForClient[emptypb.Empty, emptypb.Empty] + // ServerStream is a server stream, unsupported response type. + ServerStream(context.Context, *connect.Request[emptypb.Empty]) (*connect.ServerStreamForClient[emptypb.Empty], error) +} + +// NewRestrictedServiceClient constructs a client for the vanguard.test.v1.RestrictedService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewRestrictedServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) RestrictedServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &restrictedServiceClient{ + bidiStream: connect.NewClient[emptypb.Empty, emptypb.Empty]( + httpClient, + baseURL+RestrictedServiceBidiStreamProcedure, + connect.WithSchema(restrictedServiceBidiStreamMethodDescriptor), + connect.WithClientOptions(opts...), + ), + clientStream: connect.NewClient[emptypb.Empty, emptypb.Empty]( + httpClient, + baseURL+RestrictedServiceClientStreamProcedure, + connect.WithSchema(restrictedServiceClientStreamMethodDescriptor), + connect.WithClientOptions(opts...), + ), + serverStream: connect.NewClient[emptypb.Empty, emptypb.Empty]( + httpClient, + baseURL+RestrictedServiceServerStreamProcedure, + connect.WithSchema(restrictedServiceServerStreamMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// restrictedServiceClient implements RestrictedServiceClient. +type restrictedServiceClient struct { + bidiStream *connect.Client[emptypb.Empty, emptypb.Empty] + clientStream *connect.Client[emptypb.Empty, emptypb.Empty] + serverStream *connect.Client[emptypb.Empty, emptypb.Empty] +} + +// BidiStream calls vanguard.test.v1.RestrictedService.BidiStream. +func (c *restrictedServiceClient) BidiStream(ctx context.Context) *connect.BidiStreamForClient[emptypb.Empty, emptypb.Empty] { + return c.bidiStream.CallBidiStream(ctx) +} + +// ClientStream calls vanguard.test.v1.RestrictedService.ClientStream. +func (c *restrictedServiceClient) ClientStream(ctx context.Context) *connect.ClientStreamForClient[emptypb.Empty, emptypb.Empty] { + return c.clientStream.CallClientStream(ctx) +} + +// ServerStream calls vanguard.test.v1.RestrictedService.ServerStream. +func (c *restrictedServiceClient) ServerStream(ctx context.Context, req *connect.Request[emptypb.Empty]) (*connect.ServerStreamForClient[emptypb.Empty], error) { + return c.serverStream.CallServerStream(ctx, req) +} + +// RestrictedServiceHandler is an implementation of the vanguard.test.v1.RestrictedService service. +type RestrictedServiceHandler interface { + // BidiStream is a bidi stream, unsupported request and response type. + BidiStream(context.Context, *connect.BidiStream[emptypb.Empty, emptypb.Empty]) error + // ClientStream is a client stream, unsupported request type. + ClientStream(context.Context, *connect.ClientStream[emptypb.Empty]) (*connect.Response[emptypb.Empty], error) + // ServerStream is a server stream, unsupported response type. + ServerStream(context.Context, *connect.Request[emptypb.Empty], *connect.ServerStream[emptypb.Empty]) error +} + +// NewRestrictedServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewRestrictedServiceHandler(svc RestrictedServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + restrictedServiceBidiStreamHandler := connect.NewBidiStreamHandler( + RestrictedServiceBidiStreamProcedure, + svc.BidiStream, + connect.WithSchema(restrictedServiceBidiStreamMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + restrictedServiceClientStreamHandler := connect.NewClientStreamHandler( + RestrictedServiceClientStreamProcedure, + svc.ClientStream, + connect.WithSchema(restrictedServiceClientStreamMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + restrictedServiceServerStreamHandler := connect.NewServerStreamHandler( + RestrictedServiceServerStreamProcedure, + svc.ServerStream, + connect.WithSchema(restrictedServiceServerStreamMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/vanguard.test.v1.RestrictedService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case RestrictedServiceBidiStreamProcedure: + restrictedServiceBidiStreamHandler.ServeHTTP(w, r) + case RestrictedServiceClientStreamProcedure: + restrictedServiceClientStreamHandler.ServeHTTP(w, r) + case RestrictedServiceServerStreamProcedure: + restrictedServiceServerStreamHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedRestrictedServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedRestrictedServiceHandler struct{} + +func (UnimplementedRestrictedServiceHandler) BidiStream(context.Context, *connect.BidiStream[emptypb.Empty, emptypb.Empty]) error { + return connect.NewError(connect.CodeUnimplemented, errors.New("vanguard.test.v1.RestrictedService.BidiStream is not implemented")) +} + +func (UnimplementedRestrictedServiceHandler) ClientStream(context.Context, *connect.ClientStream[emptypb.Empty]) (*connect.Response[emptypb.Empty], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("vanguard.test.v1.RestrictedService.ClientStream is not implemented")) +} + +func (UnimplementedRestrictedServiceHandler) ServerStream(context.Context, *connect.Request[emptypb.Empty], *connect.ServerStream[emptypb.Empty]) error { + return connect.NewError(connect.CodeUnimplemented, errors.New("vanguard.test.v1.RestrictedService.ServerStream is not implemented")) +} diff --git a/internal/proto/vanguard/test/v1/restricted.proto b/internal/proto/vanguard/test/v1/restricted.proto new file mode 100644 index 0000000..2e6dafd --- /dev/null +++ b/internal/proto/vanguard/test/v1/restricted.proto @@ -0,0 +1,45 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package vanguard.test.v1; + +import "google/api/annotations.proto"; +import "google/protobuf/empty.proto"; + +// RestrictedService is a service that has methods with unsupported request and response types. +service RestrictedService { + // BidiStream is a bidi stream, unsupported request and response type. + rpc BidiStream(stream google.protobuf.Empty) returns (stream google.protobuf.Empty) { + option (google.api.http) = { + post: "/streams/bidi" + body: "*" + }; + } + // ClientStream is a client stream, unsupported request type. + rpc ClientStream(stream google.protobuf.Empty) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/streams/client" + body: "*" + }; + } + // ServerStream is a server stream, unsupported response type. + rpc ServerStream(google.protobuf.Empty) returns (stream google.protobuf.Empty) { + option (google.api.http) = { + post: "/streams/server" + body: "*" + }; + } +} From 07867f392a9f7c3c7c699454f6039bcc45f50521 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Thu, 18 Apr 2024 00:38:40 -0400 Subject: [PATCH 8/8] Add check for REST stream types --- protocol.go | 1 + protocol_connect.go | 8 ++++++ protocol_grpc.go | 8 ++++++ protocol_rest.go | 28 +++++++++++++-------- transcoder.go | 17 ++++++++----- vanguard_restxrpc_test.go | 31 ++++++++++++++++++++++++ vanguard_rpcxrest_test.go | 51 +++++++++++++++++++++++++++++++++++++-- 7 files changed, 126 insertions(+), 18 deletions(-) diff --git a/protocol.go b/protocol.go index ec82441..42aaddb 100644 --- a/protocol.go +++ b/protocol.go @@ -176,6 +176,7 @@ type clientProtocolAllowsGet interface { // and understand the responses it sends. type serverProtocolHandler interface { protocol() Protocol + acceptsStreamType(*operation, connect.StreamType) bool // Encodes the given requestMeta has headers into the given target // headers. If non-nil, allowedCompression should be used instead diff --git a/protocol_connect.go b/protocol_connect.go index e5e5268..b8b5be5 100644 --- a/protocol_connect.go +++ b/protocol_connect.go @@ -251,6 +251,10 @@ func (c connectUnaryServerProtocol) protocol() Protocol { return ProtocolConnect } +func (c connectUnaryServerProtocol) acceptsStreamType(_ *operation, streamType connect.StreamType) bool { + return streamType == connect.StreamTypeUnary +} + func (c connectUnaryServerProtocol) addProtocolRequestHeaders(meta requestMeta, headers http.Header) { headers.Set("Content-Type", contentConnectUnaryPrefix+meta.codec) if meta.compression != "" { @@ -498,6 +502,10 @@ func (c connectStreamServerProtocol) protocol() Protocol { return ProtocolConnect } +func (c connectStreamServerProtocol) acceptsStreamType(_ *operation, streamType connect.StreamType) bool { + return streamType != connect.StreamTypeUnary +} + func (c connectStreamServerProtocol) addProtocolRequestHeaders(meta requestMeta, headers http.Header) { headers.Set("Content-Type", contentConnectStreamPrefix+meta.codec) if meta.compression != "" { diff --git a/protocol_grpc.go b/protocol_grpc.go index 09cfa47..5b22c98 100644 --- a/protocol_grpc.go +++ b/protocol_grpc.go @@ -107,6 +107,10 @@ func (g grpcServerProtocol) protocol() Protocol { return ProtocolGRPC } +func (g grpcServerProtocol) acceptsStreamType(_ *operation, _ connect.StreamType) bool { + return true +} + func (g grpcServerProtocol) addProtocolRequestHeaders(meta requestMeta, headers http.Header) { grpcAddRequestMeta("application/grpc+", meta, headers) headers.Set("Te", "trailers") @@ -223,6 +227,10 @@ func (g grpcWebServerProtocol) protocol() Protocol { return ProtocolGRPCWeb } +func (g grpcWebServerProtocol) acceptsStreamType(_ *operation, _ connect.StreamType) bool { + return true +} + func (g grpcWebServerProtocol) addProtocolRequestHeaders(meta requestMeta, headers http.Header) { grpcAddRequestMeta("application/grpc-web+", meta, headers) } diff --git a/protocol_rest.go b/protocol_rest.go index 3d0b4f0..6f0a38c 100644 --- a/protocol_rest.go +++ b/protocol_rest.go @@ -45,16 +45,7 @@ func (r restClientProtocol) protocol() Protocol { } func (r restClientProtocol) acceptsStreamType(op *operation, streamType connect.StreamType) bool { - switch streamType { - case connect.StreamTypeUnary: - return true - case connect.StreamTypeClient: - return restHTTPBodyRequest(op) - case connect.StreamTypeServer: - return restHTTPBodyResponse(op) - default: - return false - } + return restAcceptsStreamType(op, streamType) } func (r restClientProtocol) endMustBeInHeaders() bool { @@ -266,6 +257,10 @@ func (r restServerProtocol) protocol() Protocol { return ProtocolREST } +func (r restServerProtocol) acceptsStreamType(op *operation, streamType connect.StreamType) bool { + return restAcceptsStreamType(op, streamType) +} + func (r restServerProtocol) addProtocolRequestHeaders(meta requestMeta, headers http.Header) { // TODO: don't set content-type on no body requests. headers["Content-Type"] = []string{contentRestPrefix + meta.codec} @@ -402,6 +397,19 @@ func (r restServerProtocol) String() string { return r.protocol().String() } +func restAcceptsStreamType(op *operation, streamType connect.StreamType) bool { + switch streamType { + case connect.StreamTypeUnary: + return true + case connect.StreamTypeClient: + return restHTTPBodyRequest(op) + case connect.StreamTypeServer: + return restHTTPBodyResponse(op) + default: + return false + } +} + // Decode timeout as a float in seconds from X-Server-Timeout header. func restDecodeTimeout(timeout string) (time.Duration, error) { if timeout == "" { diff --git a/transcoder.go b/transcoder.go index 6ff5800..ec11f97 100644 --- a/transcoder.go +++ b/transcoder.go @@ -402,12 +402,14 @@ func (o *operation) validate(transcoder *Transcoder) error { o.request.ContentLength = -1 // transforming it will likely change it // Identify the method being invoked. - err := o.resolveMethod(transcoder) - if err != nil { + if err := o.resolveMethod(transcoder); err != nil { return err } if !o.client.protocol.acceptsStreamType(o, o.methodConf.streamType) { - return newHTTPError(http.StatusUnsupportedMediaType, "stream type %s not supported with %s protocol", o.methodConf.streamType, o.client.protocol) + return newHTTPError(http.StatusUnsupportedMediaType, + "stream type %s not supported with %s protocol", + o.methodConf.streamType, o.client.protocol, + ) } if o.methodConf.streamType == connect.StreamTypeBidi && o.request.ProtoMajor < 2 { return newHTTPError(http.StatusHTTPVersionNotSupported, "bidi streams require HTTP/2") @@ -462,9 +464,12 @@ func (o *operation) validate(transcoder *Transcoder) error { } } } - if o.server.protocol.protocol() == ProtocolREST && o.restTarget == nil { - // This method cannot be implemented this way. So serve a 404 for this method's URI path. - return errNotFound + + if !o.server.protocol.acceptsStreamType(o, o.methodConf.streamType) { + return newHTTPError(http.StatusUnsupportedMediaType, + "stream type %s not supported with %s protocol", + o.methodConf.streamType, o.server.protocol, + ) } // Now that we've ruled out the use of bidi streaming above, it's safe to simulate HTTP/2 diff --git a/vanguard_restxrpc_test.go b/vanguard_restxrpc_test.go index 8d8c097..a2f0e0f 100644 --- a/vanguard_restxrpc_test.go +++ b/vanguard_restxrpc_test.go @@ -47,6 +47,7 @@ func TestMux_RESTxRPC(t *testing.T) { serviceNames := []string{ testv1connect.LibraryServiceName, testv1connect.ContentServiceName, + testv1connect.RestrictedServiceName, } codecs := []string{ CodecJSON, @@ -554,6 +555,36 @@ func TestMux_RESTxRPC(t *testing.T) { "Content-Type": []string{"text/plain"}, }, }, + }, { + name: "StreamClient-Restricted", + input: input{ + method: http.MethodPost, + path: "/streams/client", + }, + output: output{ + code: http.StatusUnsupportedMediaType, + rawBody: "stream type client not supported with REST protocol\n", + }, + }, { + name: "StreamServer-Restricted", + input: input{ + method: http.MethodPost, + path: "/streams/server", + }, + output: output{ + code: http.StatusUnsupportedMediaType, + rawBody: "stream type server not supported with REST protocol\n", + }, + }, { + name: "StreamBidi-Restricted", + input: input{ + method: http.MethodPost, + path: "/streams/bidi", + }, + output: output{ + code: http.StatusUnsupportedMediaType, + rawBody: "stream type bidi not supported with REST protocol\n", + }, }} type testOpt struct { diff --git a/vanguard_rpcxrest_test.go b/vanguard_rpcxrest_test.go index 2ac321d..b57bca7 100644 --- a/vanguard_rpcxrest_test.go +++ b/vanguard_rpcxrest_test.go @@ -43,6 +43,7 @@ func TestMux_RPCxREST(t *testing.T) { serviceNames := []string{ testv1connect.LibraryServiceName, testv1connect.ContentServiceName, + testv1connect.RestrictedServiceName, } codecs := []string{ CodecJSON, @@ -145,8 +146,9 @@ func TestMux_RPCxREST(t *testing.T) { ctx := context.Background() type testClients struct { - contentClient testv1connect.ContentServiceClient - libClient testv1connect.LibraryServiceClient + contentClient testv1connect.ContentServiceClient + libClient testv1connect.LibraryServiceClient + restrictedClient testv1connect.RestrictedServiceClient } type output struct { header http.Header @@ -439,6 +441,48 @@ func TestMux_RPCxREST(t *testing.T) { output: output{ messages: []proto.Message{&emptypb.Empty{}}, }, + }, { + name: "StreamClient-Restricted", + input: func(clients testClients, hdr http.Header) (http.Header, []proto.Message, http.Header, error) { + msgs := []proto.Message{ + &emptypb.Empty{}, + } + return outputFromBidiStream(ctx, clients.restrictedClient.BidiStream, hdr, msgs) + }, + stream: testStream{ + method: "/streams/client", + }, + output: output{ + wantErr: newConnectError(connect.CodeUnknown, "stream type bidi not supported with REST protocol"), + }, + }, { + name: "StreamServer-Restricted", + input: func(clients testClients, hdr http.Header) (http.Header, []proto.Message, http.Header, error) { + msgs := []proto.Message{ + &emptypb.Empty{}, + } + return outputFromBidiStream(ctx, clients.restrictedClient.BidiStream, hdr, msgs) + }, + stream: testStream{ + method: "/streams/server", + }, + output: output{ + wantErr: newConnectError(connect.CodeUnknown, "stream type bidi not supported with REST protocol"), + }, + }, { + name: "StreamBidi-Restricted", + input: func(clients testClients, hdr http.Header) (http.Header, []proto.Message, http.Header, error) { + msgs := []proto.Message{ + &emptypb.Empty{}, + } + return outputFromBidiStream(ctx, clients.restrictedClient.BidiStream, hdr, msgs) + }, + stream: testStream{ + method: "/streams/bidi", + }, + output: output{ + wantErr: newConnectError(connect.CodeUnknown, "stream type bidi not supported with REST protocol"), + }, }} for _, opts := range testOpts { @@ -450,6 +494,9 @@ func TestMux_RPCxREST(t *testing.T) { contentClient: testv1connect.NewContentServiceClient( opts.server.Client(), opts.server.URL, opts.opts..., ), + restrictedClient: testv1connect.NewRestrictedServiceClient( + opts.server.Client(), opts.server.URL, opts.opts..., + ), } t.Run(opts.name, func(t *testing.T) { t.Parallel()