-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexceptions.py
212 lines (152 loc) · 5.08 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
"""
Exception definitions
"""
from django.utils.encoding import force_text
from rest_framework.exceptions import APIException
class InvalidParamDict(APIException):
"""
Class for exceptions due to the `param_dict` not being in the
right format.
Desired parameters for update should be passed in as a dictionary like
the following:
{'transcoder_type': 'transcoded'}
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 400
class InvalidParameter(APIException):
"""
Class for exceptions due to invalid parameters.
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 400
class MissingParameter(APIException):
"""
Class for exceptions due to missing required parameters.
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 400
class NoApiKey(APIException):
"""
Class for exceptions due to missing API Key
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class NoAccessKey(APIException):
"""
Class for exceptions due to missing Access Key
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class InvalidApiKey(APIException):
"""
Class for exceptions due to invalid API Key
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class InvalidAccessKey(APIException):
"""
Class for exceptions due to invalid Access Key
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class BadAccountStatus(APIException):
"""
Class for exceptions due to account being in bad status
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class FeatureNotEnabled(APIException):
"""
Class for exceptions due to disabled features
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class TrialExceeded(APIException):
"""
Class for exceptions due to maxed out trial account
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 401
class RecordUnaccessible(APIException):
"""
Class for exceptions due to unaccessible records due to
insufficient permissions
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 403
class RecordNotFound(APIException):
"""
Class for exceptions due to records not found
"""
def __init__(self, error):
self.detail = error['message']
self.status_code = 404
class RecordDeleted(APIException):
"""
Class for exceptions due to records being deleted
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 410
class RecordInvalid(APIException):
"""
Class for exceptions due to invalid records
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 422
class InvalidInteraction(APIException):
"""
Class for exceptions due to invalid interactions
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 422
class InvalidStateChange(APIException):
"""
Class for exceptions due to invalid state changes.
i.e. attempting to stop a stream that's not running
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 422
class ConnectionCodeNotSupported(APIException):
"""
Class for exceptions due to connection code regeneration attempts with
providers who do not use connection codes (i.e. akamai)
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 405
class TokenAuthBusy(APIException):
"""
Class for exceptions due to outstanding token auth requests being processed
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 423
class GeoblockingBusy(APIException):
"""
Class for exceptions due to outstanding geoblocking requests being processed
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 423
class LimitReached(APIException):
"""
Class for exceptions caused by reaching the limits of the account
"""
def __init__(self, error):
self.detail = {'error': [force_text(error['message'])]}
self.status_code = 409