|
2 | 2 | URL routing patterns for the Drycc REST API. |
3 | 3 | """ |
4 | 4 | from django.conf import settings |
5 | | -from django.conf.urls import include, url |
| 5 | +from django.urls import include, re_path |
6 | 6 | from rest_framework.routers import DefaultRouter |
7 | 7 | from social_core.utils import setting_name |
8 | 8 | from api import views |
|
13 | 13 |
|
14 | 14 | # Add the generated REST URLs and login/logout endpoint |
15 | 15 | app_urlpatterns = [ |
16 | | - url(r'^', include(router.urls)), |
17 | | - url(r'auth/login/?$', views.AuthLoginView.as_view({"post": "login"})), |
18 | | - url(r'auth/token/(?P<key>[-_\w]+)/?$', views.AuthTokenView.as_view({"get": "token"})), |
| 16 | + re_path(r'^', include(router.urls)), |
| 17 | + re_path(r'auth/login/?$', views.AuthLoginView.as_view({"post": "login"})), |
| 18 | + re_path(r'auth/token/(?P<key>[-_\w]+)/?$', views.AuthTokenView.as_view({"get": "token"})), |
19 | 19 | # application release components |
20 | | - url(r"^apps/(?P<id>{})/config/?$".format(settings.APP_URL_REGEX), |
| 20 | + re_path( |
| 21 | + r"^apps/(?P<id>{})/config/?$".format(settings.APP_URL_REGEX), |
21 | 22 | views.ConfigViewSet.as_view({'get': 'retrieve', 'post': 'create'})), |
22 | | - url(r"^apps/(?P<id>{})/builds/(?P<uuid>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
| 23 | + re_path( |
| 24 | + r"^apps/(?P<id>{})/builds/(?P<uuid>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
23 | 25 | views.BuildViewSet.as_view({'get': 'retrieve'})), |
24 | | - url(r"^apps/(?P<id>{})/builds/?$".format(settings.APP_URL_REGEX), |
| 26 | + re_path( |
| 27 | + r"^apps/(?P<id>{})/builds/?$".format(settings.APP_URL_REGEX), |
25 | 28 | views.BuildViewSet.as_view({'get': 'list', 'post': 'create'})), |
26 | | - url(r"^apps/(?P<id>{})/releases/v(?P<version>[0-9]+)/?$".format(settings.APP_URL_REGEX), |
| 29 | + re_path( |
| 30 | + r"^apps/(?P<id>{})/releases/v(?P<version>[0-9]+)/?$".format(settings.APP_URL_REGEX), |
27 | 31 | views.ReleaseViewSet.as_view({'get': 'retrieve'})), |
28 | | - url(r"^apps/(?P<id>{})/releases/rollback/?$".format(settings.APP_URL_REGEX), |
| 32 | + re_path( |
| 33 | + r"^apps/(?P<id>{})/releases/rollback/?$".format(settings.APP_URL_REGEX), |
29 | 34 | views.ReleaseViewSet.as_view({'post': 'rollback'})), |
30 | | - url(r"^apps/(?P<id>{})/releases/?$".format(settings.APP_URL_REGEX), |
| 35 | + re_path( |
| 36 | + r"^apps/(?P<id>{})/releases/?$".format(settings.APP_URL_REGEX), |
31 | 37 | views.ReleaseViewSet.as_view({'get': 'list'})), |
32 | 38 | # restart pods |
33 | | - url(r"^apps/(?P<id>{})/pods/restart/?$".format(settings.APP_URL_REGEX), |
| 39 | + re_path( |
| 40 | + r"^apps/(?P<id>{})/pods/restart/?$".format(settings.APP_URL_REGEX), |
34 | 41 | views.PodViewSet.as_view({'post': 'restart'})), |
35 | | - url(r"^apps/(?P<id>{})/pods/(?P<type>[-_\w.]+)/restart/?$".format(settings.APP_URL_REGEX), |
| 42 | + re_path( |
| 43 | + r"^apps/(?P<id>{})/pods/(?P<type>[-_\w.]+)/restart/?$".format(settings.APP_URL_REGEX), |
36 | 44 | views.PodViewSet.as_view({'post': 'restart'})), |
37 | | - url(r"^apps/(?P<id>{})/pods/(?P<type>[-_\w]+)/(?P<name>[-_\w]+)/restart/?$".format( |
38 | | - settings.APP_URL_REGEX), |
| 45 | + re_path( |
| 46 | + r"^apps/(?P<id>{})/pods/(?P<type>[-_\w]+)/(?P<name>[-_\w]+)/restart/?$".format( |
| 47 | + settings.APP_URL_REGEX), |
39 | 48 | views.PodViewSet.as_view({'post': 'restart'})), |
40 | 49 | # list pods |
41 | | - url(r"^apps/(?P<id>{})/pods/(?P<type>[-_\w]+)/(?P<name>[-_\w]+)/?$".format( |
42 | | - settings.APP_URL_REGEX), |
| 50 | + re_path( |
| 51 | + r"^apps/(?P<id>{})/pods/(?P<type>[-_\w]+)/(?P<name>[-_\w]+)/?$".format( |
| 52 | + settings.APP_URL_REGEX), |
43 | 53 | views.PodViewSet.as_view({'get': 'list'})), |
44 | | - url(r"^apps/(?P<id>{})/pods/(?P<type>[-_\w.]+)/?$".format(settings.APP_URL_REGEX), |
| 54 | + re_path( |
| 55 | + r"^apps/(?P<id>{})/pods/(?P<type>[-_\w.]+)/?$".format(settings.APP_URL_REGEX), |
45 | 56 | views.PodViewSet.as_view({'get': 'list'})), |
46 | | - url(r"^apps/(?P<id>{})/pods/?$".format(settings.APP_URL_REGEX), |
| 57 | + re_path( |
| 58 | + r"^apps/(?P<id>{})/pods/?$".format(settings.APP_URL_REGEX), |
47 | 59 | views.PodViewSet.as_view({'get': 'list'})), |
48 | 60 | # application domains |
49 | | - url(r"^apps/(?P<id>{})/domains/(?P<domain>\**\.?[-\._\w]+)/?$".format(settings.APP_URL_REGEX), |
| 61 | + re_path( |
| 62 | + r"^apps/(?P<id>{})/domains/(?P<domain>\**\.?[-\._\w]+)/?$".format(settings.APP_URL_REGEX), |
50 | 63 | views.DomainViewSet.as_view({'delete': 'destroy'})), |
51 | | - url(r"^apps/(?P<id>{})/domains/?$".format(settings.APP_URL_REGEX), |
| 64 | + re_path( |
| 65 | + r"^apps/(?P<id>{})/domains/?$".format(settings.APP_URL_REGEX), |
52 | 66 | views.DomainViewSet.as_view({'post': 'create', 'get': 'list'})), |
53 | 67 | # application services |
54 | | - url(r"^apps/(?P<id>{})/services/?$".format(settings.APP_URL_REGEX), |
| 68 | + re_path( |
| 69 | + r"^apps/(?P<id>{})/services/?$".format(settings.APP_URL_REGEX), |
55 | 70 | views.ServiceViewSet.as_view({'post': 'create_or_update', |
56 | 71 | 'get': 'list', 'delete': 'delete'})), |
57 | 72 | # application actions |
58 | | - url(r"^apps/(?P<id>{})/scale/?$".format(settings.APP_URL_REGEX), |
| 73 | + re_path( |
| 74 | + r"^apps/(?P<id>{})/scale/?$".format(settings.APP_URL_REGEX), |
59 | 75 | views.AppViewSet.as_view({'post': 'scale'})), |
60 | | - url(r"^apps/(?P<id>{})/logs/?$".format(settings.APP_URL_REGEX), |
| 76 | + re_path( |
| 77 | + r"^apps/(?P<id>{})/logs/?$".format(settings.APP_URL_REGEX), |
61 | 78 | views.AppViewSet.as_view({'get': 'logs'})), |
62 | | - url(r"^apps/(?P<id>{})/run/?$".format(settings.APP_URL_REGEX), |
| 79 | + re_path( |
| 80 | + r"^apps/(?P<id>{})/run/?$".format(settings.APP_URL_REGEX), |
63 | 81 | views.AppViewSet.as_view({'post': 'run'})), |
64 | 82 | # application settings |
65 | | - url(r"^apps/(?P<id>{})/settings/?$".format(settings.APP_URL_REGEX), |
| 83 | + re_path( |
| 84 | + r"^apps/(?P<id>{})/settings/?$".format(settings.APP_URL_REGEX), |
66 | 85 | views.AppSettingsViewSet.as_view({'get': 'retrieve', 'post': 'create'})), |
67 | 86 | # application ip allowlist |
68 | | - url(r"^apps/(?P<id>{})/allowlist/?$".format(settings.APP_URL_REGEX), |
| 87 | + re_path( |
| 88 | + r"^apps/(?P<id>{})/allowlist/?$".format(settings.APP_URL_REGEX), |
69 | 89 | views.AllowlistViewSet.as_view({'post': 'create', 'get': 'list', 'delete': 'delete'})), |
70 | 90 | # application TLS settings |
71 | | - url(r"^apps/(?P<id>{})/tls/?$".format(settings.APP_URL_REGEX), |
| 91 | + re_path( |
| 92 | + r"^apps/(?P<id>{})/tls/?$".format(settings.APP_URL_REGEX), |
72 | 93 | views.TLSViewSet.as_view({'get': 'retrieve', 'post': 'create'})), |
73 | 94 | # apps sharing |
74 | | - url(r"^apps/(?P<id>{})/perms/(?P<username>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
| 95 | + re_path( |
| 96 | + r"^apps/(?P<id>{})/perms/(?P<username>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
75 | 97 | views.AppPermsViewSet.as_view({'delete': 'destroy'})), |
76 | | - url(r"^apps/(?P<id>{})/perms/?$".format(settings.APP_URL_REGEX), |
| 98 | + re_path( |
| 99 | + r"^apps/(?P<id>{})/perms/?$".format(settings.APP_URL_REGEX), |
77 | 100 | views.AppPermsViewSet.as_view({'get': 'list', 'post': 'create'})), |
78 | 101 | # application volumes |
79 | | - url(r"^apps/(?P<id>{})/volumes/?$".format(settings.APP_URL_REGEX), |
| 102 | + re_path( |
| 103 | + r"^apps/(?P<id>{})/volumes/?$".format(settings.APP_URL_REGEX), |
80 | 104 | views.AppVolumesViewSet.as_view({'get': 'list', 'post': 'create'})), |
81 | | - url(r"^apps/(?P<id>{})/volumes/(?P<name>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
| 105 | + re_path( |
| 106 | + r"^apps/(?P<id>{})/volumes/(?P<name>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
82 | 107 | views.AppVolumesViewSet.as_view({'patch': 'expand', 'delete': 'destroy'})), |
83 | | - url(r"^apps/(?P<id>{})/volumes/(?P<name>[-_\w]+)/path/?$".format(settings.APP_URL_REGEX), |
| 108 | + re_path( |
| 109 | + r"^apps/(?P<id>{})/volumes/(?P<name>[-_\w]+)/path/?$".format(settings.APP_URL_REGEX), |
84 | 110 | views.AppVolumeMountPathViewSet.as_view({'patch': 'path'})), |
85 | 111 | # application resources |
86 | | - url(r"^resources/services/?$", views.AppResourcesViewSet.as_view({'get': 'services'})), |
87 | | - url(r"^resources/services/(?P<id>[-_\w]+)/plans/?$", |
| 112 | + re_path(r"^resources/services/?$", views.AppResourcesViewSet.as_view({'get': 'services'})), |
| 113 | + re_path( |
| 114 | + r"^resources/services/(?P<id>[-_\w]+)/plans/?$", |
88 | 115 | views.AppResourcesViewSet.as_view({'get': 'plans'})), |
89 | | - url(r"^apps/(?P<id>{})/resources/?$".format(settings.APP_URL_REGEX), |
| 116 | + re_path( |
| 117 | + r"^apps/(?P<id>{})/resources/?$".format(settings.APP_URL_REGEX), |
90 | 118 | views.AppResourcesViewSet.as_view({'get': 'list', 'post': 'create'})), |
91 | | - url(r"^apps/(?P<id>{})/resources/(?P<name>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
| 119 | + re_path( |
| 120 | + r"^apps/(?P<id>{})/resources/(?P<name>[-_\w]+)/?$".format(settings.APP_URL_REGEX), |
92 | 121 | views.AppSingleResourceViewSet.as_view({ |
93 | 122 | 'get': 'retrieve', |
94 | 123 | 'delete': 'destroy', |
95 | 124 | 'put': 'update' |
96 | 125 | })), |
97 | | - url(r"^apps/(?P<id>{})/resources/(?P<name>[-_\w]+)/binding/?$".format(settings.APP_URL_REGEX), |
| 126 | + re_path( |
| 127 | + r"^apps/(?P<id>{})/resources/(?P<name>[-_\w]+)/binding/?$".format(settings.APP_URL_REGEX), |
98 | 128 | views.AppResourceBindingViewSet.as_view({'patch': 'binding'})), |
99 | 129 | # apps base endpoint |
100 | | - url(r"^apps/(?P<id>{})/?$".format(settings.APP_URL_REGEX), |
| 130 | + re_path( |
| 131 | + r"^apps/(?P<id>{})/?$".format(settings.APP_URL_REGEX), |
101 | 132 | views.AppViewSet.as_view({'get': 'retrieve', 'post': 'update', 'delete': 'destroy'})), |
102 | | - url(r'^apps/?$', |
| 133 | + re_path( |
| 134 | + r'^apps/?$', |
103 | 135 | views.AppViewSet.as_view({'get': 'list', 'post': 'create'})), |
104 | 136 | # key |
105 | | - url(r'^keys/(?P<id>.+)/?$', |
| 137 | + re_path( |
| 138 | + r'^keys/(?P<id>.+)/?$', |
106 | 139 | views.KeyViewSet.as_view({'get': 'retrieve', 'delete': 'destroy'})), |
107 | | - url(r'^keys/?$', |
| 140 | + re_path( |
| 141 | + r'^keys/?$', |
108 | 142 | views.KeyViewSet.as_view({'get': 'list', 'post': 'create'})), |
109 | 143 | # hooks |
110 | | - url(r'^hooks/keys/(?P<id>{})/(?P<username>[-_\w]+)?$'.format(settings.APP_URL_REGEX), |
| 144 | + re_path( |
| 145 | + r'^hooks/keys/(?P<id>{})/(?P<username>[-_\w]+)?$'.format(settings.APP_URL_REGEX), |
111 | 146 | views.KeyHookViewSet.as_view({'get': 'users'})), |
112 | | - url(r'^hooks/keys/(?P<id>{})/?$'.format(settings.APP_URL_REGEX), |
| 147 | + re_path( |
| 148 | + r'^hooks/keys/(?P<id>{})/?$'.format(settings.APP_URL_REGEX), |
113 | 149 | views.KeyHookViewSet.as_view({'get': 'app'})), |
114 | | - url(r'^hooks/key/(?P<fingerprint>.+)/?$', |
| 150 | + re_path( |
| 151 | + r'^hooks/key/(?P<fingerprint>.+)/?$', |
115 | 152 | views.KeyHookViewSet.as_view({'get': 'public_key'})), |
116 | | - url(r'^hooks/build/?$', |
| 153 | + re_path( |
| 154 | + r'^hooks/build/?$', |
117 | 155 | views.BuildHookViewSet.as_view({'post': 'create'})), |
118 | | - url(r'^hooks/config/?$', |
| 156 | + re_path( |
| 157 | + r'^hooks/config/?$', |
119 | 158 | views.ConfigHookViewSet.as_view({'post': 'create'})), |
120 | 159 | # authn / authz |
121 | | - url(r'^auth/whoami/?$', |
| 160 | + re_path( |
| 161 | + r'^auth/whoami/?$', |
122 | 162 | views.UserManagementViewSet.as_view({'get': 'list'})), |
123 | 163 | # admin sharing |
124 | | - url(r'^admin/perms/(?P<username>[\w.@+-]+)/?$', |
| 164 | + re_path( |
| 165 | + r'^admin/perms/(?P<username>[\w.@+-]+)/?$', |
125 | 166 | views.AdminPermsViewSet.as_view({'delete': 'destroy'})), |
126 | | - url(r'^admin/perms/?$', |
| 167 | + re_path( |
| 168 | + r'^admin/perms/?$', |
127 | 169 | views.AdminPermsViewSet.as_view({'get': 'list', 'post': 'create'})), |
128 | 170 | # certificates |
129 | | - url(r'^certs/(?P<name>[-_*.\w]+)/domain/(?P<domain>\**\.?[-\._\w]+)?$', |
| 171 | + re_path( |
| 172 | + r'^certs/(?P<name>[-_*.\w]+)/domain/(?P<domain>\**\.?[-\._\w]+)?$', |
130 | 173 | views.CertificateViewSet.as_view({'delete': 'detach', 'post': 'attach'})), |
131 | | - url(r'^certs/(?P<name>[-_*.\w]+)/?$', |
| 174 | + re_path( |
| 175 | + r'^certs/(?P<name>[-_*.\w]+)/?$', |
132 | 176 | views.CertificateViewSet.as_view({ |
133 | 177 | 'get': 'retrieve', |
134 | 178 | 'delete': 'destroy' |
135 | 179 | })), |
136 | | - url(r'^certs/?$', |
| 180 | + re_path( |
| 181 | + r'^certs/?$', |
137 | 182 | views.CertificateViewSet.as_view({'get': 'list', 'post': 'create'})), |
138 | 183 | # users |
139 | | - url(r'^users/?$', |
| 184 | + re_path( |
| 185 | + r'^users/?$', |
140 | 186 | views.UserView.as_view({'get': 'list'})), |
141 | | - url(r'^users/(?P<username>[\w.@+-]+)/enable/?$', |
| 187 | + re_path( |
| 188 | + r'^users/(?P<username>[\w.@+-]+)/enable/?$', |
142 | 189 | views.UserView.as_view({'patch': 'enable'})), |
143 | | - url(r'^users/(?P<username>[\w.@+-]+)/disable/?$', |
| 190 | + re_path( |
| 191 | + r'^users/(?P<username>[\w.@+-]+)/disable/?$', |
144 | 192 | views.UserView.as_view({'patch': 'disable'})), |
145 | | - url(r'^apps/(?P<id>{})/metrics/(?P<type>[a-z0-9]+(\-[a-z0-9]+)*)/status/?$'.format( |
146 | | - settings.APP_URL_REGEX), |
| 193 | + re_path( |
| 194 | + r'^apps/(?P<id>{})/metrics/(?P<type>[a-z0-9]+(\-[a-z0-9]+)*)/status/?$'.format( |
| 195 | + settings.APP_URL_REGEX), |
147 | 196 | views.MetricView.as_view({'get': 'status'})), |
148 | | - url(r'^manager/(?P<type>[\w.@+-]+)s/(?P<id>{})/block/?$'.format(settings.APP_URL_REGEX), |
| 197 | + re_path( |
| 198 | + r'^manager/(?P<type>[\w.@+-]+)s/(?P<id>{})/block/?$'.format(settings.APP_URL_REGEX), |
149 | 199 | views.WorkflowManagerViewset.as_view({'post': 'block'})), |
150 | | - url(r'^manager/(?P<type>[\w.@+-]+)s/(?P<id>{})/unblock/?$'.format(settings.APP_URL_REGEX), |
| 200 | + re_path( |
| 201 | + r'^manager/(?P<type>[\w.@+-]+)s/(?P<id>{})/unblock/?$'.format(settings.APP_URL_REGEX), |
151 | 202 | views.WorkflowManagerViewset.as_view({'delete': 'unblock'})), |
152 | 203 | # social login is placed at the end of the URL match |
153 | | - url(r'^login/(?P<backend>[^/]+){0}$'.format(extra), views.auth, |
154 | | - name='begin'), |
155 | | - url(r'^complete/(?P<backend>[^/]+){0}$'.format(extra), views.complete, |
156 | | - name='complete'), |
157 | | - url('', include('social_django.urls', namespace='social')), |
| 204 | + re_path(r'^login/(?P<backend>[^/]+){0}$'.format(extra), views.auth, name='begin'), |
| 205 | + re_path(r'^complete/(?P<backend>[^/]+){0}$'.format(extra), views.complete, name='complete'), |
| 206 | + re_path('', include('social_django.urls', namespace='social')), |
158 | 207 | ] |
159 | 208 |
|
160 | 209 | webhook_urlpatterns = [ |
161 | | - url( |
| 210 | + re_path( |
162 | 211 | r'^webhooks/scale/(?P<token>.+)/?$', |
163 | 212 | views.AdmissionWebhookViewSet.as_view({'post': 'scale'}) |
164 | 213 | ), |
|
0 commit comments