From 1f216ffe7db481897afdb91e3b67cb5549ad351c Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Wed, 3 Nov 2021 23:21:30 +0500 Subject: [PATCH 1/5] #1447 - back-end usage scenario Add .proto file (messages and a service), generate go files. (Draft to demonstrate the proposal). --- rpc/cc/arduino/cli/commands/v1/files.pb.go | 361 ++++++++++++++++++ rpc/cc/arduino/cli/commands/v1/files.proto | 49 +++ .../arduino/cli/commands/v1/files_grpc.pb.go | 104 +++++ 3 files changed, 514 insertions(+) create mode 100644 rpc/cc/arduino/cli/commands/v1/files.pb.go create mode 100644 rpc/cc/arduino/cli/commands/v1/files.proto create mode 100644 rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go diff --git a/rpc/cc/arduino/cli/commands/v1/files.pb.go b/rpc/cc/arduino/cli/commands/v1/files.pb.go new file mode 100644 index 00000000000..e068e964a95 --- /dev/null +++ b/rpc/cc/arduino/cli/commands/v1/files.pb.go @@ -0,0 +1,361 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: cc/arduino/cli/commands/v1/files.proto + +package files + +import ( + status "google.golang.org/genproto/googleapis/rpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + 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 ContentType int32 + +const ( + ContentType_RAW ContentType = 0 + ContentType_ZIP ContentType = 1 +) + +// Enum value maps for ContentType. +var ( + ContentType_name = map[int32]string{ + 0: "RAW", + 1: "ZIP", + } + ContentType_value = map[string]int32{ + "RAW": 0, + "ZIP": 1, + } +) + +func (x ContentType) Enum() *ContentType { + p := new(ContentType) + *p = x + return p +} + +func (x ContentType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ContentType) Descriptor() protoreflect.EnumDescriptor { + return file_cc_arduino_cli_commands_v1_files_proto_enumTypes[0].Descriptor() +} + +func (ContentType) Type() protoreflect.EnumType { + return &file_cc_arduino_cli_commands_v1_files_proto_enumTypes[0] +} + +func (x ContentType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ContentType.Descriptor instead. +func (ContentType) EnumDescriptor() ([]byte, []int) { + return file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP(), []int{0} +} + +type LoadFileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // path as it's returned in LoadSketchResponse for instance + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + // Optional + Type ContentType `protobuf:"varint,2,opt,name=type,proto3,enum=cc.arduino.cli.commands.v1.ContentType" json:"type,omitempty"` +} + +func (x *LoadFileRequest) Reset() { + *x = LoadFileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoadFileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoadFileRequest) ProtoMessage() {} + +func (x *LoadFileRequest) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoadFileRequest.ProtoReflect.Descriptor instead. +func (*LoadFileRequest) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP(), []int{0} +} + +func (x *LoadFileRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *LoadFileRequest) GetType() ContentType { + if x != nil { + return x.Type + } + return ContentType_RAW +} + +type LoadFileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Message: + // *LoadFileResponse_Content + // *LoadFileResponse_Error + Message isLoadFileResponse_Message `protobuf_oneof:"message"` + // is skipped in case of error + Type ContentType `protobuf:"varint,3,opt,name=type,proto3,enum=cc.arduino.cli.commands.v1.ContentType" json:"type,omitempty"` +} + +func (x *LoadFileResponse) Reset() { + *x = LoadFileResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoadFileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoadFileResponse) ProtoMessage() {} + +func (x *LoadFileResponse) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoadFileResponse.ProtoReflect.Descriptor instead. +func (*LoadFileResponse) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP(), []int{1} +} + +func (m *LoadFileResponse) GetMessage() isLoadFileResponse_Message { + if m != nil { + return m.Message + } + return nil +} + +func (x *LoadFileResponse) GetContent() []byte { + if x, ok := x.GetMessage().(*LoadFileResponse_Content); ok { + return x.Content + } + return nil +} + +func (x *LoadFileResponse) GetError() *status.Status { + if x, ok := x.GetMessage().(*LoadFileResponse_Error); ok { + return x.Error + } + return nil +} + +func (x *LoadFileResponse) GetType() ContentType { + if x != nil { + return x.Type + } + return ContentType_RAW +} + +type isLoadFileResponse_Message interface { + isLoadFileResponse_Message() +} + +type LoadFileResponse_Content struct { + Content []byte `protobuf:"bytes,1,opt,name=content,proto3,oneof"` +} + +type LoadFileResponse_Error struct { + Error *status.Status `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*LoadFileResponse_Content) isLoadFileResponse_Message() {} + +func (*LoadFileResponse_Error) isLoadFileResponse_Message() {} + +var File_cc_arduino_cli_commands_v1_files_proto protoreflect.FileDescriptor + +var file_cc_arduino_cli_commands_v1_files_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, + 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x62, 0x0a, + 0x0f, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x3b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, + 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x22, 0xa2, 0x01, 0x0a, 0x10, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x3b, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x1f, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x52, 0x41, 0x57, 0x10, 0x00, 0x12, 0x07, + 0x0a, 0x03, 0x5a, 0x49, 0x50, 0x10, 0x01, 0x32, 0x83, 0x01, 0x0a, 0x18, 0x41, 0x72, 0x64, 0x75, + 0x69, 0x6e, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, 0x0a, 0x08, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, + 0x12, 0x2b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, + 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, + 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, + 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, + 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, + 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, + 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, + 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, + 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x66, + 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cc_arduino_cli_commands_v1_files_proto_rawDescOnce sync.Once + file_cc_arduino_cli_commands_v1_files_proto_rawDescData = file_cc_arduino_cli_commands_v1_files_proto_rawDesc +) + +func file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP() []byte { + file_cc_arduino_cli_commands_v1_files_proto_rawDescOnce.Do(func() { + file_cc_arduino_cli_commands_v1_files_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_cli_commands_v1_files_proto_rawDescData) + }) + return file_cc_arduino_cli_commands_v1_files_proto_rawDescData +} + +var file_cc_arduino_cli_commands_v1_files_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_cc_arduino_cli_commands_v1_files_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cc_arduino_cli_commands_v1_files_proto_goTypes = []interface{}{ + (ContentType)(0), // 0: cc.arduino.cli.commands.v1.ContentType + (*LoadFileRequest)(nil), // 1: cc.arduino.cli.commands.v1.LoadFileRequest + (*LoadFileResponse)(nil), // 2: cc.arduino.cli.commands.v1.LoadFileResponse + (*status.Status)(nil), // 3: google.rpc.Status +} +var file_cc_arduino_cli_commands_v1_files_proto_depIdxs = []int32{ + 0, // 0: cc.arduino.cli.commands.v1.LoadFileRequest.type:type_name -> cc.arduino.cli.commands.v1.ContentType + 3, // 1: cc.arduino.cli.commands.v1.LoadFileResponse.error:type_name -> google.rpc.Status + 0, // 2: cc.arduino.cli.commands.v1.LoadFileResponse.type:type_name -> cc.arduino.cli.commands.v1.ContentType + 1, // 3: cc.arduino.cli.commands.v1.ArduinoFileSystemService.LoadFile:input_type -> cc.arduino.cli.commands.v1.LoadFileRequest + 2, // 4: cc.arduino.cli.commands.v1.ArduinoFileSystemService.LoadFile:output_type -> cc.arduino.cli.commands.v1.LoadFileResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] 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_cc_arduino_cli_commands_v1_files_proto_init() } +func file_cc_arduino_cli_commands_v1_files_proto_init() { + if File_cc_arduino_cli_commands_v1_files_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cc_arduino_cli_commands_v1_files_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoadFileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoadFileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*LoadFileResponse_Content)(nil), + (*LoadFileResponse_Error)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cc_arduino_cli_commands_v1_files_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_cc_arduino_cli_commands_v1_files_proto_goTypes, + DependencyIndexes: file_cc_arduino_cli_commands_v1_files_proto_depIdxs, + EnumInfos: file_cc_arduino_cli_commands_v1_files_proto_enumTypes, + MessageInfos: file_cc_arduino_cli_commands_v1_files_proto_msgTypes, + }.Build() + File_cc_arduino_cli_commands_v1_files_proto = out.File + file_cc_arduino_cli_commands_v1_files_proto_rawDesc = nil + file_cc_arduino_cli_commands_v1_files_proto_goTypes = nil + file_cc_arduino_cli_commands_v1_files_proto_depIdxs = nil +} diff --git a/rpc/cc/arduino/cli/commands/v1/files.proto b/rpc/cc/arduino/cli/commands/v1/files.proto new file mode 100644 index 00000000000..50b42e0be2f --- /dev/null +++ b/rpc/cc/arduino/cli/commands/v1/files.proto @@ -0,0 +1,49 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands.v1; + +option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1;files"; + +import "google/rpc/status.proto"; + +// Arduino File System service API +service ArduinoFileSystemService { + // Load file content from the file system + rpc LoadFile(LoadFileRequest) returns (LoadFileResponse) {} +} + +enum ContentType { + RAW = 0; + ZIP = 1; +} + +message LoadFileRequest { + // path as it's returned in LoadSketchResponse for instance + string path = 1; + // Optional + ContentType type = 2; +} + +message LoadFileResponse { + oneof message { + bytes content = 1; + google.rpc.Status error = 2; + } + // is skipped in case of error + ContentType type = 3; +} diff --git a/rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go b/rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go new file mode 100644 index 00000000000..7c0abd5c95a --- /dev/null +++ b/rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go @@ -0,0 +1,104 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package files + +import ( + context "context" + 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 + +// ArduinoFileSystemServiceClient is the client API for ArduinoFileSystemService 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 ArduinoFileSystemServiceClient interface { + // Load file content from the file system + LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) +} + +type arduinoFileSystemServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewArduinoFileSystemServiceClient(cc grpc.ClientConnInterface) ArduinoFileSystemServiceClient { + return &arduinoFileSystemServiceClient{cc} +} + +func (c *arduinoFileSystemServiceClient) LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) { + out := new(LoadFileResponse) + err := c.cc.Invoke(ctx, "/cc.arduino.cli.commands.v1.ArduinoFileSystemService/LoadFile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ArduinoFileSystemServiceServer is the server API for ArduinoFileSystemService service. +// All implementations must embed UnimplementedArduinoFileSystemServiceServer +// for forward compatibility +type ArduinoFileSystemServiceServer interface { + // Load file content from the file system + LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) + mustEmbedUnimplementedArduinoFileSystemServiceServer() +} + +// UnimplementedArduinoFileSystemServiceServer must be embedded to have forward compatible implementations. +type UnimplementedArduinoFileSystemServiceServer struct { +} + +func (UnimplementedArduinoFileSystemServiceServer) LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoadFile not implemented") +} +func (UnimplementedArduinoFileSystemServiceServer) mustEmbedUnimplementedArduinoFileSystemServiceServer() { +} + +// UnsafeArduinoFileSystemServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ArduinoFileSystemServiceServer will +// result in compilation errors. +type UnsafeArduinoFileSystemServiceServer interface { + mustEmbedUnimplementedArduinoFileSystemServiceServer() +} + +func RegisterArduinoFileSystemServiceServer(s grpc.ServiceRegistrar, srv ArduinoFileSystemServiceServer) { + s.RegisterService(&ArduinoFileSystemService_ServiceDesc, srv) +} + +func _ArduinoFileSystemService_LoadFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoadFileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArduinoFileSystemServiceServer).LoadFile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cc.arduino.cli.commands.v1.ArduinoFileSystemService/LoadFile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArduinoFileSystemServiceServer).LoadFile(ctx, req.(*LoadFileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ArduinoFileSystemService_ServiceDesc is the grpc.ServiceDesc for ArduinoFileSystemService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ArduinoFileSystemService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cc.arduino.cli.commands.v1.ArduinoFileSystemService", + HandlerType: (*ArduinoFileSystemServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LoadFile", + Handler: _ArduinoFileSystemService_LoadFile_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cc/arduino/cli/commands/v1/files.proto", +} From d13b45b6054bdf5ec867e3196d79d3c0d15c47e9 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Thu, 4 Nov 2021 10:45:24 +0500 Subject: [PATCH 2/5] #1447 - back-end usage scenario Move to a proper location (fix compilation). --- rpc/cc/arduino/cli/commands/v1/files.pb.go | 361 ------------------ .../arduino/cli/commands/v1/files_grpc.pb.go | 104 ----- rpc/cc/arduino/cli/files/v1/files.pb.go | 361 ++++++++++++++++++ .../cli/{commands => files}/v1/files.proto | 12 +- rpc/cc/arduino/cli/files/v1/files_grpc.pb.go | 103 +++++ 5 files changed, 470 insertions(+), 471 deletions(-) delete mode 100644 rpc/cc/arduino/cli/commands/v1/files.pb.go delete mode 100644 rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go create mode 100644 rpc/cc/arduino/cli/files/v1/files.pb.go rename rpc/cc/arduino/cli/{commands => files}/v1/files.proto (88%) create mode 100644 rpc/cc/arduino/cli/files/v1/files_grpc.pb.go diff --git a/rpc/cc/arduino/cli/commands/v1/files.pb.go b/rpc/cc/arduino/cli/commands/v1/files.pb.go deleted file mode 100644 index e068e964a95..00000000000 --- a/rpc/cc/arduino/cli/commands/v1/files.pb.go +++ /dev/null @@ -1,361 +0,0 @@ -// This file is part of arduino-cli. -// -// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of arduino-cli. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to -// modify or otherwise use the software for commercial activities involving the -// Arduino software without disclosing the source code of your own applications. -// To purchase a commercial license, send an email to license@arduino.cc. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v3.17.3 -// source: cc/arduino/cli/commands/v1/files.proto - -package files - -import ( - status "google.golang.org/genproto/googleapis/rpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - 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 ContentType int32 - -const ( - ContentType_RAW ContentType = 0 - ContentType_ZIP ContentType = 1 -) - -// Enum value maps for ContentType. -var ( - ContentType_name = map[int32]string{ - 0: "RAW", - 1: "ZIP", - } - ContentType_value = map[string]int32{ - "RAW": 0, - "ZIP": 1, - } -) - -func (x ContentType) Enum() *ContentType { - p := new(ContentType) - *p = x - return p -} - -func (x ContentType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ContentType) Descriptor() protoreflect.EnumDescriptor { - return file_cc_arduino_cli_commands_v1_files_proto_enumTypes[0].Descriptor() -} - -func (ContentType) Type() protoreflect.EnumType { - return &file_cc_arduino_cli_commands_v1_files_proto_enumTypes[0] -} - -func (x ContentType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ContentType.Descriptor instead. -func (ContentType) EnumDescriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP(), []int{0} -} - -type LoadFileRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // path as it's returned in LoadSketchResponse for instance - Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - // Optional - Type ContentType `protobuf:"varint,2,opt,name=type,proto3,enum=cc.arduino.cli.commands.v1.ContentType" json:"type,omitempty"` -} - -func (x *LoadFileRequest) Reset() { - *x = LoadFileRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *LoadFileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoadFileRequest) ProtoMessage() {} - -func (x *LoadFileRequest) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LoadFileRequest.ProtoReflect.Descriptor instead. -func (*LoadFileRequest) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP(), []int{0} -} - -func (x *LoadFileRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *LoadFileRequest) GetType() ContentType { - if x != nil { - return x.Type - } - return ContentType_RAW -} - -type LoadFileResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Message: - // *LoadFileResponse_Content - // *LoadFileResponse_Error - Message isLoadFileResponse_Message `protobuf_oneof:"message"` - // is skipped in case of error - Type ContentType `protobuf:"varint,3,opt,name=type,proto3,enum=cc.arduino.cli.commands.v1.ContentType" json:"type,omitempty"` -} - -func (x *LoadFileResponse) Reset() { - *x = LoadFileResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *LoadFileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoadFileResponse) ProtoMessage() {} - -func (x *LoadFileResponse) ProtoReflect() protoreflect.Message { - mi := &file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LoadFileResponse.ProtoReflect.Descriptor instead. -func (*LoadFileResponse) Descriptor() ([]byte, []int) { - return file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP(), []int{1} -} - -func (m *LoadFileResponse) GetMessage() isLoadFileResponse_Message { - if m != nil { - return m.Message - } - return nil -} - -func (x *LoadFileResponse) GetContent() []byte { - if x, ok := x.GetMessage().(*LoadFileResponse_Content); ok { - return x.Content - } - return nil -} - -func (x *LoadFileResponse) GetError() *status.Status { - if x, ok := x.GetMessage().(*LoadFileResponse_Error); ok { - return x.Error - } - return nil -} - -func (x *LoadFileResponse) GetType() ContentType { - if x != nil { - return x.Type - } - return ContentType_RAW -} - -type isLoadFileResponse_Message interface { - isLoadFileResponse_Message() -} - -type LoadFileResponse_Content struct { - Content []byte `protobuf:"bytes,1,opt,name=content,proto3,oneof"` -} - -type LoadFileResponse_Error struct { - Error *status.Status `protobuf:"bytes,2,opt,name=error,proto3,oneof"` -} - -func (*LoadFileResponse_Content) isLoadFileResponse_Message() {} - -func (*LoadFileResponse_Error) isLoadFileResponse_Message() {} - -var File_cc_arduino_cli_commands_v1_files_proto protoreflect.FileDescriptor - -var file_cc_arduino_cli_commands_v1_files_proto_rawDesc = []byte{ - 0x0a, 0x26, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x69, 0x6c, - 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, - 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x62, 0x0a, - 0x0f, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x70, 0x61, 0x74, 0x68, 0x12, 0x3b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, - 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x22, 0xa2, 0x01, 0x0a, 0x10, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x3b, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, - 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x1f, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x52, 0x41, 0x57, 0x10, 0x00, 0x12, 0x07, - 0x0a, 0x03, 0x5a, 0x49, 0x50, 0x10, 0x01, 0x32, 0x83, 0x01, 0x0a, 0x18, 0x41, 0x72, 0x64, 0x75, - 0x69, 0x6e, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, 0x0a, 0x08, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, - 0x12, 0x2b, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, - 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, - 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, - 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, - 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, - 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, - 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, - 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, - 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x66, - 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_cc_arduino_cli_commands_v1_files_proto_rawDescOnce sync.Once - file_cc_arduino_cli_commands_v1_files_proto_rawDescData = file_cc_arduino_cli_commands_v1_files_proto_rawDesc -) - -func file_cc_arduino_cli_commands_v1_files_proto_rawDescGZIP() []byte { - file_cc_arduino_cli_commands_v1_files_proto_rawDescOnce.Do(func() { - file_cc_arduino_cli_commands_v1_files_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_cli_commands_v1_files_proto_rawDescData) - }) - return file_cc_arduino_cli_commands_v1_files_proto_rawDescData -} - -var file_cc_arduino_cli_commands_v1_files_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_cc_arduino_cli_commands_v1_files_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_cc_arduino_cli_commands_v1_files_proto_goTypes = []interface{}{ - (ContentType)(0), // 0: cc.arduino.cli.commands.v1.ContentType - (*LoadFileRequest)(nil), // 1: cc.arduino.cli.commands.v1.LoadFileRequest - (*LoadFileResponse)(nil), // 2: cc.arduino.cli.commands.v1.LoadFileResponse - (*status.Status)(nil), // 3: google.rpc.Status -} -var file_cc_arduino_cli_commands_v1_files_proto_depIdxs = []int32{ - 0, // 0: cc.arduino.cli.commands.v1.LoadFileRequest.type:type_name -> cc.arduino.cli.commands.v1.ContentType - 3, // 1: cc.arduino.cli.commands.v1.LoadFileResponse.error:type_name -> google.rpc.Status - 0, // 2: cc.arduino.cli.commands.v1.LoadFileResponse.type:type_name -> cc.arduino.cli.commands.v1.ContentType - 1, // 3: cc.arduino.cli.commands.v1.ArduinoFileSystemService.LoadFile:input_type -> cc.arduino.cli.commands.v1.LoadFileRequest - 2, // 4: cc.arduino.cli.commands.v1.ArduinoFileSystemService.LoadFile:output_type -> cc.arduino.cli.commands.v1.LoadFileResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] 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_cc_arduino_cli_commands_v1_files_proto_init() } -func file_cc_arduino_cli_commands_v1_files_proto_init() { - if File_cc_arduino_cli_commands_v1_files_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_cc_arduino_cli_commands_v1_files_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LoadFileRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LoadFileResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_cc_arduino_cli_commands_v1_files_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*LoadFileResponse_Content)(nil), - (*LoadFileResponse_Error)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_cc_arduino_cli_commands_v1_files_proto_rawDesc, - NumEnums: 1, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_cc_arduino_cli_commands_v1_files_proto_goTypes, - DependencyIndexes: file_cc_arduino_cli_commands_v1_files_proto_depIdxs, - EnumInfos: file_cc_arduino_cli_commands_v1_files_proto_enumTypes, - MessageInfos: file_cc_arduino_cli_commands_v1_files_proto_msgTypes, - }.Build() - File_cc_arduino_cli_commands_v1_files_proto = out.File - file_cc_arduino_cli_commands_v1_files_proto_rawDesc = nil - file_cc_arduino_cli_commands_v1_files_proto_goTypes = nil - file_cc_arduino_cli_commands_v1_files_proto_depIdxs = nil -} diff --git a/rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go b/rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go deleted file mode 100644 index 7c0abd5c95a..00000000000 --- a/rpc/cc/arduino/cli/commands/v1/files_grpc.pb.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package files - -import ( - context "context" - 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 - -// ArduinoFileSystemServiceClient is the client API for ArduinoFileSystemService 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 ArduinoFileSystemServiceClient interface { - // Load file content from the file system - LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) -} - -type arduinoFileSystemServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewArduinoFileSystemServiceClient(cc grpc.ClientConnInterface) ArduinoFileSystemServiceClient { - return &arduinoFileSystemServiceClient{cc} -} - -func (c *arduinoFileSystemServiceClient) LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) { - out := new(LoadFileResponse) - err := c.cc.Invoke(ctx, "/cc.arduino.cli.commands.v1.ArduinoFileSystemService/LoadFile", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ArduinoFileSystemServiceServer is the server API for ArduinoFileSystemService service. -// All implementations must embed UnimplementedArduinoFileSystemServiceServer -// for forward compatibility -type ArduinoFileSystemServiceServer interface { - // Load file content from the file system - LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) - mustEmbedUnimplementedArduinoFileSystemServiceServer() -} - -// UnimplementedArduinoFileSystemServiceServer must be embedded to have forward compatible implementations. -type UnimplementedArduinoFileSystemServiceServer struct { -} - -func (UnimplementedArduinoFileSystemServiceServer) LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LoadFile not implemented") -} -func (UnimplementedArduinoFileSystemServiceServer) mustEmbedUnimplementedArduinoFileSystemServiceServer() { -} - -// UnsafeArduinoFileSystemServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ArduinoFileSystemServiceServer will -// result in compilation errors. -type UnsafeArduinoFileSystemServiceServer interface { - mustEmbedUnimplementedArduinoFileSystemServiceServer() -} - -func RegisterArduinoFileSystemServiceServer(s grpc.ServiceRegistrar, srv ArduinoFileSystemServiceServer) { - s.RegisterService(&ArduinoFileSystemService_ServiceDesc, srv) -} - -func _ArduinoFileSystemService_LoadFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LoadFileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ArduinoFileSystemServiceServer).LoadFile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cc.arduino.cli.commands.v1.ArduinoFileSystemService/LoadFile", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ArduinoFileSystemServiceServer).LoadFile(ctx, req.(*LoadFileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// ArduinoFileSystemService_ServiceDesc is the grpc.ServiceDesc for ArduinoFileSystemService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ArduinoFileSystemService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "cc.arduino.cli.commands.v1.ArduinoFileSystemService", - HandlerType: (*ArduinoFileSystemServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "LoadFile", - Handler: _ArduinoFileSystemService_LoadFile_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cc/arduino/cli/commands/v1/files.proto", -} diff --git a/rpc/cc/arduino/cli/files/v1/files.pb.go b/rpc/cc/arduino/cli/files/v1/files.pb.go new file mode 100644 index 00000000000..7ea284375e6 --- /dev/null +++ b/rpc/cc/arduino/cli/files/v1/files.pb.go @@ -0,0 +1,361 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: cc/arduino/cli/files/v1/files.proto + +package files + +import ( + status "google.golang.org/genproto/googleapis/rpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + 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 ContentType int32 + +const ( + ContentType_CONTENT_TYPE_RAW_UNSPECIFIED ContentType = 0 + ContentType_CONTENT_TYPE_ZIP ContentType = 1 +) + +// Enum value maps for ContentType. +var ( + ContentType_name = map[int32]string{ + 0: "CONTENT_TYPE_RAW_UNSPECIFIED", + 1: "CONTENT_TYPE_ZIP", + } + ContentType_value = map[string]int32{ + "CONTENT_TYPE_RAW_UNSPECIFIED": 0, + "CONTENT_TYPE_ZIP": 1, + } +) + +func (x ContentType) Enum() *ContentType { + p := new(ContentType) + *p = x + return p +} + +func (x ContentType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ContentType) Descriptor() protoreflect.EnumDescriptor { + return file_cc_arduino_cli_files_v1_files_proto_enumTypes[0].Descriptor() +} + +func (ContentType) Type() protoreflect.EnumType { + return &file_cc_arduino_cli_files_v1_files_proto_enumTypes[0] +} + +func (x ContentType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ContentType.Descriptor instead. +func (ContentType) EnumDescriptor() ([]byte, []int) { + return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{0} +} + +type LoadFileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // path as it's returned in LoadSketchResponse for instance + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + // Optional + Type ContentType `protobuf:"varint,2,opt,name=type,proto3,enum=cc.arduino.cli.files.v1.ContentType" json:"type,omitempty"` +} + +func (x *LoadFileRequest) Reset() { + *x = LoadFileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoadFileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoadFileRequest) ProtoMessage() {} + +func (x *LoadFileRequest) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoadFileRequest.ProtoReflect.Descriptor instead. +func (*LoadFileRequest) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{0} +} + +func (x *LoadFileRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *LoadFileRequest) GetType() ContentType { + if x != nil { + return x.Type + } + return ContentType_CONTENT_TYPE_RAW_UNSPECIFIED +} + +type LoadFileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Message: + // *LoadFileResponse_Content + // *LoadFileResponse_Error + Message isLoadFileResponse_Message `protobuf_oneof:"message"` + // is skipped in case of error + Type ContentType `protobuf:"varint,3,opt,name=type,proto3,enum=cc.arduino.cli.files.v1.ContentType" json:"type,omitempty"` +} + +func (x *LoadFileResponse) Reset() { + *x = LoadFileResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoadFileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoadFileResponse) ProtoMessage() {} + +func (x *LoadFileResponse) ProtoReflect() protoreflect.Message { + mi := &file_cc_arduino_cli_files_v1_files_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoadFileResponse.ProtoReflect.Descriptor instead. +func (*LoadFileResponse) Descriptor() ([]byte, []int) { + return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{1} +} + +func (m *LoadFileResponse) GetMessage() isLoadFileResponse_Message { + if m != nil { + return m.Message + } + return nil +} + +func (x *LoadFileResponse) GetContent() []byte { + if x, ok := x.GetMessage().(*LoadFileResponse_Content); ok { + return x.Content + } + return nil +} + +func (x *LoadFileResponse) GetError() *status.Status { + if x, ok := x.GetMessage().(*LoadFileResponse_Error); ok { + return x.Error + } + return nil +} + +func (x *LoadFileResponse) GetType() ContentType { + if x != nil { + return x.Type + } + return ContentType_CONTENT_TYPE_RAW_UNSPECIFIED +} + +type isLoadFileResponse_Message interface { + isLoadFileResponse_Message() +} + +type LoadFileResponse_Content struct { + Content []byte `protobuf:"bytes,1,opt,name=content,proto3,oneof"` +} + +type LoadFileResponse_Error struct { + Error *status.Status `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*LoadFileResponse_Content) isLoadFileResponse_Message() {} + +func (*LoadFileResponse_Error) isLoadFileResponse_Message() {} + +var File_cc_arduino_cli_files_v1_files_proto protoreflect.FileDescriptor + +var file_cc_arduino_cli_files_v1_files_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, + 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x17, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5f, 0x0a, 0x0f, 0x4c, 0x6f, 0x61, 0x64, 0x46, + 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x38, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, + 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x9f, 0x01, 0x0a, 0x10, 0x4c, 0x6f, 0x61, + 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, + 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, + 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x42, + 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x45, 0x0a, 0x0b, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x4f, 0x4e, + 0x54, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x41, 0x57, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, + 0x4f, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x5a, 0x49, 0x50, 0x10, + 0x01, 0x32, 0x71, 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x61, 0x0a, 0x08, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x28, 0x2e, + 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, + 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, + 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, + 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, + 0x76, 0x31, 0x3b, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cc_arduino_cli_files_v1_files_proto_rawDescOnce sync.Once + file_cc_arduino_cli_files_v1_files_proto_rawDescData = file_cc_arduino_cli_files_v1_files_proto_rawDesc +) + +func file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP() []byte { + file_cc_arduino_cli_files_v1_files_proto_rawDescOnce.Do(func() { + file_cc_arduino_cli_files_v1_files_proto_rawDescData = protoimpl.X.CompressGZIP(file_cc_arduino_cli_files_v1_files_proto_rawDescData) + }) + return file_cc_arduino_cli_files_v1_files_proto_rawDescData +} + +var file_cc_arduino_cli_files_v1_files_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_cc_arduino_cli_files_v1_files_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cc_arduino_cli_files_v1_files_proto_goTypes = []interface{}{ + (ContentType)(0), // 0: cc.arduino.cli.files.v1.ContentType + (*LoadFileRequest)(nil), // 1: cc.arduino.cli.files.v1.LoadFileRequest + (*LoadFileResponse)(nil), // 2: cc.arduino.cli.files.v1.LoadFileResponse + (*status.Status)(nil), // 3: google.rpc.Status +} +var file_cc_arduino_cli_files_v1_files_proto_depIdxs = []int32{ + 0, // 0: cc.arduino.cli.files.v1.LoadFileRequest.type:type_name -> cc.arduino.cli.files.v1.ContentType + 3, // 1: cc.arduino.cli.files.v1.LoadFileResponse.error:type_name -> google.rpc.Status + 0, // 2: cc.arduino.cli.files.v1.LoadFileResponse.type:type_name -> cc.arduino.cli.files.v1.ContentType + 1, // 3: cc.arduino.cli.files.v1.FilesService.LoadFile:input_type -> cc.arduino.cli.files.v1.LoadFileRequest + 2, // 4: cc.arduino.cli.files.v1.FilesService.LoadFile:output_type -> cc.arduino.cli.files.v1.LoadFileResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] 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_cc_arduino_cli_files_v1_files_proto_init() } +func file_cc_arduino_cli_files_v1_files_proto_init() { + if File_cc_arduino_cli_files_v1_files_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cc_arduino_cli_files_v1_files_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoadFileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cc_arduino_cli_files_v1_files_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoadFileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_cc_arduino_cli_files_v1_files_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*LoadFileResponse_Content)(nil), + (*LoadFileResponse_Error)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cc_arduino_cli_files_v1_files_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_cc_arduino_cli_files_v1_files_proto_goTypes, + DependencyIndexes: file_cc_arduino_cli_files_v1_files_proto_depIdxs, + EnumInfos: file_cc_arduino_cli_files_v1_files_proto_enumTypes, + MessageInfos: file_cc_arduino_cli_files_v1_files_proto_msgTypes, + }.Build() + File_cc_arduino_cli_files_v1_files_proto = out.File + file_cc_arduino_cli_files_v1_files_proto_rawDesc = nil + file_cc_arduino_cli_files_v1_files_proto_goTypes = nil + file_cc_arduino_cli_files_v1_files_proto_depIdxs = nil +} diff --git a/rpc/cc/arduino/cli/commands/v1/files.proto b/rpc/cc/arduino/cli/files/v1/files.proto similarity index 88% rename from rpc/cc/arduino/cli/commands/v1/files.proto rename to rpc/cc/arduino/cli/files/v1/files.proto index 50b42e0be2f..ff4644fc5cc 100644 --- a/rpc/cc/arduino/cli/commands/v1/files.proto +++ b/rpc/cc/arduino/cli/files/v1/files.proto @@ -15,21 +15,21 @@ syntax = "proto3"; -package cc.arduino.cli.commands.v1; +package cc.arduino.cli.files.v1; -option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1;files"; +option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1;files"; import "google/rpc/status.proto"; -// Arduino File System service API -service ArduinoFileSystemService { +// Arduino Files service API +service FilesService { // Load file content from the file system rpc LoadFile(LoadFileRequest) returns (LoadFileResponse) {} } enum ContentType { - RAW = 0; - ZIP = 1; + CONTENT_TYPE_RAW_UNSPECIFIED = 0; + CONTENT_TYPE_ZIP = 1; } message LoadFileRequest { diff --git a/rpc/cc/arduino/cli/files/v1/files_grpc.pb.go b/rpc/cc/arduino/cli/files/v1/files_grpc.pb.go new file mode 100644 index 00000000000..3d6fa97ec14 --- /dev/null +++ b/rpc/cc/arduino/cli/files/v1/files_grpc.pb.go @@ -0,0 +1,103 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package files + +import ( + context "context" + 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 + +// FilesServiceClient is the client API for FilesService 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 FilesServiceClient interface { + // Load file content from the file system + LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) +} + +type filesServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewFilesServiceClient(cc grpc.ClientConnInterface) FilesServiceClient { + return &filesServiceClient{cc} +} + +func (c *filesServiceClient) LoadFile(ctx context.Context, in *LoadFileRequest, opts ...grpc.CallOption) (*LoadFileResponse, error) { + out := new(LoadFileResponse) + err := c.cc.Invoke(ctx, "/cc.arduino.cli.files.v1.FilesService/LoadFile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// FilesServiceServer is the server API for FilesService service. +// All implementations must embed UnimplementedFilesServiceServer +// for forward compatibility +type FilesServiceServer interface { + // Load file content from the file system + LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) + mustEmbedUnimplementedFilesServiceServer() +} + +// UnimplementedFilesServiceServer must be embedded to have forward compatible implementations. +type UnimplementedFilesServiceServer struct { +} + +func (UnimplementedFilesServiceServer) LoadFile(context.Context, *LoadFileRequest) (*LoadFileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoadFile not implemented") +} +func (UnimplementedFilesServiceServer) mustEmbedUnimplementedFilesServiceServer() {} + +// UnsafeFilesServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to FilesServiceServer will +// result in compilation errors. +type UnsafeFilesServiceServer interface { + mustEmbedUnimplementedFilesServiceServer() +} + +func RegisterFilesServiceServer(s grpc.ServiceRegistrar, srv FilesServiceServer) { + s.RegisterService(&FilesService_ServiceDesc, srv) +} + +func _FilesService_LoadFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoadFileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FilesServiceServer).LoadFile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cc.arduino.cli.files.v1.FilesService/LoadFile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FilesServiceServer).LoadFile(ctx, req.(*LoadFileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// FilesService_ServiceDesc is the grpc.ServiceDesc for FilesService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var FilesService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cc.arduino.cli.files.v1.FilesService", + HandlerType: (*FilesServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LoadFile", + Handler: _FilesService_LoadFile_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cc/arduino/cli/files/v1/files.proto", +} From b9bebad5e36234162e0db38a549527da4d5f0cf9 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Thu, 4 Nov 2021 11:59:40 +0500 Subject: [PATCH 3/5] #1447 - back-end usage scenario Simplify API (remove error) --- rpc/cc/arduino/cli/files/v1/files.pb.go | 124 ++++++++---------------- rpc/cc/arduino/cli/files/v1/files.proto | 10 +- 2 files changed, 43 insertions(+), 91 deletions(-) diff --git a/rpc/cc/arduino/cli/files/v1/files.pb.go b/rpc/cc/arduino/cli/files/v1/files.pb.go index 7ea284375e6..7338eb3b77b 100644 --- a/rpc/cc/arduino/cli/files/v1/files.pb.go +++ b/rpc/cc/arduino/cli/files/v1/files.pb.go @@ -22,7 +22,6 @@ package files import ( - status "google.golang.org/genproto/googleapis/rpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -144,12 +143,10 @@ type LoadFileResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Types that are assignable to Message: - // *LoadFileResponse_Content - // *LoadFileResponse_Error - Message isLoadFileResponse_Message `protobuf_oneof:"message"` + // File content + Content []byte `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"` // is skipped in case of error - Type ContentType `protobuf:"varint,3,opt,name=type,proto3,enum=cc.arduino.cli.files.v1.ContentType" json:"type,omitempty"` + Type ContentType `protobuf:"varint,2,opt,name=type,proto3,enum=cc.arduino.cli.files.v1.ContentType" json:"type,omitempty"` } func (x *LoadFileResponse) Reset() { @@ -184,27 +181,13 @@ func (*LoadFileResponse) Descriptor() ([]byte, []int) { return file_cc_arduino_cli_files_v1_files_proto_rawDescGZIP(), []int{1} } -func (m *LoadFileResponse) GetMessage() isLoadFileResponse_Message { - if m != nil { - return m.Message - } - return nil -} - func (x *LoadFileResponse) GetContent() []byte { - if x, ok := x.GetMessage().(*LoadFileResponse_Content); ok { + if x != nil { return x.Content } return nil } -func (x *LoadFileResponse) GetError() *status.Status { - if x, ok := x.GetMessage().(*LoadFileResponse_Error); ok { - return x.Error - } - return nil -} - func (x *LoadFileResponse) GetType() ContentType { if x != nil { return x.Type @@ -212,63 +195,42 @@ func (x *LoadFileResponse) GetType() ContentType { return ContentType_CONTENT_TYPE_RAW_UNSPECIFIED } -type isLoadFileResponse_Message interface { - isLoadFileResponse_Message() -} - -type LoadFileResponse_Content struct { - Content []byte `protobuf:"bytes,1,opt,name=content,proto3,oneof"` -} - -type LoadFileResponse_Error struct { - Error *status.Status `protobuf:"bytes,2,opt,name=error,proto3,oneof"` -} - -func (*LoadFileResponse_Content) isLoadFileResponse_Message() {} - -func (*LoadFileResponse_Error) isLoadFileResponse_Message() {} - var File_cc_arduino_cli_files_v1_files_proto protoreflect.FileDescriptor var file_cc_arduino_cli_files_v1_files_proto_rawDesc = []byte{ 0x0a, 0x23, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, - 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x17, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5f, 0x0a, 0x0f, 0x4c, 0x6f, 0x61, 0x64, 0x46, - 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x38, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, - 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, - 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x9f, 0x01, 0x0a, 0x10, 0x4c, 0x6f, 0x61, - 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, - 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, - 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, + 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x5f, + 0x0a, 0x0f, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x42, - 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x45, 0x0a, 0x0b, 0x43, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x4f, 0x4e, - 0x54, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x41, 0x57, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, - 0x4f, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x5a, 0x49, 0x50, 0x10, - 0x01, 0x32, 0x71, 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x61, 0x0a, 0x08, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x28, 0x2e, - 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, - 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, - 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, - 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, - 0x76, 0x31, 0x3b, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, + 0x66, 0x0a, 0x10, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x38, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x63, + 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x2a, 0x45, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x4e, + 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x41, 0x57, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x4e, 0x54, + 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x5a, 0x49, 0x50, 0x10, 0x01, 0x32, 0x71, + 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x61, + 0x0a, 0x08, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x28, 0x2e, 0x63, 0x63, 0x2e, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, + 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, + 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, + 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -289,19 +251,17 @@ var file_cc_arduino_cli_files_v1_files_proto_goTypes = []interface{}{ (ContentType)(0), // 0: cc.arduino.cli.files.v1.ContentType (*LoadFileRequest)(nil), // 1: cc.arduino.cli.files.v1.LoadFileRequest (*LoadFileResponse)(nil), // 2: cc.arduino.cli.files.v1.LoadFileResponse - (*status.Status)(nil), // 3: google.rpc.Status } var file_cc_arduino_cli_files_v1_files_proto_depIdxs = []int32{ 0, // 0: cc.arduino.cli.files.v1.LoadFileRequest.type:type_name -> cc.arduino.cli.files.v1.ContentType - 3, // 1: cc.arduino.cli.files.v1.LoadFileResponse.error:type_name -> google.rpc.Status - 0, // 2: cc.arduino.cli.files.v1.LoadFileResponse.type:type_name -> cc.arduino.cli.files.v1.ContentType - 1, // 3: cc.arduino.cli.files.v1.FilesService.LoadFile:input_type -> cc.arduino.cli.files.v1.LoadFileRequest - 2, // 4: cc.arduino.cli.files.v1.FilesService.LoadFile:output_type -> cc.arduino.cli.files.v1.LoadFileResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] 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 + 0, // 1: cc.arduino.cli.files.v1.LoadFileResponse.type:type_name -> cc.arduino.cli.files.v1.ContentType + 1, // 2: cc.arduino.cli.files.v1.FilesService.LoadFile:input_type -> cc.arduino.cli.files.v1.LoadFileRequest + 2, // 3: cc.arduino.cli.files.v1.FilesService.LoadFile:output_type -> cc.arduino.cli.files.v1.LoadFileResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_cc_arduino_cli_files_v1_files_proto_init() } @@ -335,10 +295,6 @@ func file_cc_arduino_cli_files_v1_files_proto_init() { } } } - file_cc_arduino_cli_files_v1_files_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*LoadFileResponse_Content)(nil), - (*LoadFileResponse_Error)(nil), - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/rpc/cc/arduino/cli/files/v1/files.proto b/rpc/cc/arduino/cli/files/v1/files.proto index ff4644fc5cc..fa9d1180620 100644 --- a/rpc/cc/arduino/cli/files/v1/files.proto +++ b/rpc/cc/arduino/cli/files/v1/files.proto @@ -19,8 +19,6 @@ package cc.arduino.cli.files.v1; option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1;files"; -import "google/rpc/status.proto"; - // Arduino Files service API service FilesService { // Load file content from the file system @@ -40,10 +38,8 @@ message LoadFileRequest { } message LoadFileResponse { - oneof message { - bytes content = 1; - google.rpc.Status error = 2; - } + // File content + bytes content = 1; // is skipped in case of error - ContentType type = 3; + ContentType type = 2; } From 97a231ffcd1a4163bc24046a412860f9aff895a1 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Thu, 4 Nov 2021 12:45:44 +0500 Subject: [PATCH 4/5] #1447 - back-end usage scenario Add `FilesService` impl. --- cli/daemon/daemon.go | 4 ++++ commands/daemon/files.go | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 commands/daemon/files.go diff --git a/cli/daemon/daemon.go b/cli/daemon/daemon.go index 489c36d7edf..56bb6524edf 100644 --- a/cli/daemon/daemon.go +++ b/cli/daemon/daemon.go @@ -33,6 +33,7 @@ import ( "github.com/arduino/arduino-cli/metrics" srv_commands "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" srv_debug "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1" + srv_files "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1" srv_monitor "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/monitor/v1" srv_settings "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1" "github.com/segmentio/stats/v4" @@ -98,6 +99,9 @@ func runDaemonCommand(cmd *cobra.Command, args []string) { // Register the debug session service srv_debug.RegisterDebugServiceServer(s, &daemon.DebugService{}) + // Register the files service + srv_files.RegisterFilesServiceServer(s, &daemon.FilesService{}) + if !daemonize { // When parent process ends terminate also the daemon go func() { diff --git a/commands/daemon/files.go b/commands/daemon/files.go new file mode 100644 index 00000000000..0fdfdb99655 --- /dev/null +++ b/commands/daemon/files.go @@ -0,0 +1,41 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +package daemon + +import ( + "context" + "os" + + rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1" +) + +// FilesService implements the `Files` service +type FilesService struct { + rpc.UnimplementedFilesServiceServer +} + +// LoadFile returns a requested file content or an error. +func (s *FilesService) LoadFile(ctx context.Context, req *rpc.LoadFileRequest) (*rpc.LoadFileResponse, error) { + content, err := os.ReadFile(req.Path) + if err == nil { + return &rpc.LoadFileResponse{ + Content: content, + Type: rpc.ContentType_CONTENT_TYPE_RAW_UNSPECIFIED, + }, nil + } + + return nil, err +} From 32b704738f2b14c8829e0d413f5b275cac8bbf44 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Thu, 4 Nov 2021 15:27:10 +0500 Subject: [PATCH 5/5] #1447 - back-end usage scenario Add TODO (Type support). --- commands/daemon/files.go | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/daemon/files.go b/commands/daemon/files.go index 0fdfdb99655..b9d662daafc 100644 --- a/commands/daemon/files.go +++ b/commands/daemon/files.go @@ -30,6 +30,7 @@ type FilesService struct { // LoadFile returns a requested file content or an error. func (s *FilesService) LoadFile(ctx context.Context, req *rpc.LoadFileRequest) (*rpc.LoadFileResponse, error) { content, err := os.ReadFile(req.Path) + // TODO: support req.Type other than RAW or remove Type from .proto if err == nil { return &rpc.LoadFileResponse{ Content: content,