evernote-thrift 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/APACHE-LICENSE-2.0.txt +202 -0
  2. data/LICENSE +27 -0
  3. data/NOTICE +5 -0
  4. data/README.md +44 -0
  5. data/evernote-thrift.gemspec +28 -0
  6. data/lib/Evernote/EDAM/errors_constants.rb +14 -0
  7. data/lib/Evernote/EDAM/errors_types.rb +128 -0
  8. data/lib/Evernote/EDAM/limits_constants.rb +252 -0
  9. data/lib/Evernote/EDAM/limits_types.rb +13 -0
  10. data/lib/Evernote/EDAM/note_store.rb +5562 -0
  11. data/lib/Evernote/EDAM/note_store_constants.rb +14 -0
  12. data/lib/Evernote/EDAM/note_store_types.rb +1127 -0
  13. data/lib/Evernote/EDAM/types_constants.rb +20 -0
  14. data/lib/Evernote/EDAM/types_types.rb +1792 -0
  15. data/lib/Evernote/EDAM/user_store.rb +549 -0
  16. data/lib/Evernote/EDAM/user_store_constants.rb +18 -0
  17. data/lib/Evernote/EDAM/user_store_types.rb +417 -0
  18. data/lib/evernote-thrift.rb +39 -0
  19. data/lib/thrift.rb +64 -0
  20. data/lib/thrift/client.rb +62 -0
  21. data/lib/thrift/core_ext.rb +23 -0
  22. data/lib/thrift/core_ext/fixnum.rb +29 -0
  23. data/lib/thrift/exceptions.rb +84 -0
  24. data/lib/thrift/processor.rb +57 -0
  25. data/lib/thrift/protocol/base_protocol.rb +290 -0
  26. data/lib/thrift/protocol/binary_protocol.rb +229 -0
  27. data/lib/thrift/protocol/binary_protocol_accelerated.rb +39 -0
  28. data/lib/thrift/protocol/compact_protocol.rb +426 -0
  29. data/lib/thrift/serializer/deserializer.rb +33 -0
  30. data/lib/thrift/serializer/serializer.rb +34 -0
  31. data/lib/thrift/server/base_server.rb +31 -0
  32. data/lib/thrift/server/mongrel_http_server.rb +58 -0
  33. data/lib/thrift/server/nonblocking_server.rb +305 -0
  34. data/lib/thrift/server/simple_server.rb +43 -0
  35. data/lib/thrift/server/thread_pool_server.rb +75 -0
  36. data/lib/thrift/server/threaded_server.rb +47 -0
  37. data/lib/thrift/struct.rb +237 -0
  38. data/lib/thrift/struct_union.rb +192 -0
  39. data/lib/thrift/thrift_native.rb +24 -0
  40. data/lib/thrift/transport/base_server_transport.rb +37 -0
  41. data/lib/thrift/transport/base_transport.rb +107 -0
  42. data/lib/thrift/transport/buffered_transport.rb +108 -0
  43. data/lib/thrift/transport/framed_transport.rb +116 -0
  44. data/lib/thrift/transport/http_client_transport.rb +53 -0
  45. data/lib/thrift/transport/io_stream_transport.rb +39 -0
  46. data/lib/thrift/transport/memory_buffer_transport.rb +125 -0
  47. data/lib/thrift/transport/server_socket.rb +63 -0
  48. data/lib/thrift/transport/socket.rb +137 -0
  49. data/lib/thrift/transport/unix_server_socket.rb +60 -0
  50. data/lib/thrift/transport/unix_socket.rb +40 -0
  51. data/lib/thrift/types.rb +101 -0
  52. data/lib/thrift/union.rb +179 -0
  53. metadata +99 -0
