Skip to content

Commit

Permalink
Create and use a single point my_api.__version__ used every where.
Browse files Browse the repository at this point in the history
  • Loading branch information
alainivars committed Jun 17, 2019
1 parent 28dcb80 commit 104ebed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions my_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.7.1'
17 changes: 13 additions & 4 deletions my_api/rest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from rest_framework.response import Response
from rest_framework import status

from my_api import __version__
from my_api.rest.serializers import FileToFilesystemSerializer


Expand All @@ -19,18 +20,26 @@
@api_view(['GET'])
def status_api(request):
"""
Just return ok for Icinga2 or Nagios. Function based.
For Icinga2 or Nagios. Function based.
Return 'status': 'OK' and the current version running.
"""
if request.method == 'GET':
return JsonResponse({'status': 'OK'}, status=200)
return JsonResponse({
'status': 'OK',
'version': __version__
}, status=200)


class Icinga2API(APIView):
"""
Just return ok for Icinga2 or Nagios. Class based.
For Icinga2 or Nagios. Class based.
Return 'status': 'OK' and the current version running.
"""
def get(self, request):
return Response({'status': 'OK'}, status=200)
return Response({
'status': 'OK',
'version': __version__
}, status=200)


class FileAPI(APIView):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import os
from setuptools import setup, find_packages

import my_api

here = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(here, 'README.rst')) as f:
long_description = f.read().strip()

setup(
name='drf-microservice',
version='0.7.0',
version=my_api.__version__,
author='Alain IVARS',
author_email='alainivars@gmail.com',
url='http://github.com/alainivars/drf-microservice',
Expand Down

0 comments on commit 104ebed

Please sign in to comment.