Skip to content

Commit 21adb4f

Browse files
committed
write before the first try at getting this into the store
1 parent 15aaae5 commit 21adb4f

10 files changed

+87
-9
lines changed

Diff for: Changelog

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Version 0.1.0 2015-09-15
2+
* first version

Diff for: MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include README.rst
2+
include Changelog

Diff for: README.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary
2+
=======
3+
4+
NeoApi is an OGM built on top of NeoModel. NeoApi Classes extend the StructuredNode from NeoModel by adding methods that allow each object to be easiy serialized into json api responses that comply with the standard on http://jsonapi.org. With this framework your neo4j api will basically build itself!
5+
6+
example api
7+
===========
8+
9+
Please take a look at the sample project to get started. Also, remember to familiarize yourself with the json api specification.
10+
11+
http://github.com/buckmaxwell/sample-neo-api

Diff for: neoapi/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .serializable_structured_node import *
2+
3+
__author__ = 'Max Buck'
4+
__email__ = '[email protected]'
5+
__license__ = 'MIT'
6+
__package__ = 'neoapi'
7+
__version__ = '0.1.0'

Diff for: neoapi/application_codes.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from .http_error_codes import (OK, CREATED, BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND,
2+
CONFLICT, INTERNAL_SERVER_ERROR, NOT_ALLOWED)
3+
from flask import jsonify, make_response
4+
5+
BAD_FORMAT_VIOLATION = '4000', 'there is a problem with the request format', BAD_REQUEST
6+
UNIQUE_KEY_VIOLATION = '4001', 'a uniqueness constraint is violated by the request', BAD_REQUEST
7+
WRONG_TYPE_VIOLATION = '4002', 'the type key does not match the resource requested', BAD_REQUEST
8+
PARAMETER_NOT_SUPPORTED_VIOLATION = '4003', 'a query parameter you tried to use is not supported for this endpoint', BAD_REQUEST
9+
ENUMERATED_TYPE_VIOLATION = '4004', 'a value given for an enumerated type was unsupported', BAD_REQUEST
10+
BAD_PARAMETER_VIOLATION = '4005', 'one or more of the attributes in your request is not part of the model', BAD_REQUEST
11+
12+
RESOURCE_NOT_FOUND = '4040', 'the requested resource was not found on the server', NOT_FOUND
13+
14+
METHOD_NOT_ALLOWED = '4050', 'the http method you tried is not a legal operation on this resource', NOT_ALLOWED
15+
FORBIDDEN_VIOLATION = '4030', 'the http method you tried is forbidden.', FORBIDDEN
16+
UNAUTHORIZED_VIOLATION = '4010', 'missing or bad authorization', UNAUTHORIZED
17+
BAD_AUTHENTICATION = '4011', 'bad authorization', UNAUTHORIZED
18+
NO_AUTHENTICATION = '4012', 'no authorization header provided', UNAUTHORIZED
19+
20+
21+
def error_response(array_of_application_code_tuples):
22+
errors = list()
23+
for app_code_tuple in array_of_application_code_tuples:
24+
error = dict()
25+
error['status'] = app_code_tuple[2]
26+
error['code'] = app_code_tuple[0]
27+
error['title'] = app_code_tuple[1]
28+
errors.append(error)
29+
30+
r = make_response(jsonify({'errors': errors}))
31+
r.status_code = app_code_tuple[2]
32+
r.headers['Content-Type'] = "application/vnd.api+json; charset=utf-8"
33+
34+
return r
35+
36+

Diff for: neoapi/errors.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class WrongTypeError(Exception):
2+
3+
def __init__(self, value='wrong type error'):
4+
self.value = value
5+
6+
def __str__(self):
7+
return repr(self.value)
8+

Diff for: neoapi/http_error_codes.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
OK = 200
2+
CREATED = 201
3+
NO_CONTENT = 204
4+
BAD_REQUEST = 400
5+
UNAUTHORIZED = 401
6+
FORBIDDEN = 403
7+
NOT_FOUND = 404
8+
NOT_ALLOWED = 405
9+
CONFLICT = 409
10+
INTERNAL_SERVER_ERROR = 500

Diff for: neoapi/serializable_structured_node.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
DeflateError)
44
from py2neo.cypher.error.statement import ParameterMissing
55
import os
6-
import http_error_codes
6+
import .http_error_codes
77
from flask import jsonify, make_response
88
from neomodel import db
9-
import application_codes
10-
from errors import WrongTypeError
9+
import .application_codes
10+
from .errors import WrongTypeError
1111
from datetime import datetime
1212
import hashlib
1313

Diff for: setup.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[bdist_wheel]
2+
# This flag says that the code is written to work on both Python 2 and Python
3+
# 3. If at all possible, it is good practice to do this. If you cannot, you
4+
# will need to generate wheels for each Python version that you support.
5+
universal=1

Diff for: setup.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# 3 - Alpha
2929
# 4 - Beta
3030
# 5 - Production/Stable
31-
'Development Status :: 5 - Production/Stable',
31+
'Development Status :: 3 - Alpha',
3232

3333
# Indicate who your project is intended for
3434
'Intended Audience :: Developers',
@@ -49,7 +49,7 @@
4949
],
5050

5151
# What does your project relate to?
52-
keywords='zip codes',
52+
keywords='json api specification neomodel neo4j',
5353

5454
# You can just specify the packages manually here if your project is
5555
# simple. Or you can use find_packages().
@@ -59,14 +59,11 @@
5959
# your project is installed. For an analysis of "install_requires" vs pip's
6060
# requirements files see:
6161
# https://packaging.python.org/en/latest/requirements.html
62-
install_requires=['haversine'],
62+
install_requires=['neomodel', 'py2neo', 'flask', 'hashlib'],
6363

6464
# If there are data files included in your packages that need to be
6565
# installed, specify them here. If using Python 2.6 or less, then these
6666
# have to be included in MANIFEST.in as well.
67-
#package_data={
68-
# 'zipcode': ['zipcode.db'],
69-
#},
7067
include_package_data=True
7168

7269
)

0 commit comments

Comments
 (0)