@@ -14,6 +14,10 @@ class LaunchResultBase(object):
14
14
type of the synchronous response. See :class:`LaunchEmptyResult` for an
15
15
example.
16
16
17
+ This class acts as a tagged union. Only one of the ``is_*`` methods will
18
+ return true. To get the associated value of a tag (if one exists), use the
19
+ corresponding ``get_*`` method.
20
+
17
21
:ivar str async_job_id: This response indicates that the processing is
18
22
asynchronous. The string is an id that can be used to obtain the status
19
23
of the asynchronous job.
@@ -37,25 +41,48 @@ def __init__(self, tag, value=None):
37
41
38
42
@classmethod
39
43
def async_job_id (cls , val ):
44
+ """
45
+ Create an instance of this class set to the ``async_job_id`` tag with value ``val``.
46
+
47
+ :param str val:
48
+ :rtype: LaunchResultBase
49
+ """
40
50
return cls ('async_job_id' , val )
41
51
42
52
def is_async_job_id (self ):
53
+ """
54
+ Check if the union tag is ``async_job_id``.
55
+
56
+ :rtype: bool
57
+ """
43
58
return self ._tag == 'async_job_id'
44
59
45
60
def get_async_job_id (self ):
61
+ """
62
+ This response indicates that the processing is asynchronous. The string
63
+ is an id that can be used to obtain the status of the asynchronous job.
64
+
65
+ Only call this if :meth:`is_async_job_id` is true.
66
+
67
+ :rtype: str
68
+ """
46
69
if not self .is_async_job_id ():
47
70
raise AttributeError ("tag 'async_job_id' not set" )
48
71
return self ._value
49
72
50
73
def __repr__ (self ):
51
- return 'LaunchResultBase(%r)' % self ._tag
74
+ return 'LaunchResultBase(%r, %r )' % ( self ._tag , self . _value )
52
75
53
76
class LaunchEmptyResult (LaunchResultBase ):
54
77
"""
55
78
Result returned by methods that may either launch an asynchronous job or
56
79
complete synchronously. Upon synchronous completion of the job, no
57
80
additional information is returned.
58
81
82
+ This class acts as a tagged union. Only one of the ``is_*`` methods will
83
+ return true. To get the associated value of a tag (if one exists), use the
84
+ corresponding ``get_*`` method.
85
+
59
86
:ivar complete: The job finished synchronously and successfully.
60
87
"""
61
88
@@ -77,10 +104,15 @@ def __init__(self, tag, value=None):
77
104
self ._value = value
78
105
79
106
def is_complete (self ):
107
+ """
108
+ Check if the union tag is ``complete``.
109
+
110
+ :rtype: bool
111
+ """
80
112
return self ._tag == 'complete'
81
113
82
114
def __repr__ (self ):
83
- return 'LaunchEmptyResult(%r)' % self ._tag
115
+ return 'LaunchEmptyResult(%r, %r )' % ( self ._tag , self . _value )
84
116
85
117
class PollArg (object ):
86
118
"""
@@ -140,6 +172,10 @@ class PollResultBase(object):
140
172
the information returned upon job completion. See :class:`PollEmptyResult`
141
173
for an example.
142
174
175
+ This class acts as a tagged union. Only one of the ``is_*`` methods will
176
+ return true. To get the associated value of a tag (if one exists), use the
177
+ corresponding ``get_*`` method.
178
+
143
179
:ivar in_progress: The asynchronous job is still in progress.
144
180
"""
145
181
@@ -162,16 +198,25 @@ def __init__(self, tag, value=None):
162
198
self ._value = value
163
199
164
200
def is_in_progress (self ):
201
+ """
202
+ Check if the union tag is ``in_progress``.
203
+
204
+ :rtype: bool
205
+ """
165
206
return self ._tag == 'in_progress'
166
207
167
208
def __repr__ (self ):
168
- return 'PollResultBase(%r)' % self ._tag
209
+ return 'PollResultBase(%r, %r )' % ( self ._tag , self . _value )
169
210
170
211
class PollEmptyResult (PollResultBase ):
171
212
"""
172
213
Result returned by methods that poll for the status of an asynchronous job.
173
214
Upon completion of the job, no additional information is returned.
174
215
216
+ This class acts as a tagged union. Only one of the ``is_*`` methods will
217
+ return true. To get the associated value of a tag (if one exists), use the
218
+ corresponding ``get_*`` method.
219
+
175
220
:ivar complete: The asynchronous job has completed successfully.
176
221
"""
177
222
@@ -193,15 +238,24 @@ def __init__(self, tag, value=None):
193
238
self ._value = value
194
239
195
240
def is_complete (self ):
241
+ """
242
+ Check if the union tag is ``complete``.
243
+
244
+ :rtype: bool
245
+ """
196
246
return self ._tag == 'complete'
197
247
198
248
def __repr__ (self ):
199
- return 'PollEmptyResult(%r)' % self ._tag
249
+ return 'PollEmptyResult(%r, %r )' % ( self ._tag , self . _value )
200
250
201
251
class PollError (object ):
202
252
"""
203
253
Error returned by methods for polling the status of asynchronous job.
204
254
255
+ This class acts as a tagged union. Only one of the ``is_*`` methods will
256
+ return true. To get the associated value of a tag (if one exists), use the
257
+ corresponding ``get_*`` method.
258
+
205
259
:ivar invalid_async_job_id: The job ID is invalid.
206
260
:ivar internal_error: Something went wrong with the job on Dropbox's end.
207
261
You'll need to verify that the action you were taking succeeded, and if
@@ -232,16 +286,31 @@ def __init__(self, tag, value=None):
232
286
self ._value = value
233
287
234
288
def is_invalid_async_job_id (self ):
289
+ """
290
+ Check if the union tag is ``invalid_async_job_id``.
291
+
292
+ :rtype: bool
293
+ """
235
294
return self ._tag == 'invalid_async_job_id'
236
295
237
296
def is_internal_error (self ):
297
+ """
298
+ Check if the union tag is ``internal_error``.
299
+
300
+ :rtype: bool
301
+ """
238
302
return self ._tag == 'internal_error'
239
303
240
304
def is_other (self ):
305
+ """
306
+ Check if the union tag is ``other``.
307
+
308
+ :rtype: bool
309
+ """
241
310
return self ._tag == 'other'
242
311
243
312
def __repr__ (self ):
244
- return 'PollError(%r)' % self ._tag
313
+ return 'PollError(%r, %r )' % ( self ._tag , self . _value )
245
314
246
315
LaunchResultBase ._async_job_id_validator = bv .String (min_length = 1 )
247
316
LaunchResultBase ._tagmap = {
0 commit comments