diff --git a/component/button/v1/button.pb.go b/component/button/v1/button.pb.go new file mode 100644 index 000000000..7ac237eeb --- /dev/null +++ b/component/button/v1/button.pb.go @@ -0,0 +1,215 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.35.1 +// protoc (unknown) +// source: component/button/v1/button.proto + +package v1 + +import ( + v1 "go.viam.com/api/common/v1" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + 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 PushRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Extra *structpb.Struct `protobuf:"bytes,99,opt,name=extra,proto3" json:"extra,omitempty"` +} + +func (x *PushRequest) Reset() { + *x = PushRequest{} + mi := &file_component_button_v1_button_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PushRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PushRequest) ProtoMessage() {} + +func (x *PushRequest) ProtoReflect() protoreflect.Message { + mi := &file_component_button_v1_button_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PushRequest.ProtoReflect.Descriptor instead. +func (*PushRequest) Descriptor() ([]byte, []int) { + return file_component_button_v1_button_proto_rawDescGZIP(), []int{0} +} + +func (x *PushRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *PushRequest) GetExtra() *structpb.Struct { + if x != nil { + return x.Extra + } + return nil +} + +type PushResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PushResponse) Reset() { + *x = PushResponse{} + mi := &file_component_button_v1_button_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PushResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PushResponse) ProtoMessage() {} + +func (x *PushResponse) ProtoReflect() protoreflect.Message { + mi := &file_component_button_v1_button_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PushResponse.ProtoReflect.Descriptor instead. +func (*PushResponse) Descriptor() ([]byte, []int) { + return file_component_button_v1_button_proto_rawDescGZIP(), []int{1} +} + +var File_component_button_v1_button_proto protoreflect.FileDescriptor + +var file_component_button_v1_button_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x74, 0x74, + 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x18, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, + 0x6e, 0x74, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x16, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 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, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x50, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x63, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x05, 0x65, 0x78, 0x74, + 0x72, 0x61, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x32, 0xa6, 0x02, 0x0a, 0x0d, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x88, 0x01, 0x0a, 0x04, 0x50, 0x75, 0x73, 0x68, 0x12, 0x25, 0x2e, + 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x62, + 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, + 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x2b, 0x1a, 0x29, 0x2f, 0x76, 0x69, 0x61, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x74, + 0x74, 0x6f, 0x6e, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x2f, 0x70, 0x75, 0x73, 0x68, 0x12, + 0x89, 0x01, 0x0a, 0x09, 0x44, 0x6f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x20, 0x2e, + 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x6f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x21, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x6f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x22, 0x2f, 0x2f, 0x76, 0x69, 0x61, + 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, + 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, + 0x2f, 0x64, 0x6f, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x42, 0x43, 0x0a, 0x1c, 0x63, + 0x6f, 0x6d, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x2e, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x5a, 0x23, 0x67, 0x6f, 0x2e, + 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x2f, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_component_button_v1_button_proto_rawDescOnce sync.Once + file_component_button_v1_button_proto_rawDescData = file_component_button_v1_button_proto_rawDesc +) + +func file_component_button_v1_button_proto_rawDescGZIP() []byte { + file_component_button_v1_button_proto_rawDescOnce.Do(func() { + file_component_button_v1_button_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_button_v1_button_proto_rawDescData) + }) + return file_component_button_v1_button_proto_rawDescData +} + +var file_component_button_v1_button_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_component_button_v1_button_proto_goTypes = []any{ + (*PushRequest)(nil), // 0: viam.component.button.v1.PushRequest + (*PushResponse)(nil), // 1: viam.component.button.v1.PushResponse + (*structpb.Struct)(nil), // 2: google.protobuf.Struct + (*v1.DoCommandRequest)(nil), // 3: viam.common.v1.DoCommandRequest + (*v1.DoCommandResponse)(nil), // 4: viam.common.v1.DoCommandResponse +} +var file_component_button_v1_button_proto_depIdxs = []int32{ + 2, // 0: viam.component.button.v1.PushRequest.extra:type_name -> google.protobuf.Struct + 0, // 1: viam.component.button.v1.ButtonService.Push:input_type -> viam.component.button.v1.PushRequest + 3, // 2: viam.component.button.v1.ButtonService.DoCommand:input_type -> viam.common.v1.DoCommandRequest + 1, // 3: viam.component.button.v1.ButtonService.Push:output_type -> viam.component.button.v1.PushResponse + 4, // 4: viam.component.button.v1.ButtonService.DoCommand:output_type -> viam.common.v1.DoCommandResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_component_button_v1_button_proto_init() } +func file_component_button_v1_button_proto_init() { + if File_component_button_v1_button_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_component_button_v1_button_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_component_button_v1_button_proto_goTypes, + DependencyIndexes: file_component_button_v1_button_proto_depIdxs, + MessageInfos: file_component_button_v1_button_proto_msgTypes, + }.Build() + File_component_button_v1_button_proto = out.File + file_component_button_v1_button_proto_rawDesc = nil + file_component_button_v1_button_proto_goTypes = nil + file_component_button_v1_button_proto_depIdxs = nil +} diff --git a/component/button/v1/button.pb.gw.go b/component/button/v1/button.pb.gw.go new file mode 100644 index 000000000..88e5ec8a6 --- /dev/null +++ b/component/button/v1/button.pb.gw.go @@ -0,0 +1,329 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: component/button/v1/button.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "go.viam.com/api/common/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +var ( + filter_ButtonService_Push_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_ButtonService_Push_0(ctx context.Context, marshaler runtime.Marshaler, client ButtonServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq PushRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ButtonService_Push_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Push(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_ButtonService_Push_0(ctx context.Context, marshaler runtime.Marshaler, server ButtonServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq PushRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ButtonService_Push_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Push(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_ButtonService_DoCommand_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_ButtonService_DoCommand_0(ctx context.Context, marshaler runtime.Marshaler, client ButtonServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq v1.DoCommandRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ButtonService_DoCommand_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DoCommand(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_ButtonService_DoCommand_0(ctx context.Context, marshaler runtime.Marshaler, server ButtonServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq v1.DoCommandRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ButtonService_DoCommand_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DoCommand(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterButtonServiceHandlerServer registers the http handlers for service ButtonService to "mux". +// UnaryRPC :call ButtonServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterButtonServiceHandlerFromEndpoint instead. +func RegisterButtonServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ButtonServiceServer) error { + + mux.Handle("PUT", pattern_ButtonService_Push_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/viam.component.button.v1.ButtonService/Push", runtime.WithHTTPPathPattern("/viam/api/v1/component/button/{name}/push")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ButtonService_Push_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_ButtonService_Push_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ButtonService_DoCommand_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/viam.component.button.v1.ButtonService/DoCommand", runtime.WithHTTPPathPattern("/viam/api/v1/component/button/{name}/do_command")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ButtonService_DoCommand_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_ButtonService_DoCommand_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterButtonServiceHandlerFromEndpoint is same as RegisterButtonServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterButtonServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterButtonServiceHandler(ctx, mux, conn) +} + +// RegisterButtonServiceHandler registers the http handlers for service ButtonService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterButtonServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterButtonServiceHandlerClient(ctx, mux, NewButtonServiceClient(conn)) +} + +// RegisterButtonServiceHandlerClient registers the http handlers for service ButtonService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ButtonServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ButtonServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "ButtonServiceClient" to call the correct interceptors. +func RegisterButtonServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ButtonServiceClient) error { + + mux.Handle("PUT", pattern_ButtonService_Push_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/viam.component.button.v1.ButtonService/Push", runtime.WithHTTPPathPattern("/viam/api/v1/component/button/{name}/push")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ButtonService_Push_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_ButtonService_Push_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_ButtonService_DoCommand_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/viam.component.button.v1.ButtonService/DoCommand", runtime.WithHTTPPathPattern("/viam/api/v1/component/button/{name}/do_command")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ButtonService_DoCommand_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_ButtonService_DoCommand_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_ButtonService_Push_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"viam", "api", "v1", "component", "button", "name", "push"}, "")) + + pattern_ButtonService_DoCommand_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"viam", "api", "v1", "component", "button", "name", "do_command"}, "")) +) + +var ( + forward_ButtonService_Push_0 = runtime.ForwardResponseMessage + + forward_ButtonService_DoCommand_0 = runtime.ForwardResponseMessage +) diff --git a/component/button/v1/button_grpc.pb.go b/component/button/v1/button_grpc.pb.go new file mode 100644 index 000000000..a89dde3b5 --- /dev/null +++ b/component/button/v1/button_grpc.pb.go @@ -0,0 +1,146 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: component/button/v1/button.proto + +package v1 + +import ( + context "context" + v1 "go.viam.com/api/common/v1" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// 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 + +// ButtonServiceClient is the client API for ButtonService 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 ButtonServiceClient interface { + // Pushes a button + Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) + // DoCommand sends/receives arbitrary commands + DoCommand(ctx context.Context, in *v1.DoCommandRequest, opts ...grpc.CallOption) (*v1.DoCommandResponse, error) +} + +type buttonServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewButtonServiceClient(cc grpc.ClientConnInterface) ButtonServiceClient { + return &buttonServiceClient{cc} +} + +func (c *buttonServiceClient) Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*PushResponse, error) { + out := new(PushResponse) + err := c.cc.Invoke(ctx, "/viam.component.button.v1.ButtonService/Push", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *buttonServiceClient) DoCommand(ctx context.Context, in *v1.DoCommandRequest, opts ...grpc.CallOption) (*v1.DoCommandResponse, error) { + out := new(v1.DoCommandResponse) + err := c.cc.Invoke(ctx, "/viam.component.button.v1.ButtonService/DoCommand", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ButtonServiceServer is the server API for ButtonService service. +// All implementations must embed UnimplementedButtonServiceServer +// for forward compatibility +type ButtonServiceServer interface { + // Pushes a button + Push(context.Context, *PushRequest) (*PushResponse, error) + // DoCommand sends/receives arbitrary commands + DoCommand(context.Context, *v1.DoCommandRequest) (*v1.DoCommandResponse, error) + mustEmbedUnimplementedButtonServiceServer() +} + +// UnimplementedButtonServiceServer must be embedded to have forward compatible implementations. +type UnimplementedButtonServiceServer struct { +} + +func (UnimplementedButtonServiceServer) Push(context.Context, *PushRequest) (*PushResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Push not implemented") +} +func (UnimplementedButtonServiceServer) DoCommand(context.Context, *v1.DoCommandRequest) (*v1.DoCommandResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DoCommand not implemented") +} +func (UnimplementedButtonServiceServer) mustEmbedUnimplementedButtonServiceServer() {} + +// UnsafeButtonServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ButtonServiceServer will +// result in compilation errors. +type UnsafeButtonServiceServer interface { + mustEmbedUnimplementedButtonServiceServer() +} + +func RegisterButtonServiceServer(s grpc.ServiceRegistrar, srv ButtonServiceServer) { + s.RegisterService(&ButtonService_ServiceDesc, srv) +} + +func _ButtonService_Push_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PushRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ButtonServiceServer).Push(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/viam.component.button.v1.ButtonService/Push", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ButtonServiceServer).Push(ctx, req.(*PushRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ButtonService_DoCommand_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(v1.DoCommandRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ButtonServiceServer).DoCommand(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/viam.component.button.v1.ButtonService/DoCommand", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ButtonServiceServer).DoCommand(ctx, req.(*v1.DoCommandRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ButtonService_ServiceDesc is the grpc.ServiceDesc for ButtonService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ButtonService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "viam.component.button.v1.ButtonService", + HandlerType: (*ButtonServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Push", + Handler: _ButtonService_Push_Handler, + }, + { + MethodName: "DoCommand", + Handler: _ButtonService_DoCommand_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "component/button/v1/button.proto", +} diff --git a/component/switch/v1/switch.pb.go b/component/switch/v1/switch.pb.go new file mode 100644 index 000000000..08006214f --- /dev/null +++ b/component/switch/v1/switch.pb.go @@ -0,0 +1,477 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.35.1 +// protoc (unknown) +// source: component/switch/v1/switch.proto + +package v1 + +import ( + v1 "go.viam.com/api/common/v1" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + 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 SetPositionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Position uint32 `protobuf:"varint,2,opt,name=position,proto3" json:"position,omitempty"` + Extra *structpb.Struct `protobuf:"bytes,99,opt,name=extra,proto3" json:"extra,omitempty"` +} + +func (x *SetPositionRequest) Reset() { + *x = SetPositionRequest{} + mi := &file_component_switch_v1_switch_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetPositionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetPositionRequest) ProtoMessage() {} + +func (x *SetPositionRequest) ProtoReflect() protoreflect.Message { + mi := &file_component_switch_v1_switch_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetPositionRequest.ProtoReflect.Descriptor instead. +func (*SetPositionRequest) Descriptor() ([]byte, []int) { + return file_component_switch_v1_switch_proto_rawDescGZIP(), []int{0} +} + +func (x *SetPositionRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SetPositionRequest) GetPosition() uint32 { + if x != nil { + return x.Position + } + return 0 +} + +func (x *SetPositionRequest) GetExtra() *structpb.Struct { + if x != nil { + return x.Extra + } + return nil +} + +type SetPositionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SetPositionResponse) Reset() { + *x = SetPositionResponse{} + mi := &file_component_switch_v1_switch_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetPositionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetPositionResponse) ProtoMessage() {} + +func (x *SetPositionResponse) ProtoReflect() protoreflect.Message { + mi := &file_component_switch_v1_switch_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetPositionResponse.ProtoReflect.Descriptor instead. +func (*SetPositionResponse) Descriptor() ([]byte, []int) { + return file_component_switch_v1_switch_proto_rawDescGZIP(), []int{1} +} + +type GetPositionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Extra *structpb.Struct `protobuf:"bytes,99,opt,name=extra,proto3" json:"extra,omitempty"` +} + +func (x *GetPositionRequest) Reset() { + *x = GetPositionRequest{} + mi := &file_component_switch_v1_switch_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPositionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPositionRequest) ProtoMessage() {} + +func (x *GetPositionRequest) ProtoReflect() protoreflect.Message { + mi := &file_component_switch_v1_switch_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPositionRequest.ProtoReflect.Descriptor instead. +func (*GetPositionRequest) Descriptor() ([]byte, []int) { + return file_component_switch_v1_switch_proto_rawDescGZIP(), []int{2} +} + +func (x *GetPositionRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GetPositionRequest) GetExtra() *structpb.Struct { + if x != nil { + return x.Extra + } + return nil +} + +type GetPositionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Position uint32 `protobuf:"varint,1,opt,name=position,proto3" json:"position,omitempty"` +} + +func (x *GetPositionResponse) Reset() { + *x = GetPositionResponse{} + mi := &file_component_switch_v1_switch_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPositionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPositionResponse) ProtoMessage() {} + +func (x *GetPositionResponse) ProtoReflect() protoreflect.Message { + mi := &file_component_switch_v1_switch_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPositionResponse.ProtoReflect.Descriptor instead. +func (*GetPositionResponse) Descriptor() ([]byte, []int) { + return file_component_switch_v1_switch_proto_rawDescGZIP(), []int{3} +} + +func (x *GetPositionResponse) GetPosition() uint32 { + if x != nil { + return x.Position + } + return 0 +} + +type GetNumberOfPositionsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Extra *structpb.Struct `protobuf:"bytes,99,opt,name=extra,proto3" json:"extra,omitempty"` +} + +func (x *GetNumberOfPositionsRequest) Reset() { + *x = GetNumberOfPositionsRequest{} + mi := &file_component_switch_v1_switch_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetNumberOfPositionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNumberOfPositionsRequest) ProtoMessage() {} + +func (x *GetNumberOfPositionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_component_switch_v1_switch_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNumberOfPositionsRequest.ProtoReflect.Descriptor instead. +func (*GetNumberOfPositionsRequest) Descriptor() ([]byte, []int) { + return file_component_switch_v1_switch_proto_rawDescGZIP(), []int{4} +} + +func (x *GetNumberOfPositionsRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GetNumberOfPositionsRequest) GetExtra() *structpb.Struct { + if x != nil { + return x.Extra + } + return nil +} + +type GetNumberOfPositionsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NumberOfPositions uint32 `protobuf:"varint,1,opt,name=number_of_positions,json=numberOfPositions,proto3" json:"number_of_positions,omitempty"` +} + +func (x *GetNumberOfPositionsResponse) Reset() { + *x = GetNumberOfPositionsResponse{} + mi := &file_component_switch_v1_switch_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetNumberOfPositionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNumberOfPositionsResponse) ProtoMessage() {} + +func (x *GetNumberOfPositionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_component_switch_v1_switch_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNumberOfPositionsResponse.ProtoReflect.Descriptor instead. +func (*GetNumberOfPositionsResponse) Descriptor() ([]byte, []int) { + return file_component_switch_v1_switch_proto_rawDescGZIP(), []int{5} +} + +func (x *GetNumberOfPositionsResponse) GetNumberOfPositions() uint32 { + if x != nil { + return x.NumberOfPositions + } + return 0 +} + +var File_component_switch_v1_switch_proto protoreflect.FileDescriptor + +var file_component_switch_v1_switch_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x77, 0x69, 0x74, + 0x63, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x18, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, + 0x6e, 0x74, 0x2e, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x1a, 0x16, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 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, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x73, 0x0a, 0x12, 0x53, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, + 0x63, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x05, + 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x57, 0x0a, 0x12, + 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, + 0x63, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x05, + 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x60, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x65, + 0x78, 0x74, 0x72, 0x61, 0x18, 0x63, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x75, 0x63, 0x74, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x4e, 0x0a, 0x1c, 0x47, 0x65, + 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, + 0x66, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x32, 0xb9, 0x05, 0x0a, 0x0d, 0x53, + 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa5, 0x01, 0x0a, + 0x0b, 0x53, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x2e, 0x76, + 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, + 0x69, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x76, 0x69, 0x61, + 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, 0x69, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x39, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x33, 0x1a, 0x31, 0x2f, 0x76, 0x69, 0x61, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, + 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, + 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x2f, 0x73, 0x65, 0x74, 0x5f, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0xa5, 0x01, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, + 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, + 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x39, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x33, 0x1a, 0x31, 0x2f, 0x76, 0x69, 0x61, 0x6d, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x2f, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x2f, + 0x67, 0x65, 0x74, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0xcb, 0x01, 0x0a, + 0x14, 0x47, 0x65, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x35, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x76, + 0x69, 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, + 0x69, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x44, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3e, 0x1a, 0x3c, 0x2f, 0x76, + 0x69, 0x61, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, + 0x65, 0x7d, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, + 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x89, 0x01, 0x0a, 0x09, 0x44, + 0x6f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x20, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x69, 0x61, + 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x22, 0x2f, 0x2f, 0x76, 0x69, 0x61, 0x6d, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x77, + 0x69, 0x74, 0x63, 0x68, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x2f, 0x64, 0x6f, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x42, 0x43, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x69, + 0x61, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x73, 0x77, 0x69, + 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x5a, 0x23, 0x67, 0x6f, 0x2e, 0x76, 0x69, 0x61, 0x6d, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x2f, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_component_switch_v1_switch_proto_rawDescOnce sync.Once + file_component_switch_v1_switch_proto_rawDescData = file_component_switch_v1_switch_proto_rawDesc +) + +func file_component_switch_v1_switch_proto_rawDescGZIP() []byte { + file_component_switch_v1_switch_proto_rawDescOnce.Do(func() { + file_component_switch_v1_switch_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_switch_v1_switch_proto_rawDescData) + }) + return file_component_switch_v1_switch_proto_rawDescData +} + +var file_component_switch_v1_switch_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_component_switch_v1_switch_proto_goTypes = []any{ + (*SetPositionRequest)(nil), // 0: viam.component.switch.v1.SetPositionRequest + (*SetPositionResponse)(nil), // 1: viam.component.switch.v1.SetPositionResponse + (*GetPositionRequest)(nil), // 2: viam.component.switch.v1.GetPositionRequest + (*GetPositionResponse)(nil), // 3: viam.component.switch.v1.GetPositionResponse + (*GetNumberOfPositionsRequest)(nil), // 4: viam.component.switch.v1.GetNumberOfPositionsRequest + (*GetNumberOfPositionsResponse)(nil), // 5: viam.component.switch.v1.GetNumberOfPositionsResponse + (*structpb.Struct)(nil), // 6: google.protobuf.Struct + (*v1.DoCommandRequest)(nil), // 7: viam.common.v1.DoCommandRequest + (*v1.DoCommandResponse)(nil), // 8: viam.common.v1.DoCommandResponse +} +var file_component_switch_v1_switch_proto_depIdxs = []int32{ + 6, // 0: viam.component.switch.v1.SetPositionRequest.extra:type_name -> google.protobuf.Struct + 6, // 1: viam.component.switch.v1.GetPositionRequest.extra:type_name -> google.protobuf.Struct + 6, // 2: viam.component.switch.v1.GetNumberOfPositionsRequest.extra:type_name -> google.protobuf.Struct + 0, // 3: viam.component.switch.v1.SwitchService.SetPosition:input_type -> viam.component.switch.v1.SetPositionRequest + 2, // 4: viam.component.switch.v1.SwitchService.GetPosition:input_type -> viam.component.switch.v1.GetPositionRequest + 4, // 5: viam.component.switch.v1.SwitchService.GetNumberOfPositions:input_type -> viam.component.switch.v1.GetNumberOfPositionsRequest + 7, // 6: viam.component.switch.v1.SwitchService.DoCommand:input_type -> viam.common.v1.DoCommandRequest + 1, // 7: viam.component.switch.v1.SwitchService.SetPosition:output_type -> viam.component.switch.v1.SetPositionResponse + 3, // 8: viam.component.switch.v1.SwitchService.GetPosition:output_type -> viam.component.switch.v1.GetPositionResponse + 5, // 9: viam.component.switch.v1.SwitchService.GetNumberOfPositions:output_type -> viam.component.switch.v1.GetNumberOfPositionsResponse + 8, // 10: viam.component.switch.v1.SwitchService.DoCommand:output_type -> viam.common.v1.DoCommandResponse + 7, // [7:11] is the sub-list for method output_type + 3, // [3:7] 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_component_switch_v1_switch_proto_init() } +func file_component_switch_v1_switch_proto_init() { + if File_component_switch_v1_switch_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_component_switch_v1_switch_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_component_switch_v1_switch_proto_goTypes, + DependencyIndexes: file_component_switch_v1_switch_proto_depIdxs, + MessageInfos: file_component_switch_v1_switch_proto_msgTypes, + }.Build() + File_component_switch_v1_switch_proto = out.File + file_component_switch_v1_switch_proto_rawDesc = nil + file_component_switch_v1_switch_proto_goTypes = nil + file_component_switch_v1_switch_proto_depIdxs = nil +} diff --git a/component/switch/v1/switch.pb.gw.go b/component/switch/v1/switch.pb.gw.go new file mode 100644 index 000000000..66ef0dba5 --- /dev/null +++ b/component/switch/v1/switch.pb.gw.go @@ -0,0 +1,571 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: component/switch/v1/switch.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "go.viam.com/api/common/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +var ( + filter_SwitchService_SetPosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SwitchService_SetPosition_0(ctx context.Context, marshaler runtime.Marshaler, client SwitchServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SetPositionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_SetPosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SetPosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SwitchService_SetPosition_0(ctx context.Context, marshaler runtime.Marshaler, server SwitchServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SetPositionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_SetPosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SetPosition(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SwitchService_GetPosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SwitchService_GetPosition_0(ctx context.Context, marshaler runtime.Marshaler, client SwitchServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetPositionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_GetPosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetPosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SwitchService_GetPosition_0(ctx context.Context, marshaler runtime.Marshaler, server SwitchServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetPositionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_GetPosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetPosition(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SwitchService_GetNumberOfPositions_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SwitchService_GetNumberOfPositions_0(ctx context.Context, marshaler runtime.Marshaler, client SwitchServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetNumberOfPositionsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_GetNumberOfPositions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetNumberOfPositions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SwitchService_GetNumberOfPositions_0(ctx context.Context, marshaler runtime.Marshaler, server SwitchServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetNumberOfPositionsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_GetNumberOfPositions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetNumberOfPositions(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SwitchService_DoCommand_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SwitchService_DoCommand_0(ctx context.Context, marshaler runtime.Marshaler, client SwitchServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq v1.DoCommandRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_DoCommand_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DoCommand(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SwitchService_DoCommand_0(ctx context.Context, marshaler runtime.Marshaler, server SwitchServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq v1.DoCommandRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwitchService_DoCommand_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DoCommand(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterSwitchServiceHandlerServer registers the http handlers for service SwitchService to "mux". +// UnaryRPC :call SwitchServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSwitchServiceHandlerFromEndpoint instead. +func RegisterSwitchServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SwitchServiceServer) error { + + mux.Handle("PUT", pattern_SwitchService_SetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/SetPosition", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/set_position")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwitchService_SetPosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_SetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_SwitchService_GetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/GetPosition", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/get_position")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwitchService_GetPosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_GetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_SwitchService_GetNumberOfPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/GetNumberOfPositions", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/get_number_of_positions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwitchService_GetNumberOfPositions_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_GetNumberOfPositions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SwitchService_DoCommand_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/DoCommand", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/do_command")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwitchService_DoCommand_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_DoCommand_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterSwitchServiceHandlerFromEndpoint is same as RegisterSwitchServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterSwitchServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterSwitchServiceHandler(ctx, mux, conn) +} + +// RegisterSwitchServiceHandler registers the http handlers for service SwitchService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterSwitchServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterSwitchServiceHandlerClient(ctx, mux, NewSwitchServiceClient(conn)) +} + +// RegisterSwitchServiceHandlerClient registers the http handlers for service SwitchService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SwitchServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SwitchServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "SwitchServiceClient" to call the correct interceptors. +func RegisterSwitchServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SwitchServiceClient) error { + + mux.Handle("PUT", pattern_SwitchService_SetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/SetPosition", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/set_position")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SwitchService_SetPosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_SetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_SwitchService_GetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/GetPosition", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/get_position")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SwitchService_GetPosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_GetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_SwitchService_GetNumberOfPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/GetNumberOfPositions", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/get_number_of_positions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SwitchService_GetNumberOfPositions_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_GetNumberOfPositions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SwitchService_DoCommand_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/viam.component.switch.v1.SwitchService/DoCommand", runtime.WithHTTPPathPattern("/viam/api/v1/component/switch/{name}/do_command")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SwitchService_DoCommand_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwitchService_DoCommand_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_SwitchService_SetPosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"viam", "api", "v1", "component", "switch", "name", "set_position"}, "")) + + pattern_SwitchService_GetPosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"viam", "api", "v1", "component", "switch", "name", "get_position"}, "")) + + pattern_SwitchService_GetNumberOfPositions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"viam", "api", "v1", "component", "switch", "name", "get_number_of_positions"}, "")) + + pattern_SwitchService_DoCommand_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"viam", "api", "v1", "component", "switch", "name", "do_command"}, "")) +) + +var ( + forward_SwitchService_SetPosition_0 = runtime.ForwardResponseMessage + + forward_SwitchService_GetPosition_0 = runtime.ForwardResponseMessage + + forward_SwitchService_GetNumberOfPositions_0 = runtime.ForwardResponseMessage + + forward_SwitchService_DoCommand_0 = runtime.ForwardResponseMessage +) diff --git a/component/switch/v1/switch_grpc.pb.go b/component/switch/v1/switch_grpc.pb.go new file mode 100644 index 000000000..b2a54862d --- /dev/null +++ b/component/switch/v1/switch_grpc.pb.go @@ -0,0 +1,222 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: component/switch/v1/switch.proto + +package v1 + +import ( + context "context" + v1 "go.viam.com/api/common/v1" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// 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 + +// SwitchServiceClient is the client API for SwitchService 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 SwitchServiceClient interface { + // Set the position of the switch + SetPosition(ctx context.Context, in *SetPositionRequest, opts ...grpc.CallOption) (*SetPositionResponse, error) + // Get the position of the switch + GetPosition(ctx context.Context, in *GetPositionRequest, opts ...grpc.CallOption) (*GetPositionResponse, error) + // Get the number of positions that the switch supports + GetNumberOfPositions(ctx context.Context, in *GetNumberOfPositionsRequest, opts ...grpc.CallOption) (*GetNumberOfPositionsResponse, error) + // DoCommand sends/receives arbitrary commands + DoCommand(ctx context.Context, in *v1.DoCommandRequest, opts ...grpc.CallOption) (*v1.DoCommandResponse, error) +} + +type switchServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSwitchServiceClient(cc grpc.ClientConnInterface) SwitchServiceClient { + return &switchServiceClient{cc} +} + +func (c *switchServiceClient) SetPosition(ctx context.Context, in *SetPositionRequest, opts ...grpc.CallOption) (*SetPositionResponse, error) { + out := new(SetPositionResponse) + err := c.cc.Invoke(ctx, "/viam.component.switch.v1.SwitchService/SetPosition", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *switchServiceClient) GetPosition(ctx context.Context, in *GetPositionRequest, opts ...grpc.CallOption) (*GetPositionResponse, error) { + out := new(GetPositionResponse) + err := c.cc.Invoke(ctx, "/viam.component.switch.v1.SwitchService/GetPosition", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *switchServiceClient) GetNumberOfPositions(ctx context.Context, in *GetNumberOfPositionsRequest, opts ...grpc.CallOption) (*GetNumberOfPositionsResponse, error) { + out := new(GetNumberOfPositionsResponse) + err := c.cc.Invoke(ctx, "/viam.component.switch.v1.SwitchService/GetNumberOfPositions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *switchServiceClient) DoCommand(ctx context.Context, in *v1.DoCommandRequest, opts ...grpc.CallOption) (*v1.DoCommandResponse, error) { + out := new(v1.DoCommandResponse) + err := c.cc.Invoke(ctx, "/viam.component.switch.v1.SwitchService/DoCommand", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SwitchServiceServer is the server API for SwitchService service. +// All implementations must embed UnimplementedSwitchServiceServer +// for forward compatibility +type SwitchServiceServer interface { + // Set the position of the switch + SetPosition(context.Context, *SetPositionRequest) (*SetPositionResponse, error) + // Get the position of the switch + GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) + // Get the number of positions that the switch supports + GetNumberOfPositions(context.Context, *GetNumberOfPositionsRequest) (*GetNumberOfPositionsResponse, error) + // DoCommand sends/receives arbitrary commands + DoCommand(context.Context, *v1.DoCommandRequest) (*v1.DoCommandResponse, error) + mustEmbedUnimplementedSwitchServiceServer() +} + +// UnimplementedSwitchServiceServer must be embedded to have forward compatible implementations. +type UnimplementedSwitchServiceServer struct { +} + +func (UnimplementedSwitchServiceServer) SetPosition(context.Context, *SetPositionRequest) (*SetPositionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetPosition not implemented") +} +func (UnimplementedSwitchServiceServer) GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPosition not implemented") +} +func (UnimplementedSwitchServiceServer) GetNumberOfPositions(context.Context, *GetNumberOfPositionsRequest) (*GetNumberOfPositionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetNumberOfPositions not implemented") +} +func (UnimplementedSwitchServiceServer) DoCommand(context.Context, *v1.DoCommandRequest) (*v1.DoCommandResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DoCommand not implemented") +} +func (UnimplementedSwitchServiceServer) mustEmbedUnimplementedSwitchServiceServer() {} + +// UnsafeSwitchServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SwitchServiceServer will +// result in compilation errors. +type UnsafeSwitchServiceServer interface { + mustEmbedUnimplementedSwitchServiceServer() +} + +func RegisterSwitchServiceServer(s grpc.ServiceRegistrar, srv SwitchServiceServer) { + s.RegisterService(&SwitchService_ServiceDesc, srv) +} + +func _SwitchService_SetPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetPositionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwitchServiceServer).SetPosition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/viam.component.switch.v1.SwitchService/SetPosition", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwitchServiceServer).SetPosition(ctx, req.(*SetPositionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SwitchService_GetPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPositionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwitchServiceServer).GetPosition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/viam.component.switch.v1.SwitchService/GetPosition", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwitchServiceServer).GetPosition(ctx, req.(*GetPositionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SwitchService_GetNumberOfPositions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetNumberOfPositionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwitchServiceServer).GetNumberOfPositions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/viam.component.switch.v1.SwitchService/GetNumberOfPositions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwitchServiceServer).GetNumberOfPositions(ctx, req.(*GetNumberOfPositionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SwitchService_DoCommand_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(v1.DoCommandRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwitchServiceServer).DoCommand(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/viam.component.switch.v1.SwitchService/DoCommand", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwitchServiceServer).DoCommand(ctx, req.(*v1.DoCommandRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SwitchService_ServiceDesc is the grpc.ServiceDesc for SwitchService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SwitchService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "viam.component.switch.v1.SwitchService", + HandlerType: (*SwitchServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SetPosition", + Handler: _SwitchService_SetPosition_Handler, + }, + { + MethodName: "GetPosition", + Handler: _SwitchService_GetPosition_Handler, + }, + { + MethodName: "GetNumberOfPositions", + Handler: _SwitchService_GetNumberOfPositions_Handler, + }, + { + MethodName: "DoCommand", + Handler: _SwitchService_DoCommand_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "component/switch/v1/switch.proto", +} diff --git a/gen/js/component/button/v1/button_grpc_web_pb.js b/gen/js/component/button/v1/button_grpc_web_pb.js new file mode 100644 index 000000000..558f0cc6e --- /dev/null +++ b/gen/js/component/button/v1/button_grpc_web_pb.js @@ -0,0 +1,209 @@ +/** + * @fileoverview gRPC-Web generated client stub for viam.component.button.v1 + * @enhanceable + * @public + */ + +// Code generated by protoc-gen-grpc-web. DO NOT EDIT. +// versions: +// protoc-gen-grpc-web v1.5.0 +// protoc v0.0.0 +// source: component/button/v1/button.proto + + +/* eslint-disable */ +// @ts-nocheck + + + +const grpc = {}; +grpc.web = require('grpc-web'); + + +var common_v1_common_pb = require('../../../common/v1/common_pb.js') + +var google_api_annotations_pb = require('../../../google/api/annotations_pb.js') + +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js') +const proto = {}; +proto.viam = {}; +proto.viam.component = {}; +proto.viam.component.button = {}; +proto.viam.component.button.v1 = require('./button_pb.js'); + +/** + * @param {string} hostname + * @param {?Object} credentials + * @param {?grpc.web.ClientOptions} options + * @constructor + * @struct + * @final + */ +proto.viam.component.button.v1.ButtonServiceClient = + function(hostname, credentials, options) { + if (!options) options = {}; + options.format = 'text'; + + /** + * @private @const {!grpc.web.GrpcWebClientBase} The client + */ + this.client_ = new grpc.web.GrpcWebClientBase(options); + + /** + * @private @const {string} The hostname + */ + this.hostname_ = hostname.replace(/\/+$/, ''); + +}; + + +/** + * @param {string} hostname + * @param {?Object} credentials + * @param {?grpc.web.ClientOptions} options + * @constructor + * @struct + * @final + */ +proto.viam.component.button.v1.ButtonServicePromiseClient = + function(hostname, credentials, options) { + if (!options) options = {}; + options.format = 'text'; + + /** + * @private @const {!grpc.web.GrpcWebClientBase} The client + */ + this.client_ = new grpc.web.GrpcWebClientBase(options); + + /** + * @private @const {string} The hostname + */ + this.hostname_ = hostname.replace(/\/+$/, ''); + +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.viam.component.button.v1.PushRequest, + * !proto.viam.component.button.v1.PushResponse>} + */ +const methodDescriptor_ButtonService_Push = new grpc.web.MethodDescriptor( + '/viam.component.button.v1.ButtonService/Push', + grpc.web.MethodType.UNARY, + proto.viam.component.button.v1.PushRequest, + proto.viam.component.button.v1.PushResponse, + /** + * @param {!proto.viam.component.button.v1.PushRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.viam.component.button.v1.PushResponse.deserializeBinary +); + + +/** + * @param {!proto.viam.component.button.v1.PushRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.viam.component.button.v1.PushResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.viam.component.button.v1.ButtonServiceClient.prototype.push = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/viam.component.button.v1.ButtonService/Push', + request, + metadata || {}, + methodDescriptor_ButtonService_Push, + callback); +}; + + +/** + * @param {!proto.viam.component.button.v1.PushRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.viam.component.button.v1.ButtonServicePromiseClient.prototype.push = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/viam.component.button.v1.ButtonService/Push', + request, + metadata || {}, + methodDescriptor_ButtonService_Push); +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.viam.common.v1.DoCommandRequest, + * !proto.viam.common.v1.DoCommandResponse>} + */ +const methodDescriptor_ButtonService_DoCommand = new grpc.web.MethodDescriptor( + '/viam.component.button.v1.ButtonService/DoCommand', + grpc.web.MethodType.UNARY, + common_v1_common_pb.DoCommandRequest, + common_v1_common_pb.DoCommandResponse, + /** + * @param {!proto.viam.common.v1.DoCommandRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + common_v1_common_pb.DoCommandResponse.deserializeBinary +); + + +/** + * @param {!proto.viam.common.v1.DoCommandRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.viam.common.v1.DoCommandResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.viam.component.button.v1.ButtonServiceClient.prototype.doCommand = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/viam.component.button.v1.ButtonService/DoCommand', + request, + metadata || {}, + methodDescriptor_ButtonService_DoCommand, + callback); +}; + + +/** + * @param {!proto.viam.common.v1.DoCommandRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.viam.component.button.v1.ButtonServicePromiseClient.prototype.doCommand = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/viam.component.button.v1.ButtonService/DoCommand', + request, + metadata || {}, + methodDescriptor_ButtonService_DoCommand); +}; + + +module.exports = proto.viam.component.button.v1; + diff --git a/gen/js/component/button/v1/button_pb.d.ts b/gen/js/component/button/v1/button_pb.d.ts new file mode 100644 index 000000000..fe364b0cf --- /dev/null +++ b/gen/js/component/button/v1/button_pb.d.ts @@ -0,0 +1,50 @@ +// package: viam.component.button.v1 +// file: component/button/v1/button.proto + +import * as jspb from "google-protobuf"; +import * as common_v1_common_pb from "../../../common/v1/common_pb"; +import * as google_api_annotations_pb from "../../../google/api/annotations_pb"; +import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb"; + +export class PushRequest extends jspb.Message { + getName(): string; + setName(value: string): void; + + hasExtra(): boolean; + clearExtra(): void; + getExtra(): google_protobuf_struct_pb.Struct | undefined; + setExtra(value?: google_protobuf_struct_pb.Struct): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): PushRequest.AsObject; + static toObject(includeInstance: boolean, msg: PushRequest): PushRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: PushRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): PushRequest; + static deserializeBinaryFromReader(message: PushRequest, reader: jspb.BinaryReader): PushRequest; +} + +export namespace PushRequest { + export type AsObject = { + name: string, + extra?: google_protobuf_struct_pb.Struct.AsObject, + } +} + +export class PushResponse extends jspb.Message { + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): PushResponse.AsObject; + static toObject(includeInstance: boolean, msg: PushResponse): PushResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: PushResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): PushResponse; + static deserializeBinaryFromReader(message: PushResponse, reader: jspb.BinaryReader): PushResponse; +} + +export namespace PushResponse { + export type AsObject = { + } +} + diff --git a/gen/js/component/button/v1/button_pb.js b/gen/js/component/button/v1/button_pb.js new file mode 100644 index 000000000..01b9a5975 --- /dev/null +++ b/gen/js/component/button/v1/button_pb.js @@ -0,0 +1,350 @@ +// source: component/button/v1/button.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); + +var common_v1_common_pb = require('../../../common/v1/common_pb.js'); +goog.object.extend(proto, common_v1_common_pb); +var google_api_annotations_pb = require('../../../google/api/annotations_pb.js'); +goog.object.extend(proto, google_api_annotations_pb); +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js'); +goog.object.extend(proto, google_protobuf_struct_pb); +goog.exportSymbol('proto.viam.component.button.v1.PushRequest', null, global); +goog.exportSymbol('proto.viam.component.button.v1.PushResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.button.v1.PushRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.button.v1.PushRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.button.v1.PushRequest.displayName = 'proto.viam.component.button.v1.PushRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.button.v1.PushResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.button.v1.PushResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.button.v1.PushResponse.displayName = 'proto.viam.component.button.v1.PushResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.button.v1.PushRequest.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.button.v1.PushRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.button.v1.PushRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.button.v1.PushRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + extra: (f = msg.getExtra()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.button.v1.PushRequest} + */ +proto.viam.component.button.v1.PushRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.button.v1.PushRequest; + return proto.viam.component.button.v1.PushRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.button.v1.PushRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.button.v1.PushRequest} + */ +proto.viam.component.button.v1.PushRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 99: + var value = new google_protobuf_struct_pb.Struct; + reader.readMessage(value,google_protobuf_struct_pb.Struct.deserializeBinaryFromReader); + msg.setExtra(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.button.v1.PushRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.button.v1.PushRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.button.v1.PushRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.button.v1.PushRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getExtra(); + if (f != null) { + writer.writeMessage( + 99, + f, + google_protobuf_struct_pb.Struct.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.viam.component.button.v1.PushRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.viam.component.button.v1.PushRequest} returns this + */ +proto.viam.component.button.v1.PushRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional google.protobuf.Struct extra = 99; + * @return {?proto.google.protobuf.Struct} + */ +proto.viam.component.button.v1.PushRequest.prototype.getExtra = function() { + return /** @type{?proto.google.protobuf.Struct} */ ( + jspb.Message.getWrapperField(this, google_protobuf_struct_pb.Struct, 99)); +}; + + +/** + * @param {?proto.google.protobuf.Struct|undefined} value + * @return {!proto.viam.component.button.v1.PushRequest} returns this +*/ +proto.viam.component.button.v1.PushRequest.prototype.setExtra = function(value) { + return jspb.Message.setWrapperField(this, 99, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.viam.component.button.v1.PushRequest} returns this + */ +proto.viam.component.button.v1.PushRequest.prototype.clearExtra = function() { + return this.setExtra(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.viam.component.button.v1.PushRequest.prototype.hasExtra = function() { + return jspb.Message.getField(this, 99) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.button.v1.PushResponse.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.button.v1.PushResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.button.v1.PushResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.button.v1.PushResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.button.v1.PushResponse} + */ +proto.viam.component.button.v1.PushResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.button.v1.PushResponse; + return proto.viam.component.button.v1.PushResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.button.v1.PushResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.button.v1.PushResponse} + */ +proto.viam.component.button.v1.PushResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.button.v1.PushResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.button.v1.PushResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.button.v1.PushResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.button.v1.PushResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + +goog.object.extend(exports, proto.viam.component.button.v1); diff --git a/gen/js/component/button/v1/button_pb_service.d.ts b/gen/js/component/button/v1/button_pb_service.d.ts new file mode 100644 index 000000000..929274de5 --- /dev/null +++ b/gen/js/component/button/v1/button_pb_service.d.ts @@ -0,0 +1,83 @@ +// package: viam.component.button.v1 +// file: component/button/v1/button.proto + +import * as component_button_v1_button_pb from "../../../component/button/v1/button_pb"; +import * as common_v1_common_pb from "../../../common/v1/common_pb"; +import {grpc} from "@improbable-eng/grpc-web"; + +type ButtonServicePush = { + readonly methodName: string; + readonly service: typeof ButtonService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof component_button_v1_button_pb.PushRequest; + readonly responseType: typeof component_button_v1_button_pb.PushResponse; +}; + +type ButtonServiceDoCommand = { + readonly methodName: string; + readonly service: typeof ButtonService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof common_v1_common_pb.DoCommandRequest; + readonly responseType: typeof common_v1_common_pb.DoCommandResponse; +}; + +export class ButtonService { + static readonly serviceName: string; + static readonly Push: ButtonServicePush; + static readonly DoCommand: ButtonServiceDoCommand; +} + +export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } +export type Status = { details: string, code: number; metadata: grpc.Metadata } + +interface UnaryResponse { + cancel(): void; +} +interface ResponseStream { + cancel(): void; + on(type: 'data', handler: (message: T) => void): ResponseStream; + on(type: 'end', handler: (status?: Status) => void): ResponseStream; + on(type: 'status', handler: (status: Status) => void): ResponseStream; +} +interface RequestStream { + write(message: T): RequestStream; + end(): void; + cancel(): void; + on(type: 'end', handler: (status?: Status) => void): RequestStream; + on(type: 'status', handler: (status: Status) => void): RequestStream; +} +interface BidirectionalStream { + write(message: ReqT): BidirectionalStream; + end(): void; + cancel(): void; + on(type: 'data', handler: (message: ResT) => void): BidirectionalStream; + on(type: 'end', handler: (status?: Status) => void): BidirectionalStream; + on(type: 'status', handler: (status: Status) => void): BidirectionalStream; +} + +export class ButtonServiceClient { + readonly serviceHost: string; + + constructor(serviceHost: string, options?: grpc.RpcOptions); + push( + requestMessage: component_button_v1_button_pb.PushRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: component_button_v1_button_pb.PushResponse|null) => void + ): UnaryResponse; + push( + requestMessage: component_button_v1_button_pb.PushRequest, + callback: (error: ServiceError|null, responseMessage: component_button_v1_button_pb.PushResponse|null) => void + ): UnaryResponse; + doCommand( + requestMessage: common_v1_common_pb.DoCommandRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: common_v1_common_pb.DoCommandResponse|null) => void + ): UnaryResponse; + doCommand( + requestMessage: common_v1_common_pb.DoCommandRequest, + callback: (error: ServiceError|null, responseMessage: common_v1_common_pb.DoCommandResponse|null) => void + ): UnaryResponse; +} + diff --git a/gen/js/component/button/v1/button_pb_service.js b/gen/js/component/button/v1/button_pb_service.js new file mode 100644 index 000000000..82b30a775 --- /dev/null +++ b/gen/js/component/button/v1/button_pb_service.js @@ -0,0 +1,102 @@ +// package: viam.component.button.v1 +// file: component/button/v1/button.proto + +var component_button_v1_button_pb = require("../../../component/button/v1/button_pb"); +var common_v1_common_pb = require("../../../common/v1/common_pb"); +var grpc = require("@improbable-eng/grpc-web").grpc; + +var ButtonService = (function () { + function ButtonService() {} + ButtonService.serviceName = "viam.component.button.v1.ButtonService"; + return ButtonService; +}()); + +ButtonService.Push = { + methodName: "Push", + service: ButtonService, + requestStream: false, + responseStream: false, + requestType: component_button_v1_button_pb.PushRequest, + responseType: component_button_v1_button_pb.PushResponse +}; + +ButtonService.DoCommand = { + methodName: "DoCommand", + service: ButtonService, + requestStream: false, + responseStream: false, + requestType: common_v1_common_pb.DoCommandRequest, + responseType: common_v1_common_pb.DoCommandResponse +}; + +exports.ButtonService = ButtonService; + +function ButtonServiceClient(serviceHost, options) { + this.serviceHost = serviceHost; + this.options = options || {}; +} + +ButtonServiceClient.prototype.push = function push(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(ButtonService.Push, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +ButtonServiceClient.prototype.doCommand = function doCommand(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(ButtonService.DoCommand, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +exports.ButtonServiceClient = ButtonServiceClient; + diff --git a/gen/js/component/switch/v1/switch_grpc_web_pb.js b/gen/js/component/switch/v1/switch_grpc_web_pb.js new file mode 100644 index 000000000..c3f78ff84 --- /dev/null +++ b/gen/js/component/switch/v1/switch_grpc_web_pb.js @@ -0,0 +1,331 @@ +/** + * @fileoverview gRPC-Web generated client stub for viam.component.switch.v1 + * @enhanceable + * @public + */ + +// Code generated by protoc-gen-grpc-web. DO NOT EDIT. +// versions: +// protoc-gen-grpc-web v1.5.0 +// protoc v0.0.0 +// source: component/switch/v1/switch.proto + + +/* eslint-disable */ +// @ts-nocheck + + + +const grpc = {}; +grpc.web = require('grpc-web'); + + +var common_v1_common_pb = require('../../../common/v1/common_pb.js') + +var google_api_annotations_pb = require('../../../google/api/annotations_pb.js') + +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js') +const proto = {}; +proto.viam = {}; +proto.viam.component = {}; +proto.viam.component.switch = {}; +proto.viam.component.switch.v1 = require('./switch_pb.js'); + +/** + * @param {string} hostname + * @param {?Object} credentials + * @param {?grpc.web.ClientOptions} options + * @constructor + * @struct + * @final + */ +proto.viam.component.switch.v1.SwitchServiceClient = + function(hostname, credentials, options) { + if (!options) options = {}; + options.format = 'text'; + + /** + * @private @const {!grpc.web.GrpcWebClientBase} The client + */ + this.client_ = new grpc.web.GrpcWebClientBase(options); + + /** + * @private @const {string} The hostname + */ + this.hostname_ = hostname.replace(/\/+$/, ''); + +}; + + +/** + * @param {string} hostname + * @param {?Object} credentials + * @param {?grpc.web.ClientOptions} options + * @constructor + * @struct + * @final + */ +proto.viam.component.switch.v1.SwitchServicePromiseClient = + function(hostname, credentials, options) { + if (!options) options = {}; + options.format = 'text'; + + /** + * @private @const {!grpc.web.GrpcWebClientBase} The client + */ + this.client_ = new grpc.web.GrpcWebClientBase(options); + + /** + * @private @const {string} The hostname + */ + this.hostname_ = hostname.replace(/\/+$/, ''); + +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.viam.component.switch.v1.SetPositionRequest, + * !proto.viam.component.switch.v1.SetPositionResponse>} + */ +const methodDescriptor_SwitchService_SetPosition = new grpc.web.MethodDescriptor( + '/viam.component.switch.v1.SwitchService/SetPosition', + grpc.web.MethodType.UNARY, + proto.viam.component.switch.v1.SetPositionRequest, + proto.viam.component.switch.v1.SetPositionResponse, + /** + * @param {!proto.viam.component.switch.v1.SetPositionRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.viam.component.switch.v1.SetPositionResponse.deserializeBinary +); + + +/** + * @param {!proto.viam.component.switch.v1.SetPositionRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.viam.component.switch.v1.SetPositionResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.viam.component.switch.v1.SwitchServiceClient.prototype.setPosition = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/SetPosition', + request, + metadata || {}, + methodDescriptor_SwitchService_SetPosition, + callback); +}; + + +/** + * @param {!proto.viam.component.switch.v1.SetPositionRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.viam.component.switch.v1.SwitchServicePromiseClient.prototype.setPosition = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/SetPosition', + request, + metadata || {}, + methodDescriptor_SwitchService_SetPosition); +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.viam.component.switch.v1.GetPositionRequest, + * !proto.viam.component.switch.v1.GetPositionResponse>} + */ +const methodDescriptor_SwitchService_GetPosition = new grpc.web.MethodDescriptor( + '/viam.component.switch.v1.SwitchService/GetPosition', + grpc.web.MethodType.UNARY, + proto.viam.component.switch.v1.GetPositionRequest, + proto.viam.component.switch.v1.GetPositionResponse, + /** + * @param {!proto.viam.component.switch.v1.GetPositionRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.viam.component.switch.v1.GetPositionResponse.deserializeBinary +); + + +/** + * @param {!proto.viam.component.switch.v1.GetPositionRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.viam.component.switch.v1.GetPositionResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.viam.component.switch.v1.SwitchServiceClient.prototype.getPosition = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/GetPosition', + request, + metadata || {}, + methodDescriptor_SwitchService_GetPosition, + callback); +}; + + +/** + * @param {!proto.viam.component.switch.v1.GetPositionRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.viam.component.switch.v1.SwitchServicePromiseClient.prototype.getPosition = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/GetPosition', + request, + metadata || {}, + methodDescriptor_SwitchService_GetPosition); +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.viam.component.switch.v1.GetNumberOfPositionsRequest, + * !proto.viam.component.switch.v1.GetNumberOfPositionsResponse>} + */ +const methodDescriptor_SwitchService_GetNumberOfPositions = new grpc.web.MethodDescriptor( + '/viam.component.switch.v1.SwitchService/GetNumberOfPositions', + grpc.web.MethodType.UNARY, + proto.viam.component.switch.v1.GetNumberOfPositionsRequest, + proto.viam.component.switch.v1.GetNumberOfPositionsResponse, + /** + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.viam.component.switch.v1.GetNumberOfPositionsResponse.deserializeBinary +); + + +/** + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.viam.component.switch.v1.GetNumberOfPositionsResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.viam.component.switch.v1.SwitchServiceClient.prototype.getNumberOfPositions = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/GetNumberOfPositions', + request, + metadata || {}, + methodDescriptor_SwitchService_GetNumberOfPositions, + callback); +}; + + +/** + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.viam.component.switch.v1.SwitchServicePromiseClient.prototype.getNumberOfPositions = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/GetNumberOfPositions', + request, + metadata || {}, + methodDescriptor_SwitchService_GetNumberOfPositions); +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.viam.common.v1.DoCommandRequest, + * !proto.viam.common.v1.DoCommandResponse>} + */ +const methodDescriptor_SwitchService_DoCommand = new grpc.web.MethodDescriptor( + '/viam.component.switch.v1.SwitchService/DoCommand', + grpc.web.MethodType.UNARY, + common_v1_common_pb.DoCommandRequest, + common_v1_common_pb.DoCommandResponse, + /** + * @param {!proto.viam.common.v1.DoCommandRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + common_v1_common_pb.DoCommandResponse.deserializeBinary +); + + +/** + * @param {!proto.viam.common.v1.DoCommandRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.viam.common.v1.DoCommandResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.viam.component.switch.v1.SwitchServiceClient.prototype.doCommand = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/DoCommand', + request, + metadata || {}, + methodDescriptor_SwitchService_DoCommand, + callback); +}; + + +/** + * @param {!proto.viam.common.v1.DoCommandRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.viam.component.switch.v1.SwitchServicePromiseClient.prototype.doCommand = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/viam.component.switch.v1.SwitchService/DoCommand', + request, + metadata || {}, + methodDescriptor_SwitchService_DoCommand); +}; + + +module.exports = proto.viam.component.switch.v1; + diff --git a/gen/js/component/switch/v1/switch_pb.d.ts b/gen/js/component/switch/v1/switch_pb.d.ts new file mode 100644 index 000000000..80e6eb9cd --- /dev/null +++ b/gen/js/component/switch/v1/switch_pb.d.ts @@ -0,0 +1,146 @@ +// package: viam.component.switch.v1 +// file: component/switch/v1/switch.proto + +import * as jspb from "google-protobuf"; +import * as common_v1_common_pb from "../../../common/v1/common_pb"; +import * as google_api_annotations_pb from "../../../google/api/annotations_pb"; +import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb"; + +export class SetPositionRequest extends jspb.Message { + getName(): string; + setName(value: string): void; + + getPosition(): number; + setPosition(value: number): void; + + hasExtra(): boolean; + clearExtra(): void; + getExtra(): google_protobuf_struct_pb.Struct | undefined; + setExtra(value?: google_protobuf_struct_pb.Struct): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SetPositionRequest.AsObject; + static toObject(includeInstance: boolean, msg: SetPositionRequest): SetPositionRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SetPositionRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SetPositionRequest; + static deserializeBinaryFromReader(message: SetPositionRequest, reader: jspb.BinaryReader): SetPositionRequest; +} + +export namespace SetPositionRequest { + export type AsObject = { + name: string, + position: number, + extra?: google_protobuf_struct_pb.Struct.AsObject, + } +} + +export class SetPositionResponse extends jspb.Message { + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SetPositionResponse.AsObject; + static toObject(includeInstance: boolean, msg: SetPositionResponse): SetPositionResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SetPositionResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SetPositionResponse; + static deserializeBinaryFromReader(message: SetPositionResponse, reader: jspb.BinaryReader): SetPositionResponse; +} + +export namespace SetPositionResponse { + export type AsObject = { + } +} + +export class GetPositionRequest extends jspb.Message { + getName(): string; + setName(value: string): void; + + hasExtra(): boolean; + clearExtra(): void; + getExtra(): google_protobuf_struct_pb.Struct | undefined; + setExtra(value?: google_protobuf_struct_pb.Struct): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetPositionRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetPositionRequest): GetPositionRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetPositionRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetPositionRequest; + static deserializeBinaryFromReader(message: GetPositionRequest, reader: jspb.BinaryReader): GetPositionRequest; +} + +export namespace GetPositionRequest { + export type AsObject = { + name: string, + extra?: google_protobuf_struct_pb.Struct.AsObject, + } +} + +export class GetPositionResponse extends jspb.Message { + getPosition(): number; + setPosition(value: number): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetPositionResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetPositionResponse): GetPositionResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetPositionResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetPositionResponse; + static deserializeBinaryFromReader(message: GetPositionResponse, reader: jspb.BinaryReader): GetPositionResponse; +} + +export namespace GetPositionResponse { + export type AsObject = { + position: number, + } +} + +export class GetNumberOfPositionsRequest extends jspb.Message { + getName(): string; + setName(value: string): void; + + hasExtra(): boolean; + clearExtra(): void; + getExtra(): google_protobuf_struct_pb.Struct | undefined; + setExtra(value?: google_protobuf_struct_pb.Struct): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetNumberOfPositionsRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetNumberOfPositionsRequest): GetNumberOfPositionsRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetNumberOfPositionsRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetNumberOfPositionsRequest; + static deserializeBinaryFromReader(message: GetNumberOfPositionsRequest, reader: jspb.BinaryReader): GetNumberOfPositionsRequest; +} + +export namespace GetNumberOfPositionsRequest { + export type AsObject = { + name: string, + extra?: google_protobuf_struct_pb.Struct.AsObject, + } +} + +export class GetNumberOfPositionsResponse extends jspb.Message { + getNumberOfPositions(): number; + setNumberOfPositions(value: number): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetNumberOfPositionsResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetNumberOfPositionsResponse): GetNumberOfPositionsResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetNumberOfPositionsResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetNumberOfPositionsResponse; + static deserializeBinaryFromReader(message: GetNumberOfPositionsResponse, reader: jspb.BinaryReader): GetNumberOfPositionsResponse; +} + +export namespace GetNumberOfPositionsResponse { + export type AsObject = { + numberOfPositions: number, + } +} + diff --git a/gen/js/component/switch/v1/switch_pb.js b/gen/js/component/switch/v1/switch_pb.js new file mode 100644 index 000000000..880bc4eb9 --- /dev/null +++ b/gen/js/component/switch/v1/switch_pb.js @@ -0,0 +1,1090 @@ +// source: component/switch/v1/switch.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); + +var common_v1_common_pb = require('../../../common/v1/common_pb.js'); +goog.object.extend(proto, common_v1_common_pb); +var google_api_annotations_pb = require('../../../google/api/annotations_pb.js'); +goog.object.extend(proto, google_api_annotations_pb); +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js'); +goog.object.extend(proto, google_protobuf_struct_pb); +goog.exportSymbol('proto.viam.component.switch.v1.GetNumberOfPositionsRequest', null, global); +goog.exportSymbol('proto.viam.component.switch.v1.GetNumberOfPositionsResponse', null, global); +goog.exportSymbol('proto.viam.component.switch.v1.GetPositionRequest', null, global); +goog.exportSymbol('proto.viam.component.switch.v1.GetPositionResponse', null, global); +goog.exportSymbol('proto.viam.component.switch.v1.SetPositionRequest', null, global); +goog.exportSymbol('proto.viam.component.switch.v1.SetPositionResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.switch.v1.SetPositionRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.switch.v1.SetPositionRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.switch.v1.SetPositionRequest.displayName = 'proto.viam.component.switch.v1.SetPositionRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.switch.v1.SetPositionResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.switch.v1.SetPositionResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.switch.v1.SetPositionResponse.displayName = 'proto.viam.component.switch.v1.SetPositionResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.switch.v1.GetPositionRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.switch.v1.GetPositionRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.switch.v1.GetPositionRequest.displayName = 'proto.viam.component.switch.v1.GetPositionRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.switch.v1.GetPositionResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.switch.v1.GetPositionResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.switch.v1.GetPositionResponse.displayName = 'proto.viam.component.switch.v1.GetPositionResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.switch.v1.GetNumberOfPositionsRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.switch.v1.GetNumberOfPositionsRequest.displayName = 'proto.viam.component.switch.v1.GetNumberOfPositionsRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.viam.component.switch.v1.GetNumberOfPositionsResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.viam.component.switch.v1.GetNumberOfPositionsResponse.displayName = 'proto.viam.component.switch.v1.GetNumberOfPositionsResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.switch.v1.SetPositionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.switch.v1.SetPositionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.SetPositionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + position: jspb.Message.getFieldWithDefault(msg, 2, 0), + extra: (f = msg.getExtra()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.switch.v1.SetPositionRequest} + */ +proto.viam.component.switch.v1.SetPositionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.switch.v1.SetPositionRequest; + return proto.viam.component.switch.v1.SetPositionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.switch.v1.SetPositionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.switch.v1.SetPositionRequest} + */ +proto.viam.component.switch.v1.SetPositionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setPosition(value); + break; + case 99: + var value = new google_protobuf_struct_pb.Struct; + reader.readMessage(value,google_protobuf_struct_pb.Struct.deserializeBinaryFromReader); + msg.setExtra(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.switch.v1.SetPositionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.switch.v1.SetPositionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.SetPositionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getPosition(); + if (f !== 0) { + writer.writeUint32( + 2, + f + ); + } + f = message.getExtra(); + if (f != null) { + writer.writeMessage( + 99, + f, + google_protobuf_struct_pb.Struct.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.viam.component.switch.v1.SetPositionRequest} returns this + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional uint32 position = 2; + * @return {number} + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.getPosition = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.viam.component.switch.v1.SetPositionRequest} returns this + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.setPosition = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional google.protobuf.Struct extra = 99; + * @return {?proto.google.protobuf.Struct} + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.getExtra = function() { + return /** @type{?proto.google.protobuf.Struct} */ ( + jspb.Message.getWrapperField(this, google_protobuf_struct_pb.Struct, 99)); +}; + + +/** + * @param {?proto.google.protobuf.Struct|undefined} value + * @return {!proto.viam.component.switch.v1.SetPositionRequest} returns this +*/ +proto.viam.component.switch.v1.SetPositionRequest.prototype.setExtra = function(value) { + return jspb.Message.setWrapperField(this, 99, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.viam.component.switch.v1.SetPositionRequest} returns this + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.clearExtra = function() { + return this.setExtra(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.viam.component.switch.v1.SetPositionRequest.prototype.hasExtra = function() { + return jspb.Message.getField(this, 99) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.switch.v1.SetPositionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.switch.v1.SetPositionResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.switch.v1.SetPositionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.SetPositionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.switch.v1.SetPositionResponse} + */ +proto.viam.component.switch.v1.SetPositionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.switch.v1.SetPositionResponse; + return proto.viam.component.switch.v1.SetPositionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.switch.v1.SetPositionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.switch.v1.SetPositionResponse} + */ +proto.viam.component.switch.v1.SetPositionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.switch.v1.SetPositionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.switch.v1.SetPositionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.switch.v1.SetPositionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.SetPositionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.switch.v1.GetPositionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.switch.v1.GetPositionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetPositionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + extra: (f = msg.getExtra()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.switch.v1.GetPositionRequest} + */ +proto.viam.component.switch.v1.GetPositionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.switch.v1.GetPositionRequest; + return proto.viam.component.switch.v1.GetPositionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.switch.v1.GetPositionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.switch.v1.GetPositionRequest} + */ +proto.viam.component.switch.v1.GetPositionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 99: + var value = new google_protobuf_struct_pb.Struct; + reader.readMessage(value,google_protobuf_struct_pb.Struct.deserializeBinaryFromReader); + msg.setExtra(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.switch.v1.GetPositionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.switch.v1.GetPositionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetPositionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getExtra(); + if (f != null) { + writer.writeMessage( + 99, + f, + google_protobuf_struct_pb.Struct.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.viam.component.switch.v1.GetPositionRequest} returns this + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional google.protobuf.Struct extra = 99; + * @return {?proto.google.protobuf.Struct} + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.getExtra = function() { + return /** @type{?proto.google.protobuf.Struct} */ ( + jspb.Message.getWrapperField(this, google_protobuf_struct_pb.Struct, 99)); +}; + + +/** + * @param {?proto.google.protobuf.Struct|undefined} value + * @return {!proto.viam.component.switch.v1.GetPositionRequest} returns this +*/ +proto.viam.component.switch.v1.GetPositionRequest.prototype.setExtra = function(value) { + return jspb.Message.setWrapperField(this, 99, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.viam.component.switch.v1.GetPositionRequest} returns this + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.clearExtra = function() { + return this.setExtra(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.viam.component.switch.v1.GetPositionRequest.prototype.hasExtra = function() { + return jspb.Message.getField(this, 99) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.switch.v1.GetPositionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.switch.v1.GetPositionResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.switch.v1.GetPositionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetPositionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + position: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.switch.v1.GetPositionResponse} + */ +proto.viam.component.switch.v1.GetPositionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.switch.v1.GetPositionResponse; + return proto.viam.component.switch.v1.GetPositionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.switch.v1.GetPositionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.switch.v1.GetPositionResponse} + */ +proto.viam.component.switch.v1.GetPositionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint32()); + msg.setPosition(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.switch.v1.GetPositionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.switch.v1.GetPositionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.switch.v1.GetPositionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetPositionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPosition(); + if (f !== 0) { + writer.writeUint32( + 1, + f + ); + } +}; + + +/** + * optional uint32 position = 1; + * @return {number} + */ +proto.viam.component.switch.v1.GetPositionResponse.prototype.getPosition = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.viam.component.switch.v1.GetPositionResponse} returns this + */ +proto.viam.component.switch.v1.GetPositionResponse.prototype.setPosition = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.switch.v1.GetNumberOfPositionsRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + extra: (f = msg.getExtra()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.switch.v1.GetNumberOfPositionsRequest; + return proto.viam.component.switch.v1.GetNumberOfPositionsRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 99: + var value = new google_protobuf_struct_pb.Struct; + reader.readMessage(value,google_protobuf_struct_pb.Struct.deserializeBinaryFromReader); + msg.setExtra(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.switch.v1.GetNumberOfPositionsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getExtra(); + if (f != null) { + writer.writeMessage( + 99, + f, + google_protobuf_struct_pb.Struct.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} returns this + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional google.protobuf.Struct extra = 99; + * @return {?proto.google.protobuf.Struct} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.getExtra = function() { + return /** @type{?proto.google.protobuf.Struct} */ ( + jspb.Message.getWrapperField(this, google_protobuf_struct_pb.Struct, 99)); +}; + + +/** + * @param {?proto.google.protobuf.Struct|undefined} value + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} returns this +*/ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.setExtra = function(value) { + return jspb.Message.setWrapperField(this, 99, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsRequest} returns this + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.clearExtra = function() { + return this.setExtra(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsRequest.prototype.hasExtra = function() { + return jspb.Message.getField(this, 99) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.viam.component.switch.v1.GetNumberOfPositionsResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.toObject = function(includeInstance, msg) { + var f, obj = { + numberOfPositions: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsResponse} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.viam.component.switch.v1.GetNumberOfPositionsResponse; + return proto.viam.component.switch.v1.GetNumberOfPositionsResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsResponse} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint32()); + msg.setNumberOfPositions(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.viam.component.switch.v1.GetNumberOfPositionsResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.viam.component.switch.v1.GetNumberOfPositionsResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNumberOfPositions(); + if (f !== 0) { + writer.writeUint32( + 1, + f + ); + } +}; + + +/** + * optional uint32 number_of_positions = 1; + * @return {number} + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.prototype.getNumberOfPositions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.viam.component.switch.v1.GetNumberOfPositionsResponse} returns this + */ +proto.viam.component.switch.v1.GetNumberOfPositionsResponse.prototype.setNumberOfPositions = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +goog.object.extend(exports, proto.viam.component.switch.v1); diff --git a/gen/js/component/switch/v1/switch_pb_service.d.ts b/gen/js/component/switch/v1/switch_pb_service.d.ts new file mode 100644 index 000000000..06a936dab --- /dev/null +++ b/gen/js/component/switch/v1/switch_pb_service.d.ts @@ -0,0 +1,121 @@ +// package: viam.component.switch.v1 +// file: component/switch/v1/switch.proto + +import * as component_switch_v1_switch_pb from "../../../component/switch/v1/switch_pb"; +import * as common_v1_common_pb from "../../../common/v1/common_pb"; +import {grpc} from "@improbable-eng/grpc-web"; + +type SwitchServiceSetPosition = { + readonly methodName: string; + readonly service: typeof SwitchService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof component_switch_v1_switch_pb.SetPositionRequest; + readonly responseType: typeof component_switch_v1_switch_pb.SetPositionResponse; +}; + +type SwitchServiceGetPosition = { + readonly methodName: string; + readonly service: typeof SwitchService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof component_switch_v1_switch_pb.GetPositionRequest; + readonly responseType: typeof component_switch_v1_switch_pb.GetPositionResponse; +}; + +type SwitchServiceGetNumberOfPositions = { + readonly methodName: string; + readonly service: typeof SwitchService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof component_switch_v1_switch_pb.GetNumberOfPositionsRequest; + readonly responseType: typeof component_switch_v1_switch_pb.GetNumberOfPositionsResponse; +}; + +type SwitchServiceDoCommand = { + readonly methodName: string; + readonly service: typeof SwitchService; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof common_v1_common_pb.DoCommandRequest; + readonly responseType: typeof common_v1_common_pb.DoCommandResponse; +}; + +export class SwitchService { + static readonly serviceName: string; + static readonly SetPosition: SwitchServiceSetPosition; + static readonly GetPosition: SwitchServiceGetPosition; + static readonly GetNumberOfPositions: SwitchServiceGetNumberOfPositions; + static readonly DoCommand: SwitchServiceDoCommand; +} + +export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } +export type Status = { details: string, code: number; metadata: grpc.Metadata } + +interface UnaryResponse { + cancel(): void; +} +interface ResponseStream { + cancel(): void; + on(type: 'data', handler: (message: T) => void): ResponseStream; + on(type: 'end', handler: (status?: Status) => void): ResponseStream; + on(type: 'status', handler: (status: Status) => void): ResponseStream; +} +interface RequestStream { + write(message: T): RequestStream; + end(): void; + cancel(): void; + on(type: 'end', handler: (status?: Status) => void): RequestStream; + on(type: 'status', handler: (status: Status) => void): RequestStream; +} +interface BidirectionalStream { + write(message: ReqT): BidirectionalStream; + end(): void; + cancel(): void; + on(type: 'data', handler: (message: ResT) => void): BidirectionalStream; + on(type: 'end', handler: (status?: Status) => void): BidirectionalStream; + on(type: 'status', handler: (status: Status) => void): BidirectionalStream; +} + +export class SwitchServiceClient { + readonly serviceHost: string; + + constructor(serviceHost: string, options?: grpc.RpcOptions); + setPosition( + requestMessage: component_switch_v1_switch_pb.SetPositionRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: component_switch_v1_switch_pb.SetPositionResponse|null) => void + ): UnaryResponse; + setPosition( + requestMessage: component_switch_v1_switch_pb.SetPositionRequest, + callback: (error: ServiceError|null, responseMessage: component_switch_v1_switch_pb.SetPositionResponse|null) => void + ): UnaryResponse; + getPosition( + requestMessage: component_switch_v1_switch_pb.GetPositionRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: component_switch_v1_switch_pb.GetPositionResponse|null) => void + ): UnaryResponse; + getPosition( + requestMessage: component_switch_v1_switch_pb.GetPositionRequest, + callback: (error: ServiceError|null, responseMessage: component_switch_v1_switch_pb.GetPositionResponse|null) => void + ): UnaryResponse; + getNumberOfPositions( + requestMessage: component_switch_v1_switch_pb.GetNumberOfPositionsRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: component_switch_v1_switch_pb.GetNumberOfPositionsResponse|null) => void + ): UnaryResponse; + getNumberOfPositions( + requestMessage: component_switch_v1_switch_pb.GetNumberOfPositionsRequest, + callback: (error: ServiceError|null, responseMessage: component_switch_v1_switch_pb.GetNumberOfPositionsResponse|null) => void + ): UnaryResponse; + doCommand( + requestMessage: common_v1_common_pb.DoCommandRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: common_v1_common_pb.DoCommandResponse|null) => void + ): UnaryResponse; + doCommand( + requestMessage: common_v1_common_pb.DoCommandRequest, + callback: (error: ServiceError|null, responseMessage: common_v1_common_pb.DoCommandResponse|null) => void + ): UnaryResponse; +} + diff --git a/gen/js/component/switch/v1/switch_pb_service.js b/gen/js/component/switch/v1/switch_pb_service.js new file mode 100644 index 000000000..e81b4a1fa --- /dev/null +++ b/gen/js/component/switch/v1/switch_pb_service.js @@ -0,0 +1,182 @@ +// package: viam.component.switch.v1 +// file: component/switch/v1/switch.proto + +var component_switch_v1_switch_pb = require("../../../component/switch/v1/switch_pb"); +var common_v1_common_pb = require("../../../common/v1/common_pb"); +var grpc = require("@improbable-eng/grpc-web").grpc; + +var SwitchService = (function () { + function SwitchService() {} + SwitchService.serviceName = "viam.component.switch.v1.SwitchService"; + return SwitchService; +}()); + +SwitchService.SetPosition = { + methodName: "SetPosition", + service: SwitchService, + requestStream: false, + responseStream: false, + requestType: component_switch_v1_switch_pb.SetPositionRequest, + responseType: component_switch_v1_switch_pb.SetPositionResponse +}; + +SwitchService.GetPosition = { + methodName: "GetPosition", + service: SwitchService, + requestStream: false, + responseStream: false, + requestType: component_switch_v1_switch_pb.GetPositionRequest, + responseType: component_switch_v1_switch_pb.GetPositionResponse +}; + +SwitchService.GetNumberOfPositions = { + methodName: "GetNumberOfPositions", + service: SwitchService, + requestStream: false, + responseStream: false, + requestType: component_switch_v1_switch_pb.GetNumberOfPositionsRequest, + responseType: component_switch_v1_switch_pb.GetNumberOfPositionsResponse +}; + +SwitchService.DoCommand = { + methodName: "DoCommand", + service: SwitchService, + requestStream: false, + responseStream: false, + requestType: common_v1_common_pb.DoCommandRequest, + responseType: common_v1_common_pb.DoCommandResponse +}; + +exports.SwitchService = SwitchService; + +function SwitchServiceClient(serviceHost, options) { + this.serviceHost = serviceHost; + this.options = options || {}; +} + +SwitchServiceClient.prototype.setPosition = function setPosition(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(SwitchService.SetPosition, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +SwitchServiceClient.prototype.getPosition = function getPosition(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(SwitchService.GetPosition, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +SwitchServiceClient.prototype.getNumberOfPositions = function getNumberOfPositions(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(SwitchService.GetNumberOfPositions, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +SwitchServiceClient.prototype.doCommand = function doCommand(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(SwitchService.DoCommand, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +exports.SwitchServiceClient = SwitchServiceClient; + diff --git a/proto/viam/component/button/v1/button.proto b/proto/viam/component/button/v1/button.proto new file mode 100644 index 000000000..53e97239c --- /dev/null +++ b/proto/viam/component/button/v1/button.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package viam.component.button.v1; + +import "common/v1/common.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "go.viam.com/api/component/button/v1"; +option java_package = "com.viam.component.button.v1"; + +// A ButtonService services buttons associated with a machine +service ButtonService { + // Pushes a button + rpc Push(PushRequest) returns (PushResponse) { + option (google.api.http) = {put: "/viam/api/v1/component/button/{name}/push"}; + } + + // DoCommand sends/receives arbitrary commands + rpc DoCommand(common.v1.DoCommandRequest) returns (common.v1.DoCommandResponse) { + option (google.api.http) = {post: "/viam/api/v1/component/button/{name}/do_command"}; + } +} + +message PushRequest { + string name = 1; + google.protobuf.Struct extra = 99; +} + +message PushResponse {} diff --git a/proto/viam/component/switch/v1/switch.proto b/proto/viam/component/switch/v1/switch.proto new file mode 100644 index 000000000..c893e72a6 --- /dev/null +++ b/proto/viam/component/switch/v1/switch.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; + +package viam.component.switch.v1; + +import "common/v1/common.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "go.viam.com/api/component/switch/v1"; +option java_package = "com.viam.component.switch.v1"; + +// A SwitchService services switches associated with a machine. +// Switches can have multiple discrete positions - e.g. a simple +// switch has 2 positions, but a knob could have 10 positions. +service SwitchService { + // Set the position of the switch + rpc SetPosition(SetPositionRequest) returns (SetPositionResponse) { + option (google.api.http) = {put: "/viam/api/v1/component/switch/{name}/set_position"}; + } + + // Get the position of the switch + rpc GetPosition(GetPositionRequest) returns (GetPositionResponse) { + option (google.api.http) = {put: "/viam/api/v1/component/switch/{name}/get_position"}; + } + + // Get the number of positions that the switch supports + rpc GetNumberOfPositions(GetNumberOfPositionsRequest) returns (GetNumberOfPositionsResponse) { + option (google.api.http) = {put: "/viam/api/v1/component/switch/{name}/get_number_of_positions"}; + } + + // DoCommand sends/receives arbitrary commands + rpc DoCommand(common.v1.DoCommandRequest) returns (common.v1.DoCommandResponse) { + option (google.api.http) = {post: "/viam/api/v1/component/switch/{name}/do_command"}; + } +} + +message SetPositionRequest { + string name = 1; + uint32 position = 2; + google.protobuf.Struct extra = 99; +} + +message SetPositionResponse {} + +message GetPositionRequest { + string name = 1; + google.protobuf.Struct extra = 99; +} + +message GetPositionResponse { + uint32 position = 1; +} + +message GetNumberOfPositionsRequest { + string name = 1; + google.protobuf.Struct extra = 99; +} + +message GetNumberOfPositionsResponse { + uint32 number_of_positions = 1; +}