From e2362adb43da163224ecd24644c852cb9295adbf Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Fri, 24 Aug 2018 08:35:26 -0500
Subject: [PATCH] Adding v2 for API

Instantiating a second version for the API.  For now, it's identical
to v1, but can be customized as needed in the future.
---
 config/settings/base.py                          | 2 +-
 gracedb/api/urls.py                              | 2 +-
 gracedb/api/v2/events/fields.py                  | 1 +
 gracedb/api/v2/events/tests/__init__.py          | 0
 gracedb/api/v2/events/tests/mixins.py            | 1 +
 gracedb/api/v2/events/throttles.py               | 1 +
 gracedb/api/v2/events/urls.py                    | 1 +
 gracedb/api/v2/events/views.py                   | 1 +
 gracedb/api/v2/fields.py                         | 1 +
 gracedb/api/v2/filters.py                        | 1 +
 gracedb/api/v2/main/__init__.py                  | 0
 gracedb/api/v2/main/views.py                     | 1 +
 gracedb/api/v2/mixins.py                         | 1 +
 gracedb/api/v2/paginators.py                     | 1 +
 gracedb/api/v2/settings.py                       | 3 +++
 gracedb/api/v2/superevents/filters.py            | 1 +
 gracedb/api/v2/superevents/paginators.py         | 1 +
 gracedb/api/v2/superevents/permissions.py        | 1 +
 gracedb/api/v2/superevents/serializers.py        | 1 +
 gracedb/api/v2/superevents/settings.py           | 1 +
 gracedb/api/v2/superevents/tests/__init__.py     | 0
 gracedb/api/v2/superevents/tests/mixins.py       | 1 +
 gracedb/api/v2/superevents/tests/test_access.py  | 3 +++
 gracedb/api/v2/superevents/tests/test_methods.py | 1 +
 gracedb/api/v2/superevents/url_templates.py      | 1 +
 gracedb/api/v2/superevents/urls.py               | 1 +
 gracedb/api/v2/superevents/views.py              | 1 +
 gracedb/api/v2/superevents/viewsets.py           | 1 +
 gracedb/api/v2/throttles.py                      | 1 +
 gracedb/api/v2/urls.py                           | 1 +
 gracedb/api/v2/viewsets.py                       | 1 +
 31 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 gracedb/api/v2/events/fields.py
 create mode 100644 gracedb/api/v2/events/tests/__init__.py
 create mode 100644 gracedb/api/v2/events/tests/mixins.py
 create mode 100644 gracedb/api/v2/events/throttles.py
 create mode 100644 gracedb/api/v2/events/urls.py
 create mode 100644 gracedb/api/v2/events/views.py
 create mode 100644 gracedb/api/v2/fields.py
 create mode 100644 gracedb/api/v2/filters.py
 create mode 100644 gracedb/api/v2/main/__init__.py
 create mode 100644 gracedb/api/v2/main/views.py
 create mode 100644 gracedb/api/v2/mixins.py
 create mode 100644 gracedb/api/v2/paginators.py
 create mode 100644 gracedb/api/v2/settings.py
 create mode 100644 gracedb/api/v2/superevents/filters.py
 create mode 100644 gracedb/api/v2/superevents/paginators.py
 create mode 100644 gracedb/api/v2/superevents/permissions.py
 create mode 100644 gracedb/api/v2/superevents/serializers.py
 create mode 100644 gracedb/api/v2/superevents/settings.py
 create mode 100644 gracedb/api/v2/superevents/tests/__init__.py
 create mode 100644 gracedb/api/v2/superevents/tests/mixins.py
 create mode 100644 gracedb/api/v2/superevents/tests/test_access.py
 create mode 100644 gracedb/api/v2/superevents/tests/test_methods.py
 create mode 100644 gracedb/api/v2/superevents/url_templates.py
 create mode 100644 gracedb/api/v2/superevents/urls.py
 create mode 100644 gracedb/api/v2/superevents/views.py
 create mode 100644 gracedb/api/v2/superevents/viewsets.py
 create mode 100644 gracedb/api/v2/throttles.py
 create mode 100644 gracedb/api/v2/urls.py
 create mode 100644 gracedb/api/v2/viewsets.py