data/lib/thrift.rb ADDED
@@ -0,0 +1,64 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+ # Contains some contributions under the Thrift Software License.
20
+ # Please see doc/old-thrift-license.txt in the Thrift distribution for
21
+ # details.
22
+
23
+ $:.unshift File.dirname(__FILE__)
24
+
25
+ require 'thrift/core_ext'
26
+ require 'thrift/exceptions'
27
+ require 'thrift/types'
28
+ require 'thrift/processor'
29
+ require 'thrift/client'
30
+ require 'thrift/struct'
31
+ require 'thrift/union'
32
+ require 'thrift/struct_union'
33
+
34
+ # serializer
35
+ require 'thrift/serializer/serializer'
36
+ require 'thrift/serializer/deserializer'
37
+
38
+ # protocol
39
+ require 'thrift/protocol/base_protocol'
40
+ require 'thrift/protocol/binary_protocol'
41
+ require 'thrift/protocol/binary_protocol_accelerated'
42
+ require 'thrift/protocol/compact_protocol'
43
+
44
+ # transport
45
+ require 'thrift/transport/base_transport'
46
+ require 'thrift/transport/base_server_transport'
47
+ require 'thrift/transport/socket'
48
+ require 'thrift/transport/server_socket'
49
+ require 'thrift/transport/unix_socket'
50
+ require 'thrift/transport/unix_server_socket'
51
+ require 'thrift/transport/buffered_transport'
52
+ require 'thrift/transport/framed_transport'
53
+ require 'thrift/transport/http_client_transport'
54
+ require 'thrift/transport/io_stream_transport'
55
+ require 'thrift/transport/memory_buffer_transport'
56
+
57
+ # server
58
+ require 'thrift/server/base_server'
59
+ require 'thrift/server/nonblocking_server'
60
+ require 'thrift/server/simple_server'
61
+ require 'thrift/server/threaded_server'
62
+ require 'thrift/server/thread_pool_server'
63
+
64
+ require 'thrift/thrift_native'
@@ -0,0 +1,62 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ module Thrift
21
+ module Client
22
+ def initialize(iprot, oprot=nil)
23
+ @iprot = iprot
24
+ @oprot = oprot || iprot
25
+ @seqid = 0
26
+ end
27
+
28
+ def send_message(name, args_class, args = {})
29
+ @oprot.write_message_begin(name, MessageTypes::CALL, @seqid)
30
+ data = args_class.new
31
+ args.each do |k, v|
32
+ data.send("#{k.to_s}=", v)
33
+ end
34
+ begin
35
+ data.write(@oprot)
36
+ rescue StandardError => e
37
+ @oprot.trans.close
38
+ raise e
39
+ end
40
+ @oprot.write_message_end
41
+ @oprot.trans.flush
42
+ end
43
+
44
+ def receive_message(result_klass)
45
+ fname, mtype, rseqid = @iprot.read_message_begin
46
+ handle_exception(mtype)
47
+ result = result_klass.new
48
+ result.read(@iprot)
49
+ @iprot.read_message_end
50
+ result
51
+ end
52
+
53
+ def handle_exception(mtype)
54
+ if mtype == MessageTypes::EXCEPTION
55
+ x = ApplicationException.new
56
+ x.read(@iprot)
57
+ @iprot.read_message_end
58
+ raise x
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,23 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].each do |file|
21
+ name = File.basename(file, '.rb')
22
+ require "thrift/core_ext/#{name}"
23
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ # Versions of ruby pre 1.8.7 do not have an .ord method available in the Fixnum
21
+ # class.
22
+ #
23
+ if RUBY_VERSION < "1.8.7"
24
+ class Fixnum
25
+ def ord
26
+ self
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,84 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ module Thrift
21
+ class Exception < StandardError
22
+ def initialize(message)
23
+ super
24
+ @message = message
25
+ end
26
+
27
+ attr_reader :message
28
+ end
29
+
30
+ class ApplicationException < Exception
31
+
32
+ UNKNOWN = 0
33
+ UNKNOWN_METHOD = 1
34
+ INVALID_MESSAGE_TYPE = 2
35
+ WRONG_METHOD_NAME = 3
36
+ BAD_SEQUENCE_ID = 4
37
+ MISSING_RESULT = 5
38
+ INTERNAL_ERROR = 6
39
+ PROTOCOL_ERROR = 7
40
+
41
+ attr_reader :type
42
+
43
+ def initialize(type=UNKNOWN, message=nil)
44
+ super(message)
45
+ @type = type
46
+ end
47
+
48
+ def read(iprot)
49
+ iprot.read_struct_begin
50
+ while true
51
+ fname, ftype, fid = iprot.read_field_begin
52
+ if ftype == Types::STOP
53
+ break
54
+ end
55
+ if fid == 1 and ftype == Types::STRING
56
+ @message = iprot.read_string
57
+ elsif fid == 2 and ftype == Types::I32
58
+ @type = iprot.read_i32
59
+ else
60
+ iprot.skip(ftype)
61
+ end
62
+ iprot.read_field_end
63
+ end
64
+ iprot.read_struct_end
65
+ end
66
+
67
+ def write(oprot)
68
+ oprot.write_struct_begin('Thrift::ApplicationException')
69
+ unless @message.nil?
70
+ oprot.write_field_begin('message', Types::STRING, 1)
71
+ oprot.write_string(@message)
72
+ oprot.write_field_end
73
+ end
74
+ unless @type.nil?
75
+ oprot.write_field_begin('type', Types::I32, 2)
76
+ oprot.write_i32(@type)
77
+ oprot.write_field_end
78
+ end
79
+ oprot.write_field_stop
80
+ oprot.write_struct_end
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,57 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ module Thrift
21
+ module Processor
22
+ def initialize(handler)
23
+ @handler = handler
24
+ end
25
+
26
+ def process(iprot, oprot)
27
+ name, type, seqid = iprot.read_message_begin
28
+ if respond_to?("process_#{name}")
29
+ send("process_#{name}", seqid, iprot, oprot)
30
+ true
31
+ else
32
+ iprot.skip(Types::STRUCT)
33
+ iprot.read_message_end
34
+ x = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, 'Unknown function '+name)
35
+ oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
36
+ x.write(oprot)
37
+ oprot.write_message_end
38
+ oprot.trans.flush
39
+ false
40
+ end
41
+ end
42
+
43
+ def read_args(iprot, args_class)
44
+ args = args_class.new
45
+ args.read(iprot)
46
+ iprot.read_message_end
47
+ args
48
+ end
49
+
50
+ def write_result(result, oprot, name, seqid)
51
+ oprot.write_message_begin(name, MessageTypes::REPLY, seqid)
52
+ result.write(oprot)
53
+ oprot.write_message_end
54
+ oprot.trans.flush
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,290 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ # this require is to make generated struct definitions happy
21
+ require 'set'
22
+
23
+ module Thrift
24
+ class ProtocolException < Exception
25
+
26
+ UNKNOWN = 0
27
+ INVALID_DATA = 1
28
+ NEGATIVE_SIZE = 2
29
+ SIZE_LIMIT = 3
30
+ BAD_VERSION = 4
31
+
32
+ attr_reader :type
33
+
34
+ def initialize(type=UNKNOWN, message=nil)
35
+ super(message)
36
+ @type = type
37
+ end
38
+ end
39
+
40
+ class BaseProtocol
41
+
42
+ attr_reader :trans
43
+
44
+ def initialize(trans)
45
+ @trans = trans
46
+ end
47
+
48
+ def native?
49
+ puts "wrong method is being called!"
50
+ false
51
+ end
52
+
53
+ def write_message_begin(name, type, seqid)
54
+ raise NotImplementedError
55
+ end
56
+
57
+ def write_message_end; nil; end
58
+
59
+ def write_struct_begin(name)
60
+ raise NotImplementedError
61
+ end
62
+
63
+ def write_struct_end; nil; end
64
+
65
+ def write_field_begin(name, type, id)
66
+ raise NotImplementedError
67
+ end
68
+
69
+ def write_field_end; nil; end
70
+
71
+ def write_field_stop
72
+ raise NotImplementedError
73
+ end
74
+
75
+ def write_map_begin(ktype, vtype, size)
76
+ raise NotImplementedError
77
+ end
78
+
79
+ def write_map_end; nil; end
80
+
81
+ def write_list_begin(etype, size)
82
+ raise NotImplementedError
83
+ end
84
+
85
+ def write_list_end; nil; end
86
+
87
+ def write_set_begin(etype, size)
88
+ raise NotImplementedError
89
+ end
90
+
91
+ def write_set_end; nil; end
92
+
93
+ def write_bool(bool)
94
+ raise NotImplementedError
95
+ end
96
+
97
+ def write_byte(byte)
98
+ raise NotImplementedError
99
+ end
100
+
101
+ def write_i16(i16)
102
+ raise NotImplementedError
103
+ end
104
+
105
+ def write_i32(i32)
106
+ raise NotImplementedError
107
+ end
108
+
109
+ def write_i64(i64)
110
+ raise NotImplementedError
111
+ end
112
+
113
+ def write_double(dub)
114
+ raise NotImplementedError
115
+ end
116
+
117
+ def write_string(str)
118
+ raise NotImplementedError
119
+ end
120
+
121
+ def read_message_begin
122
+ raise NotImplementedError
123
+ end
124
+
125
+ def read_message_end; nil; end
126
+
127
+ def read_struct_begin
128
+ raise NotImplementedError
129
+ end
130
+
131
+ def read_struct_end; nil; end
132
+
133
+ def read_field_begin
134
+ raise NotImplementedError
135
+ end
136
+
137
+ def read_field_end; nil; end
138
+
139
+ def read_map_begin
140
+ raise NotImplementedError
141
+ end
142
+
143
+ def read_map_end; nil; end
144
+
145
+ def read_list_begin
146
+ raise NotImplementedError
147
+ end
148
+
149
+ def read_list_end; nil; end
150
+
151
+ def read_set_begin
152
+ raise NotImplementedError
153
+ end
154
+
155
+ def read_set_end; nil; end
156
+
157
+ def read_bool
158
+ raise NotImplementedError
159
+ end
160
+
161
+ def read_byte
162
+ raise NotImplementedError
163
+ end
164
+
165
+ def read_i16
166
+ raise NotImplementedError
167
+ end
168
+
169
+ def read_i32
170
+ raise NotImplementedError
171
+ end
172
+
173
+ def read_i64
174
+ raise NotImplementedError
175
+ end
176
+
177
+ def read_double
178
+ raise NotImplementedError
179
+ end
180
+
181
+ def read_string
182
+ raise NotImplementedError
183
+ end
184
+
185
+ def write_field(name, type, fid, value)
186
+ write_field_begin(name, type, fid)
187
+ write_type(type, value)
188
+ write_field_end
189
+ end
190
+
191
+ def write_type(type, value)
192
+ case type
193
+ when Types::BOOL
194
+ write_bool(value)
195
+ when Types::BYTE
196
+ write_byte(value)
197
+ when Types::DOUBLE
198
+ write_double(value)
199
+ when Types::I16
200
+ write_i16(value)
201
+ when Types::I32
202
+ write_i32(value)
203
+ when Types::I64
204
+ write_i64(value)
205
+ when Types::STRING
206
+ write_string(value)
207
+ when Types::STRUCT
208
+ value.write(self)
209
+ else
210
+ raise NotImplementedError
211
+ end
212
+ end
213
+
214
+ def read_type(type)
215
+ case type
216
+ when Types::BOOL
217
+ read_bool
218
+ when Types::BYTE
219
+ read_byte
220
+ when Types::DOUBLE
221
+ read_double
222
+ when Types::I16
223
+ read_i16
224
+ when Types::I32
225
+ read_i32
226
+ when Types::I64
227
+ read_i64
228
+ when Types::STRING
229
+ read_string
230
+ else
231
+ raise NotImplementedError
232
+ end
233
+ end
234
+
235
+ def skip(type)
236
+ case type
237
+ when Types::STOP
238
+ nil
239
+ when Types::BOOL
240
+ read_bool
241
+ when Types::BYTE
242
+ read_byte
243
+ when Types::I16
244
+ read_i16
245
+ when Types::I32
246
+ read_i32
247
+ when Types::I64
248
+ read_i64
249
+ when Types::DOUBLE
250
+ read_double
251
+ when Types::STRING
252
+ read_string
253
+ when Types::STRUCT
254
+ read_struct_begin
255
+ while true
256
+ name, type, id = read_field_begin
257
+ break if type == Types::STOP
258
+ skip(type)
259
+ read_field_end
260
+ end
261
+ read_struct_end
262
+ when Types::MAP
263
+ ktype, vtype, size = read_map_begin
264
+ size.times do
265
+ skip(ktype)
266
+ skip(vtype)
267
+ end
268
+ read_map_end
269
+ when Types::SET
270
+ etype, size = read_set_begin
271
+ size.times do
272
+ skip(etype)
273
+ end
274
+ read_set_end
275
+ when Types::LIST
276
+ etype, size = read_list_begin
277
+ size.times do
278
+ skip(etype)
279
+ end
280
+ read_list_end
281
+ end
282
+ end
283
+ end
284
+
285
+ class BaseProtocolFactory
286
+ def get_protocol(trans)
287
+ raise NotImplementedError
288
+ end
289
+ end
290
+ end