├── .gitignore ├── README.md ├── cmd_download.go ├── cmd_list.go ├── cmd_serve.go ├── main.go ├── proto ├── doc.go ├── filetransfer_service.pb.go ├── filetransfer_service.proto └── include │ └── google │ └── protobuf │ ├── any.proto │ ├── api.proto │ ├── compiler │ └── plugin.proto │ ├── descriptor.proto │ ├── duration.proto │ ├── empty.proto │ ├── field_mask.proto │ ├── source_context.proto │ ├── struct.proto │ ├── timestamp.proto │ ├── type.proto │ └── wrappers.proto └── screenshot.gif /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ft - File Transferer 2 | 3 | ft is CLI tool that transfer files. 4 | 5 | ![ft](https://raw.githubusercontent.com/mattn/ft/master/screenshot.gif) 6 | 7 | ## Usage 8 | 9 | serve files 10 | 11 | ``` 12 | $ ft serve 13 | ``` 14 | 15 | download from server 16 | 17 | ``` 18 | $ ft download -a 192.168.123.4 19 | ``` 20 | 21 | ## Installation 22 | 23 | ``` 24 | $ go install github.com/mattn/ft@latest 25 | ``` 26 | 27 | ## License 28 | 29 | MIT 30 | 31 | ## Author 32 | 33 | Yasuhiro Matsumoto (a.k.a. mattn) 34 | -------------------------------------------------------------------------------- /cmd_download.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "io" 6 | "log" 7 | "os" 8 | "path/filepath" 9 | "runtime" 10 | "strings" 11 | "sync" 12 | "time" 13 | 14 | "github.com/cheggaaa/pb" 15 | proto "github.com/mattn/ft/proto" 16 | "github.com/urfave/cli" 17 | "google.golang.org/grpc" 18 | "google.golang.org/grpc/credentials" 19 | ) 20 | 21 | type downloader struct { 22 | dir string 23 | client proto.FileTransferServiceClient 24 | ctx context.Context 25 | wg sync.WaitGroup 26 | requests chan *proto.ListResponseType 27 | pool *pb.Pool 28 | } 29 | 30 | func NewDownloader(ctx context.Context, client proto.FileTransferServiceClient, dir string) *downloader { 31 | d := &downloader{ 32 | ctx: ctx, 33 | client: client, 34 | dir: dir, 35 | requests: make(chan *proto.ListResponseType), 36 | } 37 | for i := 0; i < 5; i++ { 38 | d.wg.Add(1) 39 | go d.worker() 40 | } 41 | d.pool, _ = pb.StartPool() 42 | return d 43 | } 44 | 45 | func (d *downloader) Stop() { 46 | close(d.requests) 47 | d.wg.Wait() 48 | d.pool.RefreshRate = 500 * time.Millisecond 49 | d.pool.Stop() 50 | } 51 | 52 | func (d *downloader) worker() { 53 | defer d.wg.Done() 54 | 55 | for request := range d.requests { 56 | name := filepath.Join(d.dir, filepath.FromSlash(request.Name)) 57 | if os.FileMode(request.Mode).IsDir() { 58 | err := os.MkdirAll(name, os.FileMode(request.Mode)) 59 | if err == nil { 60 | t := time.Unix(request.ModTime.Seconds, int64(request.ModTime.Nanos)) 61 | err = os.Chtimes(name, t, t) 62 | } 63 | if err != nil { 64 | log.Printf("%s: %v", request.Name, err) 65 | } 66 | continue 67 | } 68 | 69 | req := &proto.DownloadRequestType{ 70 | Name: request.Name, 71 | } 72 | sdown, err := d.client.Download(d.ctx, req) 73 | if err != nil { 74 | log.Printf("%s: %v", request.Name, err) 75 | continue 76 | } 77 | 78 | f, err := os.Create(name) 79 | if err != nil { 80 | log.Printf("%s: %v", request.Name, err) 81 | sdown.CloseSend() 82 | continue 83 | } 84 | 85 | bar := pb.New64(request.Size).Postfix(" " + request.Name) 86 | bar.Units = pb.U_BYTES 87 | d.pool.Add(bar) 88 | for { 89 | res, err := sdown.Recv() 90 | if err != nil { 91 | if err == io.EOF { 92 | break 93 | } 94 | log.Printf("%s: %v", request.Name, err) 95 | break 96 | } 97 | n, err := f.Write(res.Data) 98 | if err != nil { 99 | log.Printf("%s: %v", request.Name, err) 100 | break 101 | } 102 | bar.Add64(int64(n)) 103 | } 104 | bar.Finish() 105 | f.Close() 106 | sdown.CloseSend() 107 | 108 | if err == nil && runtime.GOOS != "windows" { 109 | err = os.Chmod(name, os.FileMode(request.Mode)) 110 | if err != nil { 111 | log.Printf("%s: %v", request.Name, err) 112 | } 113 | } 114 | if err == nil { 115 | t := time.Unix(request.ModTime.Seconds, int64(request.ModTime.Nanos)) 116 | err = os.Chtimes(name, t, t) 117 | } 118 | if err != nil { 119 | log.Printf("%s: %v", request.Name, err) 120 | } 121 | } 122 | } 123 | 124 | func (d *downloader) Do(file *proto.ListResponseType) { 125 | d.requests <- file 126 | } 127 | 128 | func downloadFiles(ctx context.Context, client proto.FileTransferServiceClient, dir string) error { 129 | slist, err := client.ListFiles(ctx, new(proto.ListRequestType)) 130 | if err != nil { 131 | log.Fatal(err) 132 | return err 133 | } 134 | 135 | d := NewDownloader(ctx, client, dir) 136 | for { 137 | file, err := slist.Recv() 138 | if err != nil { 139 | if err == io.EOF { 140 | break 141 | } 142 | break 143 | } 144 | d.Do(file) 145 | } 146 | slist.CloseSend() 147 | d.Stop() 148 | 149 | return err 150 | } 151 | 152 | func downloadCommand() cli.Command { 153 | return cli.Command{ 154 | Name: "download", 155 | Usage: "download files from server", 156 | Flags: []cli.Flag{ 157 | cli.StringFlag{ 158 | Name: "a", 159 | Value: ":11111", 160 | Usage: "server address", 161 | }, 162 | cli.StringFlag{ 163 | Name: "d", 164 | Value: ".", 165 | Usage: "base directory", 166 | }, 167 | cli.StringFlag{ 168 | Name: "tls-path", 169 | Value: "", 170 | Usage: "directory to the TLS server.crt file", 171 | }, 172 | }, 173 | Action: func(c *cli.Context) error { 174 | options := []grpc.DialOption{} 175 | if p := c.String("tls-path"); p != "" { 176 | creds, err := credentials.NewClientTLSFromFile( 177 | filepath.Join(p, "server.crt"), 178 | "") 179 | if err != nil { 180 | log.Println(err) 181 | return err 182 | } 183 | options = append(options, grpc.WithTransportCredentials(creds)) 184 | } else { 185 | options = append(options, grpc.WithInsecure()) 186 | } 187 | addr := c.String("a") 188 | if !strings.Contains(addr, ":") { 189 | addr += ":11111" 190 | } 191 | conn, err := grpc.Dial(addr, options...) 192 | if err != nil { 193 | log.Fatalf("cannot connect: %v", err) 194 | } 195 | defer conn.Close() 196 | 197 | return downloadFiles(context.Background(), proto.NewFileTransferServiceClient(conn), c.String("d")) 198 | }, 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /cmd_list.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "log" 7 | "os" 8 | "path/filepath" 9 | "strings" 10 | "time" 11 | 12 | proto "github.com/mattn/ft/proto" 13 | "github.com/urfave/cli" 14 | "google.golang.org/grpc" 15 | "google.golang.org/grpc/credentials" 16 | ) 17 | 18 | func listFiles(ctx context.Context, client proto.FileTransferServiceClient) error { 19 | slist, err := client.ListFiles(ctx, new(proto.ListRequestType)) 20 | if err != nil { 21 | return err 22 | } 23 | fmt.Println("name,size,mode,modtime") 24 | for { 25 | file, err := slist.Recv() 26 | if err != nil { 27 | break 28 | } 29 | fmt.Printf("%q,\"%v\",\"%v\",\"%v\"\n", 30 | file.Name, file.Size, os.FileMode(file.Mode), time.Unix(file.ModTime.Seconds, 0).Format(time.RFC3339)) 31 | } 32 | slist.CloseSend() 33 | return err 34 | } 35 | 36 | func listCommand() cli.Command { 37 | return cli.Command{ 38 | Name: "list", 39 | Usage: "list files from server by CSV format", 40 | Flags: []cli.Flag{ 41 | cli.StringFlag{ 42 | Name: "a", 43 | Value: ":11111", 44 | Usage: "server address", 45 | }, 46 | cli.StringFlag{ 47 | Name: "tls-path", 48 | Value: "", 49 | Usage: "directory to the TLS server.crt file", 50 | }, 51 | }, 52 | Action: func(c *cli.Context) error { 53 | options := []grpc.DialOption{} 54 | if p := c.String("tls-path"); p != "" { 55 | creds, err := credentials.NewClientTLSFromFile( 56 | filepath.Join(p, "server.crt"), 57 | "") 58 | if err != nil { 59 | log.Println(err) 60 | return err 61 | } 62 | options = append(options, grpc.WithTransportCredentials(creds)) 63 | } else { 64 | options = append(options, grpc.WithInsecure()) 65 | } 66 | addr := c.String("a") 67 | if !strings.Contains(addr, ":") { 68 | addr += ":11111" 69 | } 70 | conn, err := grpc.Dial(addr, options...) 71 | if err != nil { 72 | log.Fatalf("cannot connect: %v", err) 73 | } 74 | defer conn.Close() 75 | 76 | return listFiles(context.Background(), proto.NewFileTransferServiceClient(conn)) 77 | }, 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /cmd_serve.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "log" 6 | "net" 7 | "os" 8 | "path/filepath" 9 | 10 | google_protobuf "github.com/golang/protobuf/ptypes/timestamp" 11 | proto "github.com/mattn/ft/proto" 12 | "github.com/urfave/cli" 13 | "google.golang.org/grpc" 14 | "google.golang.org/grpc/credentials" 15 | ) 16 | 17 | type fileTransferService struct { 18 | root string 19 | } 20 | 21 | func (fts *fileTransferService) ListFiles(_ *proto.ListRequestType, stream proto.FileTransferService_ListFilesServer) error { 22 | err := filepath.Walk(fts.root, func(p string, info os.FileInfo, err error) error { 23 | name, err := filepath.Rel(fts.root, p) 24 | if err != nil { 25 | return err 26 | } 27 | name = filepath.ToSlash(name) 28 | modTime := new(google_protobuf.Timestamp) 29 | modTime.Seconds = int64(info.ModTime().Unix()) 30 | modTime.Nanos = int32(info.ModTime().UnixNano()) 31 | f := &proto.ListResponseType{Name: name, Size: info.Size(), Mode: uint32(info.Mode()), ModTime: modTime} 32 | return stream.Send(f) 33 | }) 34 | return err 35 | } 36 | 37 | func (fts *fileTransferService) Download(r *proto.DownloadRequestType, stream proto.FileTransferService_DownloadServer) error { 38 | f, err := os.Open(filepath.Join(fts.root, r.Name)) 39 | if err != nil { 40 | return err 41 | } 42 | defer f.Close() 43 | 44 | var b [4096 * 1000]byte 45 | for { 46 | n, err := f.Read(b[:]) 47 | if err != nil { 48 | if err != io.EOF { 49 | return err 50 | } 51 | break 52 | } 53 | err = stream.Send(&proto.DownloadResponseType{ 54 | Data: b[:n], 55 | }) 56 | if err != nil { 57 | return err 58 | } 59 | } 60 | return nil 61 | } 62 | 63 | func serveCommand() cli.Command { 64 | return cli.Command{ 65 | Name: "serve", 66 | Usage: "serve files", 67 | Flags: []cli.Flag{ 68 | cli.StringFlag{ 69 | Name: "a", 70 | Value: ":11111", 71 | Usage: "server address", 72 | }, 73 | cli.StringFlag{ 74 | Name: "d", 75 | Value: ".", 76 | Usage: "base directory", 77 | }, 78 | cli.StringFlag{ 79 | Name: "tls-path", 80 | Value: "", 81 | Usage: "directory to the TLS server.crt/server.key file", 82 | }, 83 | }, 84 | Action: func(c *cli.Context) error { 85 | lis, err := net.Listen("tcp", c.String("a")) 86 | if err != nil { 87 | log.Fatalf("cannot listen: %v", err) 88 | } 89 | defer lis.Close() 90 | 91 | options := []grpc.ServerOption{} 92 | if p := c.String("tls-path"); p != "" { 93 | creds, err := credentials.NewServerTLSFromFile( 94 | filepath.Join(p, "server.crt"), 95 | filepath.Join(p, "server.key")) 96 | if err != nil { 97 | log.Println(err) 98 | return err 99 | } 100 | options = append(options, grpc.Creds(creds)) 101 | } 102 | 103 | log.Println("server started:", lis.Addr().String()) 104 | server := grpc.NewServer(options...) 105 | proto.RegisterFileTransferServiceServer(server, &fileTransferService{root: c.String("d")}) 106 | return server.Serve(lis) 107 | }, 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/urfave/cli" 7 | ) 8 | 9 | func main() { 10 | app := cli.NewApp() 11 | app.Name = "ft" 12 | app.Usage = "File Transferer" 13 | app.Version = "0.0.2" 14 | app.Commands = []cli.Command{ 15 | downloadCommand(), 16 | serveCommand(), 17 | listCommand(), 18 | } 19 | app.Run(os.Args) 20 | } 21 | -------------------------------------------------------------------------------- /proto/doc.go: -------------------------------------------------------------------------------- 1 | package proto 2 | 3 | //go:generate go get github.com/golang/protobuf/protoc-gen-go 4 | //go:generate protoc -Iinclude -I. --go_out=plugins=grpc:. filetransfer_service.proto 5 | -------------------------------------------------------------------------------- /proto/filetransfer_service.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: filetransfer_service.proto 3 | 4 | /* 5 | Package proto is a generated protocol buffer package. 6 | 7 | It is generated from these files: 8 | filetransfer_service.proto 9 | 10 | It has these top-level messages: 11 | ListRequestType 12 | ListResponseType 13 | DownloadRequestType 14 | DownloadResponseType 15 | */ 16 | package proto 17 | 18 | import proto1 "github.com/golang/protobuf/proto" 19 | import fmt "fmt" 20 | import math "math" 21 | import google_protobuf "github.com/golang/protobuf/ptypes/timestamp" 22 | 23 | import ( 24 | context "golang.org/x/net/context" 25 | grpc "google.golang.org/grpc" 26 | ) 27 | 28 | // Reference imports to suppress errors if they are not otherwise used. 29 | var _ = proto1.Marshal 30 | var _ = fmt.Errorf 31 | var _ = math.Inf 32 | 33 | // This is a compile-time assertion to ensure that this generated file 34 | // is compatible with the proto package it is being compiled against. 35 | // A compilation error at this line likely means your copy of the 36 | // proto package needs to be updated. 37 | const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package 38 | 39 | type ListRequestType struct { 40 | } 41 | 42 | func (m *ListRequestType) Reset() { *m = ListRequestType{} } 43 | func (m *ListRequestType) String() string { return proto1.CompactTextString(m) } 44 | func (*ListRequestType) ProtoMessage() {} 45 | func (*ListRequestType) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 46 | 47 | type ListResponseType struct { 48 | Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` 49 | Size int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"` 50 | Mode uint32 `protobuf:"varint,3,opt,name=mode" json:"mode,omitempty"` 51 | ModTime *google_protobuf.Timestamp `protobuf:"bytes,4,opt,name=modTime" json:"modTime,omitempty"` 52 | } 53 | 54 | func (m *ListResponseType) Reset() { *m = ListResponseType{} } 55 | func (m *ListResponseType) String() string { return proto1.CompactTextString(m) } 56 | func (*ListResponseType) ProtoMessage() {} 57 | func (*ListResponseType) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } 58 | 59 | func (m *ListResponseType) GetName() string { 60 | if m != nil { 61 | return m.Name 62 | } 63 | return "" 64 | } 65 | 66 | func (m *ListResponseType) GetSize() int64 { 67 | if m != nil { 68 | return m.Size 69 | } 70 | return 0 71 | } 72 | 73 | func (m *ListResponseType) GetMode() uint32 { 74 | if m != nil { 75 | return m.Mode 76 | } 77 | return 0 78 | } 79 | 80 | func (m *ListResponseType) GetModTime() *google_protobuf.Timestamp { 81 | if m != nil { 82 | return m.ModTime 83 | } 84 | return nil 85 | } 86 | 87 | type DownloadRequestType struct { 88 | Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` 89 | } 90 | 91 | func (m *DownloadRequestType) Reset() { *m = DownloadRequestType{} } 92 | func (m *DownloadRequestType) String() string { return proto1.CompactTextString(m) } 93 | func (*DownloadRequestType) ProtoMessage() {} 94 | func (*DownloadRequestType) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } 95 | 96 | func (m *DownloadRequestType) GetName() string { 97 | if m != nil { 98 | return m.Name 99 | } 100 | return "" 101 | } 102 | 103 | type DownloadResponseType struct { 104 | Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` 105 | } 106 | 107 | func (m *DownloadResponseType) Reset() { *m = DownloadResponseType{} } 108 | func (m *DownloadResponseType) String() string { return proto1.CompactTextString(m) } 109 | func (*DownloadResponseType) ProtoMessage() {} 110 | func (*DownloadResponseType) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } 111 | 112 | func (m *DownloadResponseType) GetData() []byte { 113 | if m != nil { 114 | return m.Data 115 | } 116 | return nil 117 | } 118 | 119 | func init() { 120 | proto1.RegisterType((*ListRequestType)(nil), "proto.ListRequestType") 121 | proto1.RegisterType((*ListResponseType)(nil), "proto.ListResponseType") 122 | proto1.RegisterType((*DownloadRequestType)(nil), "proto.DownloadRequestType") 123 | proto1.RegisterType((*DownloadResponseType)(nil), "proto.DownloadResponseType") 124 | } 125 | 126 | // Reference imports to suppress errors if they are not otherwise used. 127 | var _ context.Context 128 | var _ grpc.ClientConn 129 | 130 | // This is a compile-time assertion to ensure that this generated file 131 | // is compatible with the grpc package it is being compiled against. 132 | const _ = grpc.SupportPackageIsVersion4 133 | 134 | // Client API for FileTransferService service 135 | 136 | type FileTransferServiceClient interface { 137 | ListFiles(ctx context.Context, in *ListRequestType, opts ...grpc.CallOption) (FileTransferService_ListFilesClient, error) 138 | Download(ctx context.Context, in *DownloadRequestType, opts ...grpc.CallOption) (FileTransferService_DownloadClient, error) 139 | } 140 | 141 | type fileTransferServiceClient struct { 142 | cc *grpc.ClientConn 143 | } 144 | 145 | func NewFileTransferServiceClient(cc *grpc.ClientConn) FileTransferServiceClient { 146 | return &fileTransferServiceClient{cc} 147 | } 148 | 149 | func (c *fileTransferServiceClient) ListFiles(ctx context.Context, in *ListRequestType, opts ...grpc.CallOption) (FileTransferService_ListFilesClient, error) { 150 | stream, err := grpc.NewClientStream(ctx, &_FileTransferService_serviceDesc.Streams[0], c.cc, "/proto.FileTransferService/ListFiles", opts...) 151 | if err != nil { 152 | return nil, err 153 | } 154 | x := &fileTransferServiceListFilesClient{stream} 155 | if err := x.ClientStream.SendMsg(in); err != nil { 156 | return nil, err 157 | } 158 | if err := x.ClientStream.CloseSend(); err != nil { 159 | return nil, err 160 | } 161 | return x, nil 162 | } 163 | 164 | type FileTransferService_ListFilesClient interface { 165 | Recv() (*ListResponseType, error) 166 | grpc.ClientStream 167 | } 168 | 169 | type fileTransferServiceListFilesClient struct { 170 | grpc.ClientStream 171 | } 172 | 173 | func (x *fileTransferServiceListFilesClient) Recv() (*ListResponseType, error) { 174 | m := new(ListResponseType) 175 | if err := x.ClientStream.RecvMsg(m); err != nil { 176 | return nil, err 177 | } 178 | return m, nil 179 | } 180 | 181 | func (c *fileTransferServiceClient) Download(ctx context.Context, in *DownloadRequestType, opts ...grpc.CallOption) (FileTransferService_DownloadClient, error) { 182 | stream, err := grpc.NewClientStream(ctx, &_FileTransferService_serviceDesc.Streams[1], c.cc, "/proto.FileTransferService/Download", opts...) 183 | if err != nil { 184 | return nil, err 185 | } 186 | x := &fileTransferServiceDownloadClient{stream} 187 | if err := x.ClientStream.SendMsg(in); err != nil { 188 | return nil, err 189 | } 190 | if err := x.ClientStream.CloseSend(); err != nil { 191 | return nil, err 192 | } 193 | return x, nil 194 | } 195 | 196 | type FileTransferService_DownloadClient interface { 197 | Recv() (*DownloadResponseType, error) 198 | grpc.ClientStream 199 | } 200 | 201 | type fileTransferServiceDownloadClient struct { 202 | grpc.ClientStream 203 | } 204 | 205 | func (x *fileTransferServiceDownloadClient) Recv() (*DownloadResponseType, error) { 206 | m := new(DownloadResponseType) 207 | if err := x.ClientStream.RecvMsg(m); err != nil { 208 | return nil, err 209 | } 210 | return m, nil 211 | } 212 | 213 | // Server API for FileTransferService service 214 | 215 | type FileTransferServiceServer interface { 216 | ListFiles(*ListRequestType, FileTransferService_ListFilesServer) error 217 | Download(*DownloadRequestType, FileTransferService_DownloadServer) error 218 | } 219 | 220 | func RegisterFileTransferServiceServer(s *grpc.Server, srv FileTransferServiceServer) { 221 | s.RegisterService(&_FileTransferService_serviceDesc, srv) 222 | } 223 | 224 | func _FileTransferService_ListFiles_Handler(srv interface{}, stream grpc.ServerStream) error { 225 | m := new(ListRequestType) 226 | if err := stream.RecvMsg(m); err != nil { 227 | return err 228 | } 229 | return srv.(FileTransferServiceServer).ListFiles(m, &fileTransferServiceListFilesServer{stream}) 230 | } 231 | 232 | type FileTransferService_ListFilesServer interface { 233 | Send(*ListResponseType) error 234 | grpc.ServerStream 235 | } 236 | 237 | type fileTransferServiceListFilesServer struct { 238 | grpc.ServerStream 239 | } 240 | 241 | func (x *fileTransferServiceListFilesServer) Send(m *ListResponseType) error { 242 | return x.ServerStream.SendMsg(m) 243 | } 244 | 245 | func _FileTransferService_Download_Handler(srv interface{}, stream grpc.ServerStream) error { 246 | m := new(DownloadRequestType) 247 | if err := stream.RecvMsg(m); err != nil { 248 | return err 249 | } 250 | return srv.(FileTransferServiceServer).Download(m, &fileTransferServiceDownloadServer{stream}) 251 | } 252 | 253 | type FileTransferService_DownloadServer interface { 254 | Send(*DownloadResponseType) error 255 | grpc.ServerStream 256 | } 257 | 258 | type fileTransferServiceDownloadServer struct { 259 | grpc.ServerStream 260 | } 261 | 262 | func (x *fileTransferServiceDownloadServer) Send(m *DownloadResponseType) error { 263 | return x.ServerStream.SendMsg(m) 264 | } 265 | 266 | var _FileTransferService_serviceDesc = grpc.ServiceDesc{ 267 | ServiceName: "proto.FileTransferService", 268 | HandlerType: (*FileTransferServiceServer)(nil), 269 | Methods: []grpc.MethodDesc{}, 270 | Streams: []grpc.StreamDesc{ 271 | { 272 | StreamName: "ListFiles", 273 | Handler: _FileTransferService_ListFiles_Handler, 274 | ServerStreams: true, 275 | }, 276 | { 277 | StreamName: "Download", 278 | Handler: _FileTransferService_Download_Handler, 279 | ServerStreams: true, 280 | }, 281 | }, 282 | Metadata: "filetransfer_service.proto", 283 | } 284 | 285 | func init() { proto1.RegisterFile("filetransfer_service.proto", fileDescriptor0) } 286 | 287 | var fileDescriptor0 = []byte{ 288 | // 287 bytes of a gzipped FileDescriptorProto 289 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xbf, 0x4e, 0xf3, 0x30, 290 | 0x14, 0xc5, 0x3f, 0x7f, 0x2d, 0x7f, 0x7a, 0x01, 0x01, 0x2e, 0x82, 0xc8, 0x0c, 0x44, 0x99, 0x02, 291 | 0x43, 0x8a, 0x0a, 0x0f, 0xc0, 0x80, 0x60, 0x61, 0x32, 0xd9, 0x91, 0x4b, 0x6e, 0x2a, 0x4b, 0x71, 292 | 0x1c, 0x62, 0x17, 0x04, 0x33, 0x0f, 0xc2, 0xa3, 0x22, 0xdb, 0x8d, 0x4a, 0xa0, 0x93, 0x8f, 0xcf, 293 | 0x3d, 0xb2, 0x7f, 0xf7, 0x00, 0x2b, 0x65, 0x85, 0xb6, 0x15, 0xb5, 0x29, 0xb1, 0x7d, 0x32, 0xd8, 294 | 0xbe, 0xca, 0x67, 0xcc, 0x9a, 0x56, 0x5b, 0x4d, 0x37, 0xfc, 0xc1, 0xce, 0xe6, 0x5a, 0xcf, 0x2b, 295 | 0x9c, 0xf8, 0xdb, 0x6c, 0x51, 0x4e, 0xac, 0x54, 0x68, 0xac, 0x50, 0x4d, 0xc8, 0x25, 0x87, 0xb0, 296 | 0xff, 0x20, 0x8d, 0xe5, 0xf8, 0xb2, 0x40, 0x63, 0xf3, 0xf7, 0x06, 0x93, 0x4f, 0x02, 0x07, 0xc1, 297 | 0x33, 0x8d, 0xae, 0x0d, 0x3a, 0x93, 0x52, 0x18, 0xd6, 0x42, 0x61, 0x44, 0x62, 0x92, 0x8e, 0xb8, 298 | 0xd7, 0xce, 0x33, 0xf2, 0x03, 0xa3, 0xff, 0x31, 0x49, 0x07, 0xdc, 0x6b, 0xe7, 0x29, 0x5d, 0x60, 299 | 0x34, 0x88, 0x49, 0xba, 0xc7, 0xbd, 0xa6, 0xd7, 0xb0, 0xa5, 0x74, 0x91, 0x4b, 0x85, 0xd1, 0x30, 300 | 0x26, 0xe9, 0xce, 0x94, 0x65, 0x01, 0x2b, 0xeb, 0xb0, 0xb2, 0xbc, 0xc3, 0xe2, 0x5d, 0x34, 0x39, 301 | 0x87, 0xf1, 0xad, 0x7e, 0xab, 0x2b, 0x2d, 0x8a, 0x1f, 0x74, 0xeb, 0x40, 0x92, 0x0b, 0x38, 0x5a, 302 | 0x45, 0xfb, 0xd0, 0x85, 0xb0, 0xc2, 0x67, 0x77, 0xb9, 0xd7, 0xd3, 0x2f, 0x02, 0xe3, 0x3b, 0x59, 303 | 0x61, 0xbe, 0xec, 0xed, 0x31, 0xd4, 0x46, 0x6f, 0x60, 0xe4, 0x96, 0x76, 0x23, 0x43, 0x8f, 0x03, 304 | 0x59, 0xf6, 0xab, 0x1a, 0x76, 0xd2, 0xf3, 0x57, 0x3f, 0x25, 0xff, 0x2e, 0x09, 0xbd, 0x87, 0xed, 305 | 0x8e, 0x82, 0xb2, 0x65, 0x70, 0xcd, 0x06, 0xec, 0xf4, 0xcf, 0xac, 0xff, 0xd0, 0x6c, 0xd3, 0xcf, 306 | 0xaf, 0xbe, 0x03, 0x00, 0x00, 0xff, 0xff, 0x05, 0x59, 0x1c, 0xe7, 0xe0, 0x01, 0x00, 0x00, 307 | } 308 | -------------------------------------------------------------------------------- /proto/filetransfer_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | //google.protobuf.Timestamp 4 | //import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"; 5 | import "google/protobuf/timestamp.proto"; 6 | 7 | package proto; 8 | 9 | service FileTransferService { 10 | rpc ListFiles(ListRequestType) returns (stream ListResponseType) {}; 11 | rpc Download(DownloadRequestType) returns (stream DownloadResponseType) {}; 12 | } 13 | 14 | message ListRequestType { 15 | } 16 | 17 | message ListResponseType { 18 | string name = 1; 19 | int64 size = 2; 20 | uint32 mode = 3; 21 | google.protobuf.Timestamp modTime = 4; 22 | } 23 | 24 | message DownloadRequestType { 25 | string name = 1; 26 | } 27 | 28 | message DownloadResponseType { 29 | bytes data = 1; 30 | } 31 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/any.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/any"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "AnyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | 42 | // `Any` contains an arbitrary serialized protocol buffer message along with a 43 | // URL that describes the type of the serialized message. 44 | // 45 | // Protobuf library provides support to pack/unpack Any values in the form 46 | // of utility functions or additional generated methods of the Any type. 47 | // 48 | // Example 1: Pack and unpack a message in C++. 49 | // 50 | // Foo foo = ...; 51 | // Any any; 52 | // any.PackFrom(foo); 53 | // ... 54 | // if (any.UnpackTo(&foo)) { 55 | // ... 56 | // } 57 | // 58 | // Example 2: Pack and unpack a message in Java. 59 | // 60 | // Foo foo = ...; 61 | // Any any = Any.pack(foo); 62 | // ... 63 | // if (any.is(Foo.class)) { 64 | // foo = any.unpack(Foo.class); 65 | // } 66 | // 67 | // Example 3: Pack and unpack a message in Python. 68 | // 69 | // foo = Foo(...) 70 | // any = Any() 71 | // any.Pack(foo) 72 | // ... 73 | // if any.Is(Foo.DESCRIPTOR): 74 | // any.Unpack(foo) 75 | // ... 76 | // 77 | // Example 4: Pack and unpack a message in Go 78 | // 79 | // foo := &pb.Foo{...} 80 | // any, err := ptypes.MarshalAny(foo) 81 | // ... 82 | // foo := &pb.Foo{} 83 | // if err := ptypes.UnmarshalAny(any, foo); err != nil { 84 | // ... 85 | // } 86 | // 87 | // The pack methods provided by protobuf library will by default use 88 | // 'type.googleapis.com/full.type.name' as the type URL and the unpack 89 | // methods only use the fully qualified type name after the last '/' 90 | // in the type URL, for example "foo.bar.com/x/y.z" will yield type 91 | // name "y.z". 92 | // 93 | // 94 | // JSON 95 | // ==== 96 | // The JSON representation of an `Any` value uses the regular 97 | // representation of the deserialized, embedded message, with an 98 | // additional field `@type` which contains the type URL. Example: 99 | // 100 | // package google.profile; 101 | // message Person { 102 | // string first_name = 1; 103 | // string last_name = 2; 104 | // } 105 | // 106 | // { 107 | // "@type": "type.googleapis.com/google.profile.Person", 108 | // "firstName": , 109 | // "lastName": 110 | // } 111 | // 112 | // If the embedded message type is well-known and has a custom JSON 113 | // representation, that representation will be embedded adding a field 114 | // `value` which holds the custom JSON in addition to the `@type` 115 | // field. Example (for message [google.protobuf.Duration][]): 116 | // 117 | // { 118 | // "@type": "type.googleapis.com/google.protobuf.Duration", 119 | // "value": "1.212s" 120 | // } 121 | // 122 | message Any { 123 | // A URL/resource name whose content describes the type of the 124 | // serialized protocol buffer message. 125 | // 126 | // For URLs which use the scheme `http`, `https`, or no scheme, the 127 | // following restrictions and interpretations apply: 128 | // 129 | // * If no scheme is provided, `https` is assumed. 130 | // * The last segment of the URL's path must represent the fully 131 | // qualified name of the type (as in `path/google.protobuf.Duration`). 132 | // The name should be in a canonical form (e.g., leading "." is 133 | // not accepted). 134 | // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 135 | // value in binary format, or produce an error. 136 | // * Applications are allowed to cache lookup results based on the 137 | // URL, or have them precompiled into a binary to avoid any 138 | // lookup. Therefore, binary compatibility needs to be preserved 139 | // on changes to types. (Use versioned type names to manage 140 | // breaking changes.) 141 | // 142 | // Schemes other than `http`, `https` (or the empty scheme) might be 143 | // used with implementation specific semantics. 144 | // 145 | string type_url = 1; 146 | 147 | // Must be a valid serialized protocol buffer of the above specified type. 148 | bytes value = 2; 149 | } 150 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/api.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | import "google/protobuf/source_context.proto"; 36 | import "google/protobuf/type.proto"; 37 | 38 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 39 | option java_package = "com.google.protobuf"; 40 | option java_outer_classname = "ApiProto"; 41 | option java_multiple_files = true; 42 | option objc_class_prefix = "GPB"; 43 | option go_package = "google.golang.org/genproto/protobuf/api;api"; 44 | 45 | // Api is a light-weight descriptor for an API Interface. 46 | // 47 | // Interfaces are also described as "protocol buffer services" in some contexts, 48 | // such as by the "service" keyword in a .proto file, but they are different 49 | // from API Services, which represent a concrete implementation of an interface 50 | // as opposed to simply a description of methods and bindings. They are also 51 | // sometimes simply referred to as "APIs" in other contexts, such as the name of 52 | // this message itself. See https://cloud.google.com/apis/design/glossary for 53 | // detailed terminology. 54 | message Api { 55 | 56 | // The fully qualified name of this interface, including package name 57 | // followed by the interface's simple name. 58 | string name = 1; 59 | 60 | // The methods of this interface, in unspecified order. 61 | repeated Method methods = 2; 62 | 63 | // Any metadata attached to the interface. 64 | repeated Option options = 3; 65 | 66 | // A version string for this interface. If specified, must have the form 67 | // `major-version.minor-version`, as in `1.10`. If the minor version is 68 | // omitted, it defaults to zero. If the entire version field is empty, the 69 | // major version is derived from the package name, as outlined below. If the 70 | // field is not empty, the version in the package name will be verified to be 71 | // consistent with what is provided here. 72 | // 73 | // The versioning schema uses [semantic 74 | // versioning](http://semver.org) where the major version number 75 | // indicates a breaking change and the minor version an additive, 76 | // non-breaking change. Both version numbers are signals to users 77 | // what to expect from different versions, and should be carefully 78 | // chosen based on the product plan. 79 | // 80 | // The major version is also reflected in the package name of the 81 | // interface, which must end in `v`, as in 82 | // `google.feature.v1`. For major versions 0 and 1, the suffix can 83 | // be omitted. Zero major versions must only be used for 84 | // experimental, non-GA interfaces. 85 | // 86 | // 87 | string version = 4; 88 | 89 | // Source context for the protocol buffer service represented by this 90 | // message. 91 | SourceContext source_context = 5; 92 | 93 | // Included interfaces. See [Mixin][]. 94 | repeated Mixin mixins = 6; 95 | 96 | // The source syntax of the service. 97 | Syntax syntax = 7; 98 | } 99 | 100 | // Method represents a method of an API interface. 101 | message Method { 102 | 103 | // The simple name of this method. 104 | string name = 1; 105 | 106 | // A URL of the input message type. 107 | string request_type_url = 2; 108 | 109 | // If true, the request is streamed. 110 | bool request_streaming = 3; 111 | 112 | // The URL of the output message type. 113 | string response_type_url = 4; 114 | 115 | // If true, the response is streamed. 116 | bool response_streaming = 5; 117 | 118 | // Any metadata attached to the method. 119 | repeated Option options = 6; 120 | 121 | // The source syntax of this method. 122 | Syntax syntax = 7; 123 | } 124 | 125 | // Declares an API Interface to be included in this interface. The including 126 | // interface must redeclare all the methods from the included interface, but 127 | // documentation and options are inherited as follows: 128 | // 129 | // - If after comment and whitespace stripping, the documentation 130 | // string of the redeclared method is empty, it will be inherited 131 | // from the original method. 132 | // 133 | // - Each annotation belonging to the service config (http, 134 | // visibility) which is not set in the redeclared method will be 135 | // inherited. 136 | // 137 | // - If an http annotation is inherited, the path pattern will be 138 | // modified as follows. Any version prefix will be replaced by the 139 | // version of the including interface plus the [root][] path if 140 | // specified. 141 | // 142 | // Example of a simple mixin: 143 | // 144 | // package google.acl.v1; 145 | // service AccessControl { 146 | // // Get the underlying ACL object. 147 | // rpc GetAcl(GetAclRequest) returns (Acl) { 148 | // option (google.api.http).get = "/v1/{resource=**}:getAcl"; 149 | // } 150 | // } 151 | // 152 | // package google.storage.v2; 153 | // service Storage { 154 | // rpc GetAcl(GetAclRequest) returns (Acl); 155 | // 156 | // // Get a data record. 157 | // rpc GetData(GetDataRequest) returns (Data) { 158 | // option (google.api.http).get = "/v2/{resource=**}"; 159 | // } 160 | // } 161 | // 162 | // Example of a mixin configuration: 163 | // 164 | // apis: 165 | // - name: google.storage.v2.Storage 166 | // mixins: 167 | // - name: google.acl.v1.AccessControl 168 | // 169 | // The mixin construct implies that all methods in `AccessControl` are 170 | // also declared with same name and request/response types in 171 | // `Storage`. A documentation generator or annotation processor will 172 | // see the effective `Storage.GetAcl` method after inherting 173 | // documentation and annotations as follows: 174 | // 175 | // service Storage { 176 | // // Get the underlying ACL object. 177 | // rpc GetAcl(GetAclRequest) returns (Acl) { 178 | // option (google.api.http).get = "/v2/{resource=**}:getAcl"; 179 | // } 180 | // ... 181 | // } 182 | // 183 | // Note how the version in the path pattern changed from `v1` to `v2`. 184 | // 185 | // If the `root` field in the mixin is specified, it should be a 186 | // relative path under which inherited HTTP paths are placed. Example: 187 | // 188 | // apis: 189 | // - name: google.storage.v2.Storage 190 | // mixins: 191 | // - name: google.acl.v1.AccessControl 192 | // root: acls 193 | // 194 | // This implies the following inherited HTTP annotation: 195 | // 196 | // service Storage { 197 | // // Get the underlying ACL object. 198 | // rpc GetAcl(GetAclRequest) returns (Acl) { 199 | // option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; 200 | // } 201 | // ... 202 | // } 203 | message Mixin { 204 | // The fully qualified name of the interface which is included. 205 | string name = 1; 206 | 207 | // If non-empty specifies a path under which inherited HTTP paths 208 | // are rooted. 209 | string root = 2; 210 | } 211 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/compiler/plugin.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // 33 | // WARNING: The plugin interface is currently EXPERIMENTAL and is subject to 34 | // change. 35 | // 36 | // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is 37 | // just a program that reads a CodeGeneratorRequest from stdin and writes a 38 | // CodeGeneratorResponse to stdout. 39 | // 40 | // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead 41 | // of dealing with the raw protocol defined here. 42 | // 43 | // A plugin executable needs only to be placed somewhere in the path. The 44 | // plugin should be named "protoc-gen-$NAME", and will then be used when the 45 | // flag "--${NAME}_out" is passed to protoc. 46 | 47 | syntax = "proto2"; 48 | package google.protobuf.compiler; 49 | option java_package = "com.google.protobuf.compiler"; 50 | option java_outer_classname = "PluginProtos"; 51 | 52 | option go_package = "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go"; 53 | 54 | import "google/protobuf/descriptor.proto"; 55 | 56 | // The version number of protocol compiler. 57 | message Version { 58 | optional int32 major = 1; 59 | optional int32 minor = 2; 60 | optional int32 patch = 3; 61 | // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should 62 | // be empty for mainline stable releases. 63 | optional string suffix = 4; 64 | } 65 | 66 | // An encoded CodeGeneratorRequest is written to the plugin's stdin. 67 | message CodeGeneratorRequest { 68 | // The .proto files that were explicitly listed on the command-line. The 69 | // code generator should generate code only for these files. Each file's 70 | // descriptor will be included in proto_file, below. 71 | repeated string file_to_generate = 1; 72 | 73 | // The generator parameter passed on the command-line. 74 | optional string parameter = 2; 75 | 76 | // FileDescriptorProtos for all files in files_to_generate and everything 77 | // they import. The files will appear in topological order, so each file 78 | // appears before any file that imports it. 79 | // 80 | // protoc guarantees that all proto_files will be written after 81 | // the fields above, even though this is not technically guaranteed by the 82 | // protobuf wire format. This theoretically could allow a plugin to stream 83 | // in the FileDescriptorProtos and handle them one by one rather than read 84 | // the entire set into memory at once. However, as of this writing, this 85 | // is not similarly optimized on protoc's end -- it will store all fields in 86 | // memory at once before sending them to the plugin. 87 | // 88 | // Type names of fields and extensions in the FileDescriptorProto are always 89 | // fully qualified. 90 | repeated FileDescriptorProto proto_file = 15; 91 | 92 | // The version number of protocol compiler. 93 | optional Version compiler_version = 3; 94 | 95 | } 96 | 97 | // The plugin writes an encoded CodeGeneratorResponse to stdout. 98 | message CodeGeneratorResponse { 99 | // Error message. If non-empty, code generation failed. The plugin process 100 | // should exit with status code zero even if it reports an error in this way. 101 | // 102 | // This should be used to indicate errors in .proto files which prevent the 103 | // code generator from generating correct code. Errors which indicate a 104 | // problem in protoc itself -- such as the input CodeGeneratorRequest being 105 | // unparseable -- should be reported by writing a message to stderr and 106 | // exiting with a non-zero status code. 107 | optional string error = 1; 108 | 109 | // Represents a single generated file. 110 | message File { 111 | // The file name, relative to the output directory. The name must not 112 | // contain "." or ".." components and must be relative, not be absolute (so, 113 | // the file cannot lie outside the output directory). "/" must be used as 114 | // the path separator, not "\". 115 | // 116 | // If the name is omitted, the content will be appended to the previous 117 | // file. This allows the generator to break large files into small chunks, 118 | // and allows the generated text to be streamed back to protoc so that large 119 | // files need not reside completely in memory at one time. Note that as of 120 | // this writing protoc does not optimize for this -- it will read the entire 121 | // CodeGeneratorResponse before writing files to disk. 122 | optional string name = 1; 123 | 124 | // If non-empty, indicates that the named file should already exist, and the 125 | // content here is to be inserted into that file at a defined insertion 126 | // point. This feature allows a code generator to extend the output 127 | // produced by another code generator. The original generator may provide 128 | // insertion points by placing special annotations in the file that look 129 | // like: 130 | // @@protoc_insertion_point(NAME) 131 | // The annotation can have arbitrary text before and after it on the line, 132 | // which allows it to be placed in a comment. NAME should be replaced with 133 | // an identifier naming the point -- this is what other generators will use 134 | // as the insertion_point. Code inserted at this point will be placed 135 | // immediately above the line containing the insertion point (thus multiple 136 | // insertions to the same point will come out in the order they were added). 137 | // The double-@ is intended to make it unlikely that the generated code 138 | // could contain things that look like insertion points by accident. 139 | // 140 | // For example, the C++ code generator places the following line in the 141 | // .pb.h files that it generates: 142 | // // @@protoc_insertion_point(namespace_scope) 143 | // This line appears within the scope of the file's package namespace, but 144 | // outside of any particular class. Another plugin can then specify the 145 | // insertion_point "namespace_scope" to generate additional classes or 146 | // other declarations that should be placed in this scope. 147 | // 148 | // Note that if the line containing the insertion point begins with 149 | // whitespace, the same whitespace will be added to every line of the 150 | // inserted text. This is useful for languages like Python, where 151 | // indentation matters. In these languages, the insertion point comment 152 | // should be indented the same amount as any inserted code will need to be 153 | // in order to work correctly in that context. 154 | // 155 | // The code generator that generates the initial file and the one which 156 | // inserts into it must both run as part of a single invocation of protoc. 157 | // Code generators are executed in the order in which they appear on the 158 | // command line. 159 | // 160 | // If |insertion_point| is present, |name| must also be present. 161 | optional string insertion_point = 2; 162 | 163 | // The file contents. 164 | optional string content = 15; 165 | } 166 | repeated File file = 15; 167 | } 168 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/descriptor.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // The messages in this file describe the definitions found in .proto files. 36 | // A valid .proto file can be translated directly to a FileDescriptorProto 37 | // without any other information (e.g. without reading its imports). 38 | 39 | 40 | syntax = "proto2"; 41 | 42 | package google.protobuf; 43 | option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor"; 44 | option java_package = "com.google.protobuf"; 45 | option java_outer_classname = "DescriptorProtos"; 46 | option csharp_namespace = "Google.Protobuf.Reflection"; 47 | option objc_class_prefix = "GPB"; 48 | option cc_enable_arenas = true; 49 | 50 | // descriptor.proto must be optimized for speed because reflection-based 51 | // algorithms don't work during bootstrapping. 52 | option optimize_for = SPEED; 53 | 54 | // The protocol compiler can output a FileDescriptorSet containing the .proto 55 | // files it parses. 56 | message FileDescriptorSet { 57 | repeated FileDescriptorProto file = 1; 58 | } 59 | 60 | // Describes a complete .proto file. 61 | message FileDescriptorProto { 62 | optional string name = 1; // file name, relative to root of source tree 63 | optional string package = 2; // e.g. "foo", "foo.bar", etc. 64 | 65 | // Names of files imported by this file. 66 | repeated string dependency = 3; 67 | // Indexes of the public imported files in the dependency list above. 68 | repeated int32 public_dependency = 10; 69 | // Indexes of the weak imported files in the dependency list. 70 | // For Google-internal migration only. Do not use. 71 | repeated int32 weak_dependency = 11; 72 | 73 | // All top-level definitions in this file. 74 | repeated DescriptorProto message_type = 4; 75 | repeated EnumDescriptorProto enum_type = 5; 76 | repeated ServiceDescriptorProto service = 6; 77 | repeated FieldDescriptorProto extension = 7; 78 | 79 | optional FileOptions options = 8; 80 | 81 | // This field contains optional information about the original source code. 82 | // You may safely remove this entire field without harming runtime 83 | // functionality of the descriptors -- the information is needed only by 84 | // development tools. 85 | optional SourceCodeInfo source_code_info = 9; 86 | 87 | // The syntax of the proto file. 88 | // The supported values are "proto2" and "proto3". 89 | optional string syntax = 12; 90 | } 91 | 92 | // Describes a message type. 93 | message DescriptorProto { 94 | optional string name = 1; 95 | 96 | repeated FieldDescriptorProto field = 2; 97 | repeated FieldDescriptorProto extension = 6; 98 | 99 | repeated DescriptorProto nested_type = 3; 100 | repeated EnumDescriptorProto enum_type = 4; 101 | 102 | message ExtensionRange { 103 | optional int32 start = 1; 104 | optional int32 end = 2; 105 | 106 | optional ExtensionRangeOptions options = 3; 107 | } 108 | repeated ExtensionRange extension_range = 5; 109 | 110 | repeated OneofDescriptorProto oneof_decl = 8; 111 | 112 | optional MessageOptions options = 7; 113 | 114 | // Range of reserved tag numbers. Reserved tag numbers may not be used by 115 | // fields or extension ranges in the same message. Reserved ranges may 116 | // not overlap. 117 | message ReservedRange { 118 | optional int32 start = 1; // Inclusive. 119 | optional int32 end = 2; // Exclusive. 120 | } 121 | repeated ReservedRange reserved_range = 9; 122 | // Reserved field names, which may not be used by fields in the same message. 123 | // A given name may only be reserved once. 124 | repeated string reserved_name = 10; 125 | } 126 | 127 | message ExtensionRangeOptions { 128 | // The parser stores options it doesn't recognize here. See above. 129 | repeated UninterpretedOption uninterpreted_option = 999; 130 | 131 | // Clients can define custom options in extensions of this message. See above. 132 | extensions 1000 to max; 133 | } 134 | 135 | // Describes a field within a message. 136 | message FieldDescriptorProto { 137 | enum Type { 138 | // 0 is reserved for errors. 139 | // Order is weird for historical reasons. 140 | TYPE_DOUBLE = 1; 141 | TYPE_FLOAT = 2; 142 | // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 143 | // negative values are likely. 144 | TYPE_INT64 = 3; 145 | TYPE_UINT64 = 4; 146 | // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 147 | // negative values are likely. 148 | TYPE_INT32 = 5; 149 | TYPE_FIXED64 = 6; 150 | TYPE_FIXED32 = 7; 151 | TYPE_BOOL = 8; 152 | TYPE_STRING = 9; 153 | // Tag-delimited aggregate. 154 | // Group type is deprecated and not supported in proto3. However, Proto3 155 | // implementations should still be able to parse the group wire format and 156 | // treat group fields as unknown fields. 157 | TYPE_GROUP = 10; 158 | TYPE_MESSAGE = 11; // Length-delimited aggregate. 159 | 160 | // New in version 2. 161 | TYPE_BYTES = 12; 162 | TYPE_UINT32 = 13; 163 | TYPE_ENUM = 14; 164 | TYPE_SFIXED32 = 15; 165 | TYPE_SFIXED64 = 16; 166 | TYPE_SINT32 = 17; // Uses ZigZag encoding. 167 | TYPE_SINT64 = 18; // Uses ZigZag encoding. 168 | }; 169 | 170 | enum Label { 171 | // 0 is reserved for errors 172 | LABEL_OPTIONAL = 1; 173 | LABEL_REQUIRED = 2; 174 | LABEL_REPEATED = 3; 175 | }; 176 | 177 | optional string name = 1; 178 | optional int32 number = 3; 179 | optional Label label = 4; 180 | 181 | // If type_name is set, this need not be set. If both this and type_name 182 | // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 183 | optional Type type = 5; 184 | 185 | // For message and enum types, this is the name of the type. If the name 186 | // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 187 | // rules are used to find the type (i.e. first the nested types within this 188 | // message are searched, then within the parent, on up to the root 189 | // namespace). 190 | optional string type_name = 6; 191 | 192 | // For extensions, this is the name of the type being extended. It is 193 | // resolved in the same manner as type_name. 194 | optional string extendee = 2; 195 | 196 | // For numeric types, contains the original text representation of the value. 197 | // For booleans, "true" or "false". 198 | // For strings, contains the default text contents (not escaped in any way). 199 | // For bytes, contains the C escaped value. All bytes >= 128 are escaped. 200 | // TODO(kenton): Base-64 encode? 201 | optional string default_value = 7; 202 | 203 | // If set, gives the index of a oneof in the containing type's oneof_decl 204 | // list. This field is a member of that oneof. 205 | optional int32 oneof_index = 9; 206 | 207 | // JSON name of this field. The value is set by protocol compiler. If the 208 | // user has set a "json_name" option on this field, that option's value 209 | // will be used. Otherwise, it's deduced from the field's name by converting 210 | // it to camelCase. 211 | optional string json_name = 10; 212 | 213 | optional FieldOptions options = 8; 214 | } 215 | 216 | // Describes a oneof. 217 | message OneofDescriptorProto { 218 | optional string name = 1; 219 | optional OneofOptions options = 2; 220 | } 221 | 222 | // Describes an enum type. 223 | message EnumDescriptorProto { 224 | optional string name = 1; 225 | 226 | repeated EnumValueDescriptorProto value = 2; 227 | 228 | optional EnumOptions options = 3; 229 | 230 | // Range of reserved numeric values. Reserved values may not be used by 231 | // entries in the same enum. Reserved ranges may not overlap. 232 | // 233 | // Note that this is distinct from DescriptorProto.ReservedRange in that it 234 | // is inclusive such that it can appropriately represent the entire int32 235 | // domain. 236 | message EnumReservedRange { 237 | optional int32 start = 1; // Inclusive. 238 | optional int32 end = 2; // Inclusive. 239 | } 240 | 241 | // Range of reserved numeric values. Reserved numeric values may not be used 242 | // by enum values in the same enum declaration. Reserved ranges may not 243 | // overlap. 244 | repeated EnumReservedRange reserved_range = 4; 245 | 246 | // Reserved enum value names, which may not be reused. A given name may only 247 | // be reserved once. 248 | repeated string reserved_name = 5; 249 | } 250 | 251 | // Describes a value within an enum. 252 | message EnumValueDescriptorProto { 253 | optional string name = 1; 254 | optional int32 number = 2; 255 | 256 | optional EnumValueOptions options = 3; 257 | } 258 | 259 | // Describes a service. 260 | message ServiceDescriptorProto { 261 | optional string name = 1; 262 | repeated MethodDescriptorProto method = 2; 263 | 264 | optional ServiceOptions options = 3; 265 | } 266 | 267 | // Describes a method of a service. 268 | message MethodDescriptorProto { 269 | optional string name = 1; 270 | 271 | // Input and output type names. These are resolved in the same way as 272 | // FieldDescriptorProto.type_name, but must refer to a message type. 273 | optional string input_type = 2; 274 | optional string output_type = 3; 275 | 276 | optional MethodOptions options = 4; 277 | 278 | // Identifies if client streams multiple client messages 279 | optional bool client_streaming = 5 [default=false]; 280 | // Identifies if server streams multiple server messages 281 | optional bool server_streaming = 6 [default=false]; 282 | } 283 | 284 | 285 | // =================================================================== 286 | // Options 287 | 288 | // Each of the definitions above may have "options" attached. These are 289 | // just annotations which may cause code to be generated slightly differently 290 | // or may contain hints for code that manipulates protocol messages. 291 | // 292 | // Clients may define custom options as extensions of the *Options messages. 293 | // These extensions may not yet be known at parsing time, so the parser cannot 294 | // store the values in them. Instead it stores them in a field in the *Options 295 | // message called uninterpreted_option. This field must have the same name 296 | // across all *Options messages. We then use this field to populate the 297 | // extensions when we build a descriptor, at which point all protos have been 298 | // parsed and so all extensions are known. 299 | // 300 | // Extension numbers for custom options may be chosen as follows: 301 | // * For options which will only be used within a single application or 302 | // organization, or for experimental options, use field numbers 50000 303 | // through 99999. It is up to you to ensure that you do not use the 304 | // same number for multiple options. 305 | // * For options which will be published and used publicly by multiple 306 | // independent entities, e-mail protobuf-global-extension-registry@google.com 307 | // to reserve extension numbers. Simply provide your project name (e.g. 308 | // Objective-C plugin) and your project website (if available) -- there's no 309 | // need to explain how you intend to use them. Usually you only need one 310 | // extension number. You can declare multiple options with only one extension 311 | // number by putting them in a sub-message. See the Custom Options section of 312 | // the docs for examples: 313 | // https://developers.google.com/protocol-buffers/docs/proto#options 314 | // If this turns out to be popular, a web service will be set up 315 | // to automatically assign option numbers. 316 | 317 | 318 | message FileOptions { 319 | 320 | // Sets the Java package where classes generated from this .proto will be 321 | // placed. By default, the proto package is used, but this is often 322 | // inappropriate because proto packages do not normally start with backwards 323 | // domain names. 324 | optional string java_package = 1; 325 | 326 | 327 | // If set, all the classes from the .proto file are wrapped in a single 328 | // outer class with the given name. This applies to both Proto1 329 | // (equivalent to the old "--one_java_file" option) and Proto2 (where 330 | // a .proto always translates to a single class, but you may want to 331 | // explicitly choose the class name). 332 | optional string java_outer_classname = 8; 333 | 334 | // If set true, then the Java code generator will generate a separate .java 335 | // file for each top-level message, enum, and service defined in the .proto 336 | // file. Thus, these types will *not* be nested inside the outer class 337 | // named by java_outer_classname. However, the outer class will still be 338 | // generated to contain the file's getDescriptor() method as well as any 339 | // top-level extensions defined in the file. 340 | optional bool java_multiple_files = 10 [default=false]; 341 | 342 | // This option does nothing. 343 | optional bool java_generate_equals_and_hash = 20 [deprecated=true]; 344 | 345 | // If set true, then the Java2 code generator will generate code that 346 | // throws an exception whenever an attempt is made to assign a non-UTF-8 347 | // byte sequence to a string field. 348 | // Message reflection will do the same. 349 | // However, an extension field still accepts non-UTF-8 byte sequences. 350 | // This option has no effect on when used with the lite runtime. 351 | optional bool java_string_check_utf8 = 27 [default=false]; 352 | 353 | 354 | // Generated classes can be optimized for speed or code size. 355 | enum OptimizeMode { 356 | SPEED = 1; // Generate complete code for parsing, serialization, 357 | // etc. 358 | CODE_SIZE = 2; // Use ReflectionOps to implement these methods. 359 | LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. 360 | } 361 | optional OptimizeMode optimize_for = 9 [default=SPEED]; 362 | 363 | // Sets the Go package where structs generated from this .proto will be 364 | // placed. If omitted, the Go package will be derived from the following: 365 | // - The basename of the package import path, if provided. 366 | // - Otherwise, the package statement in the .proto file, if present. 367 | // - Otherwise, the basename of the .proto file, without extension. 368 | optional string go_package = 11; 369 | 370 | 371 | 372 | // Should generic services be generated in each language? "Generic" services 373 | // are not specific to any particular RPC system. They are generated by the 374 | // main code generators in each language (without additional plugins). 375 | // Generic services were the only kind of service generation supported by 376 | // early versions of google.protobuf. 377 | // 378 | // Generic services are now considered deprecated in favor of using plugins 379 | // that generate code specific to your particular RPC system. Therefore, 380 | // these default to false. Old code which depends on generic services should 381 | // explicitly set them to true. 382 | optional bool cc_generic_services = 16 [default=false]; 383 | optional bool java_generic_services = 17 [default=false]; 384 | optional bool py_generic_services = 18 [default=false]; 385 | optional bool php_generic_services = 42 [default=false]; 386 | 387 | // Is this file deprecated? 388 | // Depending on the target platform, this can emit Deprecated annotations 389 | // for everything in the file, or it will be completely ignored; in the very 390 | // least, this is a formalization for deprecating files. 391 | optional bool deprecated = 23 [default=false]; 392 | 393 | // Enables the use of arenas for the proto messages in this file. This applies 394 | // only to generated classes for C++. 395 | optional bool cc_enable_arenas = 31 [default=false]; 396 | 397 | 398 | // Sets the objective c class prefix which is prepended to all objective c 399 | // generated classes from this .proto. There is no default. 400 | optional string objc_class_prefix = 36; 401 | 402 | // Namespace for generated classes; defaults to the package. 403 | optional string csharp_namespace = 37; 404 | 405 | // By default Swift generators will take the proto package and CamelCase it 406 | // replacing '.' with underscore and use that to prefix the types/symbols 407 | // defined. When this options is provided, they will use this value instead 408 | // to prefix the types/symbols defined. 409 | optional string swift_prefix = 39; 410 | 411 | // Sets the php class prefix which is prepended to all php generated classes 412 | // from this .proto. Default is empty. 413 | optional string php_class_prefix = 40; 414 | 415 | // Use this option to change the namespace of php generated classes. Default 416 | // is empty. When this option is empty, the package name will be used for 417 | // determining the namespace. 418 | optional string php_namespace = 41; 419 | 420 | // The parser stores options it doesn't recognize here. 421 | // See the documentation for the "Options" section above. 422 | repeated UninterpretedOption uninterpreted_option = 999; 423 | 424 | // Clients can define custom options in extensions of this message. 425 | // See the documentation for the "Options" section above. 426 | extensions 1000 to max; 427 | 428 | reserved 38; 429 | } 430 | 431 | message MessageOptions { 432 | // Set true to use the old proto1 MessageSet wire format for extensions. 433 | // This is provided for backwards-compatibility with the MessageSet wire 434 | // format. You should not use this for any other reason: It's less 435 | // efficient, has fewer features, and is more complicated. 436 | // 437 | // The message must be defined exactly as follows: 438 | // message Foo { 439 | // option message_set_wire_format = true; 440 | // extensions 4 to max; 441 | // } 442 | // Note that the message cannot have any defined fields; MessageSets only 443 | // have extensions. 444 | // 445 | // All extensions of your type must be singular messages; e.g. they cannot 446 | // be int32s, enums, or repeated messages. 447 | // 448 | // Because this is an option, the above two restrictions are not enforced by 449 | // the protocol compiler. 450 | optional bool message_set_wire_format = 1 [default=false]; 451 | 452 | // Disables the generation of the standard "descriptor()" accessor, which can 453 | // conflict with a field of the same name. This is meant to make migration 454 | // from proto1 easier; new code should avoid fields named "descriptor". 455 | optional bool no_standard_descriptor_accessor = 2 [default=false]; 456 | 457 | // Is this message deprecated? 458 | // Depending on the target platform, this can emit Deprecated annotations 459 | // for the message, or it will be completely ignored; in the very least, 460 | // this is a formalization for deprecating messages. 461 | optional bool deprecated = 3 [default=false]; 462 | 463 | // Whether the message is an automatically generated map entry type for the 464 | // maps field. 465 | // 466 | // For maps fields: 467 | // map map_field = 1; 468 | // The parsed descriptor looks like: 469 | // message MapFieldEntry { 470 | // option map_entry = true; 471 | // optional KeyType key = 1; 472 | // optional ValueType value = 2; 473 | // } 474 | // repeated MapFieldEntry map_field = 1; 475 | // 476 | // Implementations may choose not to generate the map_entry=true message, but 477 | // use a native map in the target language to hold the keys and values. 478 | // The reflection APIs in such implementions still need to work as 479 | // if the field is a repeated message field. 480 | // 481 | // NOTE: Do not set the option in .proto files. Always use the maps syntax 482 | // instead. The option should only be implicitly set by the proto compiler 483 | // parser. 484 | optional bool map_entry = 7; 485 | 486 | reserved 8; // javalite_serializable 487 | reserved 9; // javanano_as_lite 488 | 489 | // The parser stores options it doesn't recognize here. See above. 490 | repeated UninterpretedOption uninterpreted_option = 999; 491 | 492 | // Clients can define custom options in extensions of this message. See above. 493 | extensions 1000 to max; 494 | } 495 | 496 | message FieldOptions { 497 | // The ctype option instructs the C++ code generator to use a different 498 | // representation of the field than it normally would. See the specific 499 | // options below. This option is not yet implemented in the open source 500 | // release -- sorry, we'll try to include it in a future version! 501 | optional CType ctype = 1 [default = STRING]; 502 | enum CType { 503 | // Default mode. 504 | STRING = 0; 505 | 506 | CORD = 1; 507 | 508 | STRING_PIECE = 2; 509 | } 510 | // The packed option can be enabled for repeated primitive fields to enable 511 | // a more efficient representation on the wire. Rather than repeatedly 512 | // writing the tag and type for each element, the entire array is encoded as 513 | // a single length-delimited blob. In proto3, only explicit setting it to 514 | // false will avoid using packed encoding. 515 | optional bool packed = 2; 516 | 517 | // The jstype option determines the JavaScript type used for values of the 518 | // field. The option is permitted only for 64 bit integral and fixed types 519 | // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING 520 | // is represented as JavaScript string, which avoids loss of precision that 521 | // can happen when a large value is converted to a floating point JavaScript. 522 | // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to 523 | // use the JavaScript "number" type. The behavior of the default option 524 | // JS_NORMAL is implementation dependent. 525 | // 526 | // This option is an enum to permit additional types to be added, e.g. 527 | // goog.math.Integer. 528 | optional JSType jstype = 6 [default = JS_NORMAL]; 529 | enum JSType { 530 | // Use the default type. 531 | JS_NORMAL = 0; 532 | 533 | // Use JavaScript strings. 534 | JS_STRING = 1; 535 | 536 | // Use JavaScript numbers. 537 | JS_NUMBER = 2; 538 | } 539 | 540 | // Should this field be parsed lazily? Lazy applies only to message-type 541 | // fields. It means that when the outer message is initially parsed, the 542 | // inner message's contents will not be parsed but instead stored in encoded 543 | // form. The inner message will actually be parsed when it is first accessed. 544 | // 545 | // This is only a hint. Implementations are free to choose whether to use 546 | // eager or lazy parsing regardless of the value of this option. However, 547 | // setting this option true suggests that the protocol author believes that 548 | // using lazy parsing on this field is worth the additional bookkeeping 549 | // overhead typically needed to implement it. 550 | // 551 | // This option does not affect the public interface of any generated code; 552 | // all method signatures remain the same. Furthermore, thread-safety of the 553 | // interface is not affected by this option; const methods remain safe to 554 | // call from multiple threads concurrently, while non-const methods continue 555 | // to require exclusive access. 556 | // 557 | // 558 | // Note that implementations may choose not to check required fields within 559 | // a lazy sub-message. That is, calling IsInitialized() on the outer message 560 | // may return true even if the inner message has missing required fields. 561 | // This is necessary because otherwise the inner message would have to be 562 | // parsed in order to perform the check, defeating the purpose of lazy 563 | // parsing. An implementation which chooses not to check required fields 564 | // must be consistent about it. That is, for any particular sub-message, the 565 | // implementation must either *always* check its required fields, or *never* 566 | // check its required fields, regardless of whether or not the message has 567 | // been parsed. 568 | optional bool lazy = 5 [default=false]; 569 | 570 | // Is this field deprecated? 571 | // Depending on the target platform, this can emit Deprecated annotations 572 | // for accessors, or it will be completely ignored; in the very least, this 573 | // is a formalization for deprecating fields. 574 | optional bool deprecated = 3 [default=false]; 575 | 576 | // For Google-internal migration only. Do not use. 577 | optional bool weak = 10 [default=false]; 578 | 579 | 580 | // The parser stores options it doesn't recognize here. See above. 581 | repeated UninterpretedOption uninterpreted_option = 999; 582 | 583 | // Clients can define custom options in extensions of this message. See above. 584 | extensions 1000 to max; 585 | 586 | reserved 4; // removed jtype 587 | } 588 | 589 | message OneofOptions { 590 | // The parser stores options it doesn't recognize here. See above. 591 | repeated UninterpretedOption uninterpreted_option = 999; 592 | 593 | // Clients can define custom options in extensions of this message. See above. 594 | extensions 1000 to max; 595 | } 596 | 597 | message EnumOptions { 598 | 599 | // Set this option to true to allow mapping different tag names to the same 600 | // value. 601 | optional bool allow_alias = 2; 602 | 603 | // Is this enum deprecated? 604 | // Depending on the target platform, this can emit Deprecated annotations 605 | // for the enum, or it will be completely ignored; in the very least, this 606 | // is a formalization for deprecating enums. 607 | optional bool deprecated = 3 [default=false]; 608 | 609 | reserved 5; // javanano_as_lite 610 | 611 | // The parser stores options it doesn't recognize here. See above. 612 | repeated UninterpretedOption uninterpreted_option = 999; 613 | 614 | // Clients can define custom options in extensions of this message. See above. 615 | extensions 1000 to max; 616 | } 617 | 618 | message EnumValueOptions { 619 | // Is this enum value deprecated? 620 | // Depending on the target platform, this can emit Deprecated annotations 621 | // for the enum value, or it will be completely ignored; in the very least, 622 | // this is a formalization for deprecating enum values. 623 | optional bool deprecated = 1 [default=false]; 624 | 625 | // The parser stores options it doesn't recognize here. See above. 626 | repeated UninterpretedOption uninterpreted_option = 999; 627 | 628 | // Clients can define custom options in extensions of this message. See above. 629 | extensions 1000 to max; 630 | } 631 | 632 | message ServiceOptions { 633 | 634 | // Note: Field numbers 1 through 32 are reserved for Google's internal RPC 635 | // framework. We apologize for hoarding these numbers to ourselves, but 636 | // we were already using them long before we decided to release Protocol 637 | // Buffers. 638 | 639 | // Is this service deprecated? 640 | // Depending on the target platform, this can emit Deprecated annotations 641 | // for the service, or it will be completely ignored; in the very least, 642 | // this is a formalization for deprecating services. 643 | optional bool deprecated = 33 [default=false]; 644 | 645 | // The parser stores options it doesn't recognize here. See above. 646 | repeated UninterpretedOption uninterpreted_option = 999; 647 | 648 | // Clients can define custom options in extensions of this message. See above. 649 | extensions 1000 to max; 650 | } 651 | 652 | message MethodOptions { 653 | 654 | // Note: Field numbers 1 through 32 are reserved for Google's internal RPC 655 | // framework. We apologize for hoarding these numbers to ourselves, but 656 | // we were already using them long before we decided to release Protocol 657 | // Buffers. 658 | 659 | // Is this method deprecated? 660 | // Depending on the target platform, this can emit Deprecated annotations 661 | // for the method, or it will be completely ignored; in the very least, 662 | // this is a formalization for deprecating methods. 663 | optional bool deprecated = 33 [default=false]; 664 | 665 | // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, 666 | // or neither? HTTP based RPC implementation may choose GET verb for safe 667 | // methods, and PUT verb for idempotent methods instead of the default POST. 668 | enum IdempotencyLevel { 669 | IDEMPOTENCY_UNKNOWN = 0; 670 | NO_SIDE_EFFECTS = 1; // implies idempotent 671 | IDEMPOTENT = 2; // idempotent, but may have side effects 672 | } 673 | optional IdempotencyLevel idempotency_level = 674 | 34 [default=IDEMPOTENCY_UNKNOWN]; 675 | 676 | // The parser stores options it doesn't recognize here. See above. 677 | repeated UninterpretedOption uninterpreted_option = 999; 678 | 679 | // Clients can define custom options in extensions of this message. See above. 680 | extensions 1000 to max; 681 | } 682 | 683 | 684 | // A message representing a option the parser does not recognize. This only 685 | // appears in options protos created by the compiler::Parser class. 686 | // DescriptorPool resolves these when building Descriptor objects. Therefore, 687 | // options protos in descriptor objects (e.g. returned by Descriptor::options(), 688 | // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions 689 | // in them. 690 | message UninterpretedOption { 691 | // The name of the uninterpreted option. Each string represents a segment in 692 | // a dot-separated name. is_extension is true iff a segment represents an 693 | // extension (denoted with parentheses in options specs in .proto files). 694 | // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents 695 | // "foo.(bar.baz).qux". 696 | message NamePart { 697 | required string name_part = 1; 698 | required bool is_extension = 2; 699 | } 700 | repeated NamePart name = 2; 701 | 702 | // The value of the uninterpreted option, in whatever type the tokenizer 703 | // identified it as during parsing. Exactly one of these should be set. 704 | optional string identifier_value = 3; 705 | optional uint64 positive_int_value = 4; 706 | optional int64 negative_int_value = 5; 707 | optional double double_value = 6; 708 | optional bytes string_value = 7; 709 | optional string aggregate_value = 8; 710 | } 711 | 712 | // =================================================================== 713 | // Optional source code info 714 | 715 | // Encapsulates information about the original source file from which a 716 | // FileDescriptorProto was generated. 717 | message SourceCodeInfo { 718 | // A Location identifies a piece of source code in a .proto file which 719 | // corresponds to a particular definition. This information is intended 720 | // to be useful to IDEs, code indexers, documentation generators, and similar 721 | // tools. 722 | // 723 | // For example, say we have a file like: 724 | // message Foo { 725 | // optional string foo = 1; 726 | // } 727 | // Let's look at just the field definition: 728 | // optional string foo = 1; 729 | // ^ ^^ ^^ ^ ^^^ 730 | // a bc de f ghi 731 | // We have the following locations: 732 | // span path represents 733 | // [a,i) [ 4, 0, 2, 0 ] The whole field definition. 734 | // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). 735 | // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). 736 | // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). 737 | // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). 738 | // 739 | // Notes: 740 | // - A location may refer to a repeated field itself (i.e. not to any 741 | // particular index within it). This is used whenever a set of elements are 742 | // logically enclosed in a single code segment. For example, an entire 743 | // extend block (possibly containing multiple extension definitions) will 744 | // have an outer location whose path refers to the "extensions" repeated 745 | // field without an index. 746 | // - Multiple locations may have the same path. This happens when a single 747 | // logical declaration is spread out across multiple places. The most 748 | // obvious example is the "extend" block again -- there may be multiple 749 | // extend blocks in the same scope, each of which will have the same path. 750 | // - A location's span is not always a subset of its parent's span. For 751 | // example, the "extendee" of an extension declaration appears at the 752 | // beginning of the "extend" block and is shared by all extensions within 753 | // the block. 754 | // - Just because a location's span is a subset of some other location's span 755 | // does not mean that it is a descendent. For example, a "group" defines 756 | // both a type and a field in a single declaration. Thus, the locations 757 | // corresponding to the type and field and their components will overlap. 758 | // - Code which tries to interpret locations should probably be designed to 759 | // ignore those that it doesn't understand, as more types of locations could 760 | // be recorded in the future. 761 | repeated Location location = 1; 762 | message Location { 763 | // Identifies which part of the FileDescriptorProto was defined at this 764 | // location. 765 | // 766 | // Each element is a field number or an index. They form a path from 767 | // the root FileDescriptorProto to the place where the definition. For 768 | // example, this path: 769 | // [ 4, 3, 2, 7, 1 ] 770 | // refers to: 771 | // file.message_type(3) // 4, 3 772 | // .field(7) // 2, 7 773 | // .name() // 1 774 | // This is because FileDescriptorProto.message_type has field number 4: 775 | // repeated DescriptorProto message_type = 4; 776 | // and DescriptorProto.field has field number 2: 777 | // repeated FieldDescriptorProto field = 2; 778 | // and FieldDescriptorProto.name has field number 1: 779 | // optional string name = 1; 780 | // 781 | // Thus, the above path gives the location of a field name. If we removed 782 | // the last element: 783 | // [ 4, 3, 2, 7 ] 784 | // this path refers to the whole field declaration (from the beginning 785 | // of the label to the terminating semicolon). 786 | repeated int32 path = 1 [packed=true]; 787 | 788 | // Always has exactly three or four elements: start line, start column, 789 | // end line (optional, otherwise assumed same as start line), end column. 790 | // These are packed into a single field for efficiency. Note that line 791 | // and column numbers are zero-based -- typically you will want to add 792 | // 1 to each before displaying to a user. 793 | repeated int32 span = 2 [packed=true]; 794 | 795 | // If this SourceCodeInfo represents a complete declaration, these are any 796 | // comments appearing before and after the declaration which appear to be 797 | // attached to the declaration. 798 | // 799 | // A series of line comments appearing on consecutive lines, with no other 800 | // tokens appearing on those lines, will be treated as a single comment. 801 | // 802 | // leading_detached_comments will keep paragraphs of comments that appear 803 | // before (but not connected to) the current element. Each paragraph, 804 | // separated by empty lines, will be one comment element in the repeated 805 | // field. 806 | // 807 | // Only the comment content is provided; comment markers (e.g. //) are 808 | // stripped out. For block comments, leading whitespace and an asterisk 809 | // will be stripped from the beginning of each line other than the first. 810 | // Newlines are included in the output. 811 | // 812 | // Examples: 813 | // 814 | // optional int32 foo = 1; // Comment attached to foo. 815 | // // Comment attached to bar. 816 | // optional int32 bar = 2; 817 | // 818 | // optional string baz = 3; 819 | // // Comment attached to baz. 820 | // // Another line attached to baz. 821 | // 822 | // // Comment attached to qux. 823 | // // 824 | // // Another line attached to qux. 825 | // optional double qux = 4; 826 | // 827 | // // Detached comment for corge. This is not leading or trailing comments 828 | // // to qux or corge because there are blank lines separating it from 829 | // // both. 830 | // 831 | // // Detached comment for corge paragraph 2. 832 | // 833 | // optional string corge = 5; 834 | // /* Block comment attached 835 | // * to corge. Leading asterisks 836 | // * will be removed. */ 837 | // /* Block comment attached to 838 | // * grault. */ 839 | // optional int32 grault = 6; 840 | // 841 | // // ignored detached comments. 842 | optional string leading_comments = 3; 843 | optional string trailing_comments = 4; 844 | repeated string leading_detached_comments = 6; 845 | } 846 | } 847 | 848 | // Describes the relationship between generated code and its original source 849 | // file. A GeneratedCodeInfo message is associated with only one generated 850 | // source file, but may contain references to different source .proto files. 851 | message GeneratedCodeInfo { 852 | // An Annotation connects some span of text in generated code to an element 853 | // of its generating .proto file. 854 | repeated Annotation annotation = 1; 855 | message Annotation { 856 | // Identifies the element in the original source .proto file. This field 857 | // is formatted the same as SourceCodeInfo.Location.path. 858 | repeated int32 path = 1 [packed=true]; 859 | 860 | // Identifies the filesystem path to the original source .proto. 861 | optional string source_file = 2; 862 | 863 | // Identifies the starting offset in bytes in the generated code 864 | // that relates to the identified object. 865 | optional int32 begin = 3; 866 | 867 | // Identifies the ending offset in bytes in the generated code that 868 | // relates to the identified offset. The end offset should be one past 869 | // the last relevant byte (so the length of the text = end - begin). 870 | optional int32 end = 4; 871 | } 872 | } 873 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/duration.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/duration"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "DurationProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Duration represents a signed, fixed-length span of time represented 44 | // as a count of seconds and fractions of seconds at nanosecond 45 | // resolution. It is independent of any calendar and concepts like "day" 46 | // or "month". It is related to Timestamp in that the difference between 47 | // two Timestamp values is a Duration and it can be added or subtracted 48 | // from a Timestamp. Range is approximately +-10,000 years. 49 | // 50 | // # Examples 51 | // 52 | // Example 1: Compute Duration from two Timestamps in pseudo code. 53 | // 54 | // Timestamp start = ...; 55 | // Timestamp end = ...; 56 | // Duration duration = ...; 57 | // 58 | // duration.seconds = end.seconds - start.seconds; 59 | // duration.nanos = end.nanos - start.nanos; 60 | // 61 | // if (duration.seconds < 0 && duration.nanos > 0) { 62 | // duration.seconds += 1; 63 | // duration.nanos -= 1000000000; 64 | // } else if (durations.seconds > 0 && duration.nanos < 0) { 65 | // duration.seconds -= 1; 66 | // duration.nanos += 1000000000; 67 | // } 68 | // 69 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 70 | // 71 | // Timestamp start = ...; 72 | // Duration duration = ...; 73 | // Timestamp end = ...; 74 | // 75 | // end.seconds = start.seconds + duration.seconds; 76 | // end.nanos = start.nanos + duration.nanos; 77 | // 78 | // if (end.nanos < 0) { 79 | // end.seconds -= 1; 80 | // end.nanos += 1000000000; 81 | // } else if (end.nanos >= 1000000000) { 82 | // end.seconds += 1; 83 | // end.nanos -= 1000000000; 84 | // } 85 | // 86 | // Example 3: Compute Duration from datetime.timedelta in Python. 87 | // 88 | // td = datetime.timedelta(days=3, minutes=10) 89 | // duration = Duration() 90 | // duration.FromTimedelta(td) 91 | // 92 | // # JSON Mapping 93 | // 94 | // In JSON format, the Duration type is encoded as a string rather than an 95 | // object, where the string ends in the suffix "s" (indicating seconds) and 96 | // is preceded by the number of seconds, with nanoseconds expressed as 97 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be 98 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 99 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 100 | // microsecond should be expressed in JSON format as "3.000001s". 101 | // 102 | // 103 | message Duration { 104 | 105 | // Signed seconds of the span of time. Must be from -315,576,000,000 106 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: 107 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 108 | int64 seconds = 1; 109 | 110 | // Signed fractions of a second at nanosecond resolution of the span 111 | // of time. Durations less than one second are represented with a 0 112 | // `seconds` field and a positive or negative `nanos` field. For durations 113 | // of one second or more, a non-zero value for the `nanos` field must be 114 | // of the same sign as the `seconds` field. Must be from -999,999,999 115 | // to +999,999,999 inclusive. 116 | int32 nanos = 2; 117 | } 118 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/empty"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "EmptyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | option cc_enable_arenas = true; 42 | 43 | // A generic empty message that you can re-use to avoid defining duplicated 44 | // empty messages in your APIs. A typical example is to use it as the request 45 | // or the response type of an API method. For instance: 46 | // 47 | // service Foo { 48 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 49 | // } 50 | // 51 | // The JSON representation for `Empty` is empty JSON object `{}`. 52 | message Empty {} 53 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/field_mask.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "FieldMaskProto"; 38 | option java_multiple_files = true; 39 | option objc_class_prefix = "GPB"; 40 | option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; 41 | 42 | // `FieldMask` represents a set of symbolic field paths, for example: 43 | // 44 | // paths: "f.a" 45 | // paths: "f.b.d" 46 | // 47 | // Here `f` represents a field in some root message, `a` and `b` 48 | // fields in the message found in `f`, and `d` a field found in the 49 | // message in `f.b`. 50 | // 51 | // Field masks are used to specify a subset of fields that should be 52 | // returned by a get operation or modified by an update operation. 53 | // Field masks also have a custom JSON encoding (see below). 54 | // 55 | // # Field Masks in Projections 56 | // 57 | // When used in the context of a projection, a response message or 58 | // sub-message is filtered by the API to only contain those fields as 59 | // specified in the mask. For example, if the mask in the previous 60 | // example is applied to a response message as follows: 61 | // 62 | // f { 63 | // a : 22 64 | // b { 65 | // d : 1 66 | // x : 2 67 | // } 68 | // y : 13 69 | // } 70 | // z: 8 71 | // 72 | // The result will not contain specific values for fields x,y and z 73 | // (their value will be set to the default, and omitted in proto text 74 | // output): 75 | // 76 | // 77 | // f { 78 | // a : 22 79 | // b { 80 | // d : 1 81 | // } 82 | // } 83 | // 84 | // A repeated field is not allowed except at the last position of a 85 | // paths string. 86 | // 87 | // If a FieldMask object is not present in a get operation, the 88 | // operation applies to all fields (as if a FieldMask of all fields 89 | // had been specified). 90 | // 91 | // Note that a field mask does not necessarily apply to the 92 | // top-level response message. In case of a REST get operation, the 93 | // field mask applies directly to the response, but in case of a REST 94 | // list operation, the mask instead applies to each individual message 95 | // in the returned resource list. In case of a REST custom method, 96 | // other definitions may be used. Where the mask applies will be 97 | // clearly documented together with its declaration in the API. In 98 | // any case, the effect on the returned resource/resources is required 99 | // behavior for APIs. 100 | // 101 | // # Field Masks in Update Operations 102 | // 103 | // A field mask in update operations specifies which fields of the 104 | // targeted resource are going to be updated. The API is required 105 | // to only change the values of the fields as specified in the mask 106 | // and leave the others untouched. If a resource is passed in to 107 | // describe the updated values, the API ignores the values of all 108 | // fields not covered by the mask. 109 | // 110 | // If a repeated field is specified for an update operation, the existing 111 | // repeated values in the target resource will be overwritten by the new values. 112 | // Note that a repeated field is only allowed in the last position of a `paths` 113 | // string. 114 | // 115 | // If a sub-message is specified in the last position of the field mask for an 116 | // update operation, then the existing sub-message in the target resource is 117 | // overwritten. Given the target message: 118 | // 119 | // f { 120 | // b { 121 | // d : 1 122 | // x : 2 123 | // } 124 | // c : 1 125 | // } 126 | // 127 | // And an update message: 128 | // 129 | // f { 130 | // b { 131 | // d : 10 132 | // } 133 | // } 134 | // 135 | // then if the field mask is: 136 | // 137 | // paths: "f.b" 138 | // 139 | // then the result will be: 140 | // 141 | // f { 142 | // b { 143 | // d : 10 144 | // } 145 | // c : 1 146 | // } 147 | // 148 | // However, if the update mask was: 149 | // 150 | // paths: "f.b.d" 151 | // 152 | // then the result would be: 153 | // 154 | // f { 155 | // b { 156 | // d : 10 157 | // x : 2 158 | // } 159 | // c : 1 160 | // } 161 | // 162 | // In order to reset a field's value to the default, the field must 163 | // be in the mask and set to the default value in the provided resource. 164 | // Hence, in order to reset all fields of a resource, provide a default 165 | // instance of the resource and set all fields in the mask, or do 166 | // not provide a mask as described below. 167 | // 168 | // If a field mask is not present on update, the operation applies to 169 | // all fields (as if a field mask of all fields has been specified). 170 | // Note that in the presence of schema evolution, this may mean that 171 | // fields the client does not know and has therefore not filled into 172 | // the request will be reset to their default. If this is unwanted 173 | // behavior, a specific service may require a client to always specify 174 | // a field mask, producing an error if not. 175 | // 176 | // As with get operations, the location of the resource which 177 | // describes the updated values in the request message depends on the 178 | // operation kind. In any case, the effect of the field mask is 179 | // required to be honored by the API. 180 | // 181 | // ## Considerations for HTTP REST 182 | // 183 | // The HTTP kind of an update operation which uses a field mask must 184 | // be set to PATCH instead of PUT in order to satisfy HTTP semantics 185 | // (PUT must only be used for full updates). 186 | // 187 | // # JSON Encoding of Field Masks 188 | // 189 | // In JSON, a field mask is encoded as a single string where paths are 190 | // separated by a comma. Fields name in each path are converted 191 | // to/from lower-camel naming conventions. 192 | // 193 | // As an example, consider the following message declarations: 194 | // 195 | // message Profile { 196 | // User user = 1; 197 | // Photo photo = 2; 198 | // } 199 | // message User { 200 | // string display_name = 1; 201 | // string address = 2; 202 | // } 203 | // 204 | // In proto a field mask for `Profile` may look as such: 205 | // 206 | // mask { 207 | // paths: "user.display_name" 208 | // paths: "photo" 209 | // } 210 | // 211 | // In JSON, the same mask is represented as below: 212 | // 213 | // { 214 | // mask: "user.displayName,photo" 215 | // } 216 | // 217 | // # Field Masks and Oneof Fields 218 | // 219 | // Field masks treat fields in oneofs just as regular fields. Consider the 220 | // following message: 221 | // 222 | // message SampleMessage { 223 | // oneof test_oneof { 224 | // string name = 4; 225 | // SubMessage sub_message = 9; 226 | // } 227 | // } 228 | // 229 | // The field mask can be: 230 | // 231 | // mask { 232 | // paths: "name" 233 | // } 234 | // 235 | // Or: 236 | // 237 | // mask { 238 | // paths: "sub_message" 239 | // } 240 | // 241 | // Note that oneof type names ("test_oneof" in this case) cannot be used in 242 | // paths. 243 | // 244 | // ## Field Mask Verification 245 | // 246 | // The implementation of the all the API methods, which have any FieldMask type 247 | // field in the request, should verify the included field paths, and return 248 | // `INVALID_ARGUMENT` error if any path is duplicated or unmappable. 249 | message FieldMask { 250 | // The set of field mask paths. 251 | repeated string paths = 1; 252 | } 253 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/source_context.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "SourceContextProto"; 38 | option java_multiple_files = true; 39 | option objc_class_prefix = "GPB"; 40 | option go_package = "google.golang.org/genproto/protobuf/source_context;source_context"; 41 | 42 | // `SourceContext` represents information about the source of a 43 | // protobuf element, like the file in which it is defined. 44 | message SourceContext { 45 | // The path-qualified name of the .proto file that contained the associated 46 | // protobuf element. For example: `"google/protobuf/source_context.proto"`. 47 | string file_name = 1; 48 | } 49 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/struct.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "StructProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | 44 | // `Struct` represents a structured data value, consisting of fields 45 | // which map to dynamically typed values. In some languages, `Struct` 46 | // might be supported by a native representation. For example, in 47 | // scripting languages like JS a struct is represented as an 48 | // object. The details of that representation are described together 49 | // with the proto support for the language. 50 | // 51 | // The JSON representation for `Struct` is JSON object. 52 | message Struct { 53 | // Unordered map of dynamically typed values. 54 | map fields = 1; 55 | } 56 | 57 | // `Value` represents a dynamically typed value which can be either 58 | // null, a number, a string, a boolean, a recursive struct value, or a 59 | // list of values. A producer of value is expected to set one of that 60 | // variants, absence of any variant indicates an error. 61 | // 62 | // The JSON representation for `Value` is JSON value. 63 | message Value { 64 | // The kind of value. 65 | oneof kind { 66 | // Represents a null value. 67 | NullValue null_value = 1; 68 | // Represents a double value. 69 | double number_value = 2; 70 | // Represents a string value. 71 | string string_value = 3; 72 | // Represents a boolean value. 73 | bool bool_value = 4; 74 | // Represents a structured value. 75 | Struct struct_value = 5; 76 | // Represents a repeated `Value`. 77 | ListValue list_value = 6; 78 | } 79 | } 80 | 81 | // `NullValue` is a singleton enumeration to represent the null value for the 82 | // `Value` type union. 83 | // 84 | // The JSON representation for `NullValue` is JSON `null`. 85 | enum NullValue { 86 | // Null value. 87 | NULL_VALUE = 0; 88 | } 89 | 90 | // `ListValue` is a wrapper around a repeated field of values. 91 | // 92 | // The JSON representation for `ListValue` is JSON array. 93 | message ListValue { 94 | // Repeated field of dynamically typed values. 95 | repeated Value values = 1; 96 | } 97 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/timestamp"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Timestamp represents a point in time independent of any time zone 44 | // or calendar, represented as seconds and fractions of seconds at 45 | // nanosecond resolution in UTC Epoch time. It is encoded using the 46 | // Proleptic Gregorian Calendar which extends the Gregorian calendar 47 | // backwards to year one. It is encoded assuming all minutes are 60 48 | // seconds long, i.e. leap seconds are "smeared" so that no leap second 49 | // table is needed for interpretation. Range is from 50 | // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. 51 | // By restricting to that range, we ensure that we can convert to 52 | // and from RFC 3339 date strings. 53 | // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). 54 | // 55 | // # Examples 56 | // 57 | // Example 1: Compute Timestamp from POSIX `time()`. 58 | // 59 | // Timestamp timestamp; 60 | // timestamp.set_seconds(time(NULL)); 61 | // timestamp.set_nanos(0); 62 | // 63 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 64 | // 65 | // struct timeval tv; 66 | // gettimeofday(&tv, NULL); 67 | // 68 | // Timestamp timestamp; 69 | // timestamp.set_seconds(tv.tv_sec); 70 | // timestamp.set_nanos(tv.tv_usec * 1000); 71 | // 72 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 73 | // 74 | // FILETIME ft; 75 | // GetSystemTimeAsFileTime(&ft); 76 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 77 | // 78 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 79 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 80 | // Timestamp timestamp; 81 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 82 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 83 | // 84 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 85 | // 86 | // long millis = System.currentTimeMillis(); 87 | // 88 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 89 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 90 | // 91 | // 92 | // Example 5: Compute Timestamp from current time in Python. 93 | // 94 | // timestamp = Timestamp() 95 | // timestamp.GetCurrentTime() 96 | // 97 | // # JSON Mapping 98 | // 99 | // In JSON format, the Timestamp type is encoded as a string in the 100 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 101 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 102 | // where {year} is always expressed using four digits while {month}, {day}, 103 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 104 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 105 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 106 | // is required, though only UTC (as indicated by "Z") is presently supported. 107 | // 108 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 109 | // 01:30 UTC on January 15, 2017. 110 | // 111 | // In JavaScript, one can convert a Date object to this format using the 112 | // standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] 113 | // method. In Python, a standard `datetime.datetime` object can be converted 114 | // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) 115 | // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one 116 | // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( 117 | // http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) 118 | // to obtain a formatter capable of generating timestamps in this format. 119 | // 120 | // 121 | message Timestamp { 122 | 123 | // Represents seconds of UTC time since Unix epoch 124 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 125 | // 9999-12-31T23:59:59Z inclusive. 126 | int64 seconds = 1; 127 | 128 | // Non-negative fractions of a second at nanosecond resolution. Negative 129 | // second values with fractions must still have non-negative nanos values 130 | // that count forward in time. Must be from 0 to 999,999,999 131 | // inclusive. 132 | int32 nanos = 2; 133 | } 134 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/type.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | import "google/protobuf/any.proto"; 36 | import "google/protobuf/source_context.proto"; 37 | 38 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 39 | option cc_enable_arenas = true; 40 | option java_package = "com.google.protobuf"; 41 | option java_outer_classname = "TypeProto"; 42 | option java_multiple_files = true; 43 | option objc_class_prefix = "GPB"; 44 | option go_package = "google.golang.org/genproto/protobuf/ptype;ptype"; 45 | 46 | // A protocol buffer message type. 47 | message Type { 48 | // The fully qualified message name. 49 | string name = 1; 50 | // The list of fields. 51 | repeated Field fields = 2; 52 | // The list of types appearing in `oneof` definitions in this type. 53 | repeated string oneofs = 3; 54 | // The protocol buffer options. 55 | repeated Option options = 4; 56 | // The source context. 57 | SourceContext source_context = 5; 58 | // The source syntax. 59 | Syntax syntax = 6; 60 | } 61 | 62 | // A single field of a message type. 63 | message Field { 64 | // Basic field types. 65 | enum Kind { 66 | // Field type unknown. 67 | TYPE_UNKNOWN = 0; 68 | // Field type double. 69 | TYPE_DOUBLE = 1; 70 | // Field type float. 71 | TYPE_FLOAT = 2; 72 | // Field type int64. 73 | TYPE_INT64 = 3; 74 | // Field type uint64. 75 | TYPE_UINT64 = 4; 76 | // Field type int32. 77 | TYPE_INT32 = 5; 78 | // Field type fixed64. 79 | TYPE_FIXED64 = 6; 80 | // Field type fixed32. 81 | TYPE_FIXED32 = 7; 82 | // Field type bool. 83 | TYPE_BOOL = 8; 84 | // Field type string. 85 | TYPE_STRING = 9; 86 | // Field type group. Proto2 syntax only, and deprecated. 87 | TYPE_GROUP = 10; 88 | // Field type message. 89 | TYPE_MESSAGE = 11; 90 | // Field type bytes. 91 | TYPE_BYTES = 12; 92 | // Field type uint32. 93 | TYPE_UINT32 = 13; 94 | // Field type enum. 95 | TYPE_ENUM = 14; 96 | // Field type sfixed32. 97 | TYPE_SFIXED32 = 15; 98 | // Field type sfixed64. 99 | TYPE_SFIXED64 = 16; 100 | // Field type sint32. 101 | TYPE_SINT32 = 17; 102 | // Field type sint64. 103 | TYPE_SINT64 = 18; 104 | }; 105 | 106 | // Whether a field is optional, required, or repeated. 107 | enum Cardinality { 108 | // For fields with unknown cardinality. 109 | CARDINALITY_UNKNOWN = 0; 110 | // For optional fields. 111 | CARDINALITY_OPTIONAL = 1; 112 | // For required fields. Proto2 syntax only. 113 | CARDINALITY_REQUIRED = 2; 114 | // For repeated fields. 115 | CARDINALITY_REPEATED = 3; 116 | }; 117 | 118 | // The field type. 119 | Kind kind = 1; 120 | // The field cardinality. 121 | Cardinality cardinality = 2; 122 | // The field number. 123 | int32 number = 3; 124 | // The field name. 125 | string name = 4; 126 | // The field type URL, without the scheme, for message or enumeration 127 | // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. 128 | string type_url = 6; 129 | // The index of the field type in `Type.oneofs`, for message or enumeration 130 | // types. The first type has index 1; zero means the type is not in the list. 131 | int32 oneof_index = 7; 132 | // Whether to use alternative packed wire representation. 133 | bool packed = 8; 134 | // The protocol buffer options. 135 | repeated Option options = 9; 136 | // The field JSON name. 137 | string json_name = 10; 138 | // The string value of the default value of this field. Proto2 syntax only. 139 | string default_value = 11; 140 | } 141 | 142 | // Enum type definition. 143 | message Enum { 144 | // Enum type name. 145 | string name = 1; 146 | // Enum value definitions. 147 | repeated EnumValue enumvalue = 2; 148 | // Protocol buffer options. 149 | repeated Option options = 3; 150 | // The source context. 151 | SourceContext source_context = 4; 152 | // The source syntax. 153 | Syntax syntax = 5; 154 | } 155 | 156 | // Enum value definition. 157 | message EnumValue { 158 | // Enum value name. 159 | string name = 1; 160 | // Enum value number. 161 | int32 number = 2; 162 | // Protocol buffer options. 163 | repeated Option options = 3; 164 | } 165 | 166 | // A protocol buffer option, which can be attached to a message, field, 167 | // enumeration, etc. 168 | message Option { 169 | // The option's name. For protobuf built-in options (options defined in 170 | // descriptor.proto), this is the short name. For example, `"map_entry"`. 171 | // For custom options, it should be the fully-qualified name. For example, 172 | // `"google.api.http"`. 173 | string name = 1; 174 | // The option's value packed in an Any message. If the value is a primitive, 175 | // the corresponding wrapper type defined in google/protobuf/wrappers.proto 176 | // should be used. If the value is an enum, it should be stored as an int32 177 | // value using the google.protobuf.Int32Value type. 178 | Any value = 2; 179 | } 180 | 181 | // The syntax in which a protocol buffer element is defined. 182 | enum Syntax { 183 | // Syntax `proto2`. 184 | SYNTAX_PROTO2 = 0; 185 | // Syntax `proto3`. 186 | SYNTAX_PROTO3 = 1; 187 | } 188 | -------------------------------------------------------------------------------- /proto/include/google/protobuf/wrappers.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Wrappers for primitive (non-message) types. These types are useful 32 | // for embedding primitives in the `google.protobuf.Any` type and for places 33 | // where we need to distinguish between the absence of a primitive 34 | // typed field and its default value. 35 | 36 | syntax = "proto3"; 37 | 38 | package google.protobuf; 39 | 40 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 41 | option cc_enable_arenas = true; 42 | option go_package = "github.com/golang/protobuf/ptypes/wrappers"; 43 | option java_package = "com.google.protobuf"; 44 | option java_outer_classname = "WrappersProto"; 45 | option java_multiple_files = true; 46 | option objc_class_prefix = "GPB"; 47 | 48 | // Wrapper message for `double`. 49 | // 50 | // The JSON representation for `DoubleValue` is JSON number. 51 | message DoubleValue { 52 | // The double value. 53 | double value = 1; 54 | } 55 | 56 | // Wrapper message for `float`. 57 | // 58 | // The JSON representation for `FloatValue` is JSON number. 59 | message FloatValue { 60 | // The float value. 61 | float value = 1; 62 | } 63 | 64 | // Wrapper message for `int64`. 65 | // 66 | // The JSON representation for `Int64Value` is JSON string. 67 | message Int64Value { 68 | // The int64 value. 69 | int64 value = 1; 70 | } 71 | 72 | // Wrapper message for `uint64`. 73 | // 74 | // The JSON representation for `UInt64Value` is JSON string. 75 | message UInt64Value { 76 | // The uint64 value. 77 | uint64 value = 1; 78 | } 79 | 80 | // Wrapper message for `int32`. 81 | // 82 | // The JSON representation for `Int32Value` is JSON number. 83 | message Int32Value { 84 | // The int32 value. 85 | int32 value = 1; 86 | } 87 | 88 | // Wrapper message for `uint32`. 89 | // 90 | // The JSON representation for `UInt32Value` is JSON number. 91 | message UInt32Value { 92 | // The uint32 value. 93 | uint32 value = 1; 94 | } 95 | 96 | // Wrapper message for `bool`. 97 | // 98 | // The JSON representation for `BoolValue` is JSON `true` and `false`. 99 | message BoolValue { 100 | // The bool value. 101 | bool value = 1; 102 | } 103 | 104 | // Wrapper message for `string`. 105 | // 106 | // The JSON representation for `StringValue` is JSON string. 107 | message StringValue { 108 | // The string value. 109 | string value = 1; 110 | } 111 | 112 | // Wrapper message for `bytes`. 113 | // 114 | // The JSON representation for `BytesValue` is JSON string. 115 | message BytesValue { 116 | // The bytes value. 117 | bytes value = 1; 118 | } 119 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattn/ft/9e7480c2aa55abf7b75f3d5310bb32157c4fd4ba/screenshot.gif --------------------------------------------------------------------------------