diff --git a/config/settings/base.py b/config/settings/base.py
index 7abf0f105..1d0c6ecd7 100644
--- a/config/settings/base.py
+++ b/config/settings/base.py
@@ -336,7 +336,7 @@ REST_FRAMEWORK = {
         'api.versioning.NestedNamespaceVersioning',
         #'rest_framework.versioning.NamespaceVersioning',
     'DEFAULT_VERSION': 'default',
-    'ALLOWED_VERSIONS': ['default', 'v1'],
+    'ALLOWED_VERSIONS': ['default', 'v1', 'v2'],
     'DEFAULT_PAGINATION_CLASS':
         'rest_framework.pagination.LimitOffsetPagination',
     'PAGE_SIZE': 1e7,
diff --git a/gracedb/api/urls.py b/gracedb/api/urls.py
index 6e8f80038..60e3f4ac2 100644
--- a/gracedb/api/urls.py
+++ b/gracedb/api/urls.py
@@ -5,5 +5,5 @@ app_name = 'api'
 urlpatterns = [
     url(r'^', include('api.v1.urls', namespace='default')),
     url(r'^v1/', include('api.v1.urls', namespace='v1')),
-    #url(r'^v2/', include('api.v2.urls', namespace='v2')),
+    url(r'^v2/', include('api.v2.urls', namespace='v2')),
 ]
diff --git a/gracedb/api/v2/events/fields.py b/gracedb/api/v2/events/fields.py
new file mode 100644
index 000000000..81c40e1d6
--- /dev/null
+++ b/gracedb/api/v2/events/fields.py
@@ -0,0 +1 @@
+from ...v1.events.fields import *
diff --git a/gracedb/api/v2/events/tests/__init__.py b/gracedb/api/v2/events/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/gracedb/api/v2/events/tests/mixins.py b/gracedb/api/v2/events/tests/mixins.py
new file mode 100644
index 000000000..33f1b8da0
--- /dev/null
+++ b/gracedb/api/v2/events/tests/mixins.py
@@ -0,0 +1 @@
+from ....v1.events.tests.mixins import *
diff --git a/gracedb/api/v2/events/throttles.py b/gracedb/api/v2/events/throttles.py
new file mode 100644
index 000000000..299f54d1f
--- /dev/null
+++ b/gracedb/api/v2/events/throttles.py
@@ -0,0 +1 @@
+from ...v1.events.throttles import *
diff --git a/gracedb/api/v2/events/urls.py b/gracedb/api/v2/events/urls.py
new file mode 100644
index 000000000..b6e90d63a
--- /dev/null
+++ b/gracedb/api/v2/events/urls.py
@@ -0,0 +1 @@
+from ...v1.events.urls import *
diff --git a/gracedb/api/v2/events/views.py b/gracedb/api/v2/events/views.py
new file mode 100644
index 000000000..d79004cfe
--- /dev/null
+++ b/gracedb/api/v2/events/views.py
@@ -0,0 +1 @@
+from ...v1.events.views import *
diff --git a/gracedb/api/v2/fields.py b/gracedb/api/v2/fields.py
new file mode 100644
index 000000000..4d5ddce7f
--- /dev/null
+++ b/gracedb/api/v2/fields.py
@@ -0,0 +1 @@
+from ..v1.fields import *
diff --git a/gracedb/api/v2/filters.py b/gracedb/api/v2/filters.py
new file mode 100644
index 000000000..3075a6cce
--- /dev/null
+++ b/gracedb/api/v2/filters.py
@@ -0,0 +1 @@
+from ..v1.filters import *
diff --git a/gracedb/api/v2/main/__init__.py b/gracedb/api/v2/main/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/gracedb/api/v2/main/views.py b/gracedb/api/v2/main/views.py
new file mode 100644
index 000000000..c66bd80f6
--- /dev/null
+++ b/gracedb/api/v2/main/views.py
@@ -0,0 +1 @@
+from ...v1.main.views import *
diff --git a/gracedb/api/v2/mixins.py b/gracedb/api/v2/mixins.py
new file mode 100644
index 000000000..c892a2cbe
--- /dev/null
+++ b/gracedb/api/v2/mixins.py
@@ -0,0 +1 @@
+from ..v1.mixins import *
diff --git a/gracedb/api/v2/paginators.py b/gracedb/api/v2/paginators.py
new file mode 100644
index 000000000..627c4292e
--- /dev/null
+++ b/gracedb/api/v2/paginators.py
@@ -0,0 +1 @@
+from ..v1.paginators import *
diff --git a/gracedb/api/v2/settings.py b/gracedb/api/v2/settings.py
new file mode 100644
index 000000000..87f8ab16f
--- /dev/null
+++ b/gracedb/api/v2/settings.py
@@ -0,0 +1,3 @@
+from ..v1.settings import *
+
+API_VERSION = 'v2'
diff --git a/gracedb/api/v2/superevents/filters.py b/gracedb/api/v2/superevents/filters.py
new file mode 100644
index 000000000..0380588c2
--- /dev/null
+++ b/gracedb/api/v2/superevents/filters.py
@@ -0,0 +1 @@
+from ...v1.superevents.filters import *
diff --git a/gracedb/api/v2/superevents/paginators.py b/gracedb/api/v2/superevents/paginators.py
new file mode 100644
index 000000000..505534a35
--- /dev/null
+++ b/gracedb/api/v2/superevents/paginators.py
@@ -0,0 +1 @@
+from ...v1.superevents.paginators import *
diff --git a/gracedb/api/v2/superevents/permissions.py b/gracedb/api/v2/superevents/permissions.py
new file mode 100644
index 000000000..404688aac
--- /dev/null
+++ b/gracedb/api/v2/superevents/permissions.py
@@ -0,0 +1 @@
+from ...v1.superevents.permissions import *
diff --git a/gracedb/api/v2/superevents/serializers.py b/gracedb/api/v2/superevents/serializers.py
new file mode 100644
index 000000000..e86e188d8
--- /dev/null
+++ b/gracedb/api/v2/superevents/serializers.py
@@ -0,0 +1 @@
+from ...v1.superevents.serializers import *
diff --git a/gracedb/api/v2/superevents/settings.py b/gracedb/api/v2/superevents/settings.py
new file mode 100644
index 000000000..fe6c43d21
--- /dev/null
+++ b/gracedb/api/v2/superevents/settings.py
@@ -0,0 +1 @@
+from ...v1.superevents.settings import *
diff --git a/gracedb/api/v2/superevents/tests/__init__.py b/gracedb/api/v2/superevents/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/gracedb/api/v2/superevents/tests/mixins.py b/gracedb/api/v2/superevents/tests/mixins.py
new file mode 100644
index 000000000..c3cbfe776
--- /dev/null
+++ b/gracedb/api/v2/superevents/tests/mixins.py
@@ -0,0 +1 @@
+from ....v1.superevents.tests.mixins import *
diff --git a/gracedb/api/v2/superevents/tests/test_access.py b/gracedb/api/v2/superevents/tests/test_access.py
new file mode 100644
index 000000000..d6a109149
--- /dev/null
+++ b/gracedb/api/v2/superevents/tests/test_access.py
@@ -0,0 +1,3 @@
+from ....v1.superevents.tests.test_access import *
+
+from ...settings import API_VERSION
diff --git a/gracedb/api/v2/superevents/tests/test_methods.py b/gracedb/api/v2/superevents/tests/test_methods.py
new file mode 100644
index 000000000..61c16b2a3
--- /dev/null
+++ b/gracedb/api/v2/superevents/tests/test_methods.py
@@ -0,0 +1 @@
+from ....v1.superevents.tests.test_methods import *
diff --git a/gracedb/api/v2/superevents/url_templates.py b/gracedb/api/v2/superevents/url_templates.py
new file mode 100644
index 000000000..577cf6d20
--- /dev/null
+++ b/gracedb/api/v2/superevents/url_templates.py
@@ -0,0 +1 @@
+from ...v1.superevents.url_templates import *
diff --git a/gracedb/api/v2/superevents/urls.py b/gracedb/api/v2/superevents/urls.py
new file mode 100644
index 000000000..1a7d58329
--- /dev/null
+++ b/gracedb/api/v2/superevents/urls.py
@@ -0,0 +1 @@
+from ...v1.superevents.urls import *
diff --git a/gracedb/api/v2/superevents/views.py b/gracedb/api/v2/superevents/views.py
new file mode 100644
index 000000000..6a914f530
--- /dev/null
+++ b/gracedb/api/v2/superevents/views.py
@@ -0,0 +1 @@
+from ...v1.superevents.views import *
diff --git a/gracedb/api/v2/superevents/viewsets.py b/gracedb/api/v2/superevents/viewsets.py
new file mode 100644
index 000000000..3658f9aef
--- /dev/null
+++ b/gracedb/api/v2/superevents/viewsets.py
@@ -0,0 +1 @@
+from ...v1.superevents.viewsets import *
diff --git a/gracedb/api/v2/throttles.py b/gracedb/api/v2/throttles.py
new file mode 100644
index 000000000..65db9d365
--- /dev/null
+++ b/gracedb/api/v2/throttles.py
@@ -0,0 +1 @@
+from ..v1.throttles import *
diff --git a/gracedb/api/v2/urls.py b/gracedb/api/v2/urls.py
new file mode 100644
index 000000000..9c28aabbb
--- /dev/null
+++ b/gracedb/api/v2/urls.py
@@ -0,0 +1 @@
+from ..v1.urls import *
diff --git a/gracedb/api/v2/viewsets.py b/gracedb/api/v2/viewsets.py
new file mode 100644
index 000000000..f50db6262
--- /dev/null
+++ b/gracedb/api/v2/viewsets.py
@@ -0,0 +1 @@
+from ..v1.viewsets import *
-- 
GitLab