Coverage for django_napse/utils/errors/api.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-03-12 13:49 +0000

1from rest_framework.exceptions import APIException 

2 

3 

4class APIError: 

5 """Base class for API errors.""" 

6 

7 class MissingSpace(APIException): 

8 status_code = 400 

9 default_detail = "Missing space uuid in request data" 

10 default_code = "missing_space" 

11 

12 class InvalidSpace(APIException): 

13 status_code = 400 

14 default_detail = "Space uuid is invalid" 

15 default_code = "invalid_space" 

16 

17 class InvalidPermissions(APIException): 

18 status_code = 403 

19 default_detail = "API key does not have the required permissions." 

20 default_code = "invalid_permissions" 

21 

22 class NoAPIKey(APIException): 

23 status_code = 403 

24 default_detail = "No API key was provided. Please provide an API key in the Authorization header. (Authorization: Api-Key <key>)" 

25 default_code = "no_api_key" 

26 

27 class InvalidAPIKey(APIException): 

28 status_code = 403 

29 default_detail = "Invalid API key." 

30 default_code = "invalid_api_key"