We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove /embed endpoint
Similar to #4731

https://github.com/rtfd/readthedocs.org/blob/604e1fa0374a0ba1b242b88e6f242eff77b7b6c3/readthedocs/restapi/urls.py#L66-L66

Raised in https://github.com/rtfd/readthedocs.org/pull/4731/files#r222783446

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `readthedocs/restapi/urls.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 """Define routes between URL paths and views/endpoints."""
4 
5 from __future__ import (
6     absolute_import,
7     division,
8     print_function,
9     unicode_literals,
10 )
11 
12 from django.conf import settings
13 from django.conf.urls import include, url
14 from rest_framework import routers
15 
16 from readthedocs.constants import pattern_opts
17 from readthedocs.restapi import views
18 from readthedocs.restapi.views import (
19     core_views,
20     footer_views,
21     integrations,
22     search_views,
23     task_views,
24 )
25 
26 from .views.model_views import (
27     BuildCommandViewSet,
28     BuildViewSet,
29     DomainViewSet,
30     NotificationViewSet,
31     ProjectViewSet,
32     RemoteOrganizationViewSet,
33     RemoteRepositoryViewSet,
34     SocialAccountViewSet,
35     VersionViewSet,
36 )
37 
38 router = routers.DefaultRouter()
39 router.register(r'build', BuildViewSet, base_name='build')
40 router.register(r'command', BuildCommandViewSet, base_name='buildcommandresult')
41 router.register(r'version', VersionViewSet, base_name='version')
42 router.register(r'project', ProjectViewSet, base_name='project')
43 router.register(r'notification', NotificationViewSet, base_name='emailhook')
44 router.register(r'domain', DomainViewSet, base_name='domain')
45 router.register(
46     r'remote/org',
47     RemoteOrganizationViewSet,
48     base_name='remoteorganization',
49 )
50 router.register(
51     r'remote/repo',
52     RemoteRepositoryViewSet,
53     base_name='remoterepository',
54 )
55 router.register(
56     r'remote/account',
57     SocialAccountViewSet,
58     base_name='remoteaccount',
59 )
60 
61 urlpatterns = [
62     url(r'^', include(router.urls)),
63 ]
64 
65 function_urls = [
66     url(r'embed/', core_views.embed, name='embed'),
67     url(r'docurl/', core_views.docurl, name='docurl'),
68     url(r'footer_html/', footer_views.footer_html, name='footer_html'),
69 ]
70 
71 search_urls = [
72     url(
73         r'index_search/',
74         search_views.index_search,
75         name='index_search',
76     ),
77     url(r'search/$', views.search_views.search, name='api_search'),
78     url(
79         r'search/project/$',
80         search_views.project_search,
81         name='api_project_search',
82     ),
83     url(
84         r'search/section/$',
85         search_views.section_search,
86         name='api_section_search',
87     ),
88 ]
89 
90 task_urls = [
91     url(
92         r'jobs/status/(?P<task_id>[^/]+)/',
93         task_views.job_status,
94         name='api_job_status',
95     ),
96     url(
97         r'jobs/sync-remote-repositories/',
98         task_views.sync_remote_repositories,
99         name='api_sync_remote_repositories',
100     ),
101 ]
102 
103 integration_urls = [
104     url(
105         r'webhook/github/(?P<project_slug>{project_slug})/$'
106         .format(**pattern_opts),
107         integrations.GitHubWebhookView.as_view(),
108         name='api_webhook_github',
109     ),
110     url(
111         r'webhook/gitlab/(?P<project_slug>{project_slug})/$'
112         .format(**pattern_opts),
113         integrations.GitLabWebhookView.as_view(),
114         name='api_webhook_gitlab',
115     ),
116     url(
117         r'webhook/bitbucket/(?P<project_slug>{project_slug})/$'
118         .format(**pattern_opts),
119         integrations.BitbucketWebhookView.as_view(),
120         name='api_webhook_bitbucket',
121     ),
122     url(
123         r'webhook/generic/(?P<project_slug>{project_slug})/$'
124         .format(**pattern_opts),
125         integrations.APIWebhookView.as_view(),
126         name='api_webhook_generic',
127     ),
128     url(
129         (
130             r'webhook/(?P<project_slug>{project_slug})/'
131             r'(?P<integration_pk>{integer_pk})/$'.format(**pattern_opts)
132         ),
133         integrations.WebhookView.as_view(),
134         name='api_webhook',
135     ),
136 ]
137 
138 urlpatterns += function_urls
139 urlpatterns += search_urls
140 urlpatterns += task_urls
141 urlpatterns += integration_urls
142 
143 if 'readthedocsext.search' in settings.INSTALLED_APPS:
144     # pylint: disable=import-error
145     from readthedocsext.search.docsearch import DocSearch
146     api_search_urls = [
147         url(r'^docsearch/$', DocSearch.as_view(), name='doc_search'),
148     ]
149     urlpatterns += api_search_urls
150 
151 if 'readthedocsext.donate' in settings.INSTALLED_APPS:
152     # pylint: disable=import-error
153     from readthedocsext.donate.restapi.urls import urlpatterns \
154         as sustainability_urls
155 
156     urlpatterns += [
157         url(r'^sustainability/', include(sustainability_urls)),
158     ]
159
```

Path: `readthedocs/restapi/views/core_views.py`
Content:
```
1 """Utility endpoints relating to canonical urls, embedded content, etc."""
2 
3 from __future__ import absolute_import
4 
5 from rest_framework import decorators, permissions, status
6 from rest_framework.renderers import JSONRenderer
7 from rest_framework.response import Response
8 
9 import json
10 import requests
11 
12 from django.conf import settings
13 from django.core.cache import cache
14 from django.shortcuts import get_object_or_404
15 
16 from readthedocs.builds.constants import LATEST
17 from readthedocs.builds.models import Version
18 from readthedocs.projects.models import Project
19 from readthedocs.core.templatetags.core_tags import make_document_url
20 
21 
22 @decorators.api_view(['GET'])
23 @decorators.permission_classes((permissions.AllowAny,))
24 @decorators.renderer_classes((JSONRenderer,))
25 def docurl(request):
26     """
27     Get the url that a slug resolves to.
28 
29     Example::
30 
31         GET https://readthedocs.org/api/v2/docurl/?project=requests&version=latest&doc=index
32 
33     """
34     project = request.GET.get('project')
35     version = request.GET.get('version', LATEST)
36     doc = request.GET.get('doc', 'index')
37     if project is None:
38         return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)
39 
40     project = get_object_or_404(Project, slug=project)
41     version = get_object_or_404(
42         Version.objects.public(request.user, project=project, only_active=False),
43         slug=version)
44     return Response({
45         'url': make_document_url(project=project, version=version.slug, page=doc)
46     })
47 
48 
49 @decorators.api_view(['GET'])
50 @decorators.permission_classes((permissions.AllowAny,))
51 @decorators.renderer_classes((JSONRenderer,))
52 def embed(request):
53     """
54     Embed a section of content from any Read the Docs page.
55 
56     Returns headers and content that matches the queried section.
57 
58     ### Arguments
59 
60         * project (required)
61         * doc (required)
62         * version (default latest)
63         * section
64 
65     ### Example
66 
67         GET https://readthedocs.org/api/v2/embed/?project=requests&doc=index&section=User%20Guide
68 
69     # Current Request
70     """
71     project = request.GET.get('project')
72     version = request.GET.get('version', LATEST)
73     doc = request.GET.get('doc')
74     section = request.GET.get('section')
75 
76     if project is None or doc is None:
77         return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)
78 
79     embed_cache = cache.get('embed:%s' % project)
80     if embed_cache:
81         embed = json.loads(embed_cache)
82     else:
83         try:
84             resp = requests.get(
85                 '{host}/api/v1/embed/'.format(host=settings.GROK_API_HOST),
86                 params={'project': project, 'version': version, 'doc': doc, 'section': section}
87             )
88             embed = resp.json()
89             cache.set('embed:%s' % project, resp.content, 1800)
90         except Exception as e:
91             return Response({'error': '%s' % e.msg}, status=status.HTTP_400_BAD_REQUEST)
92 
93     return Response(embed)
94
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/readthedocs/restapi/urls.py b/readthedocs/restapi/urls.py
--- a/readthedocs/restapi/urls.py
+++ b/readthedocs/restapi/urls.py
@@ -63,7 +63,6 @@
 ]
 
 function_urls = [
-    url(r'embed/', core_views.embed, name='embed'),
     url(r'docurl/', core_views.docurl, name='docurl'),
     url(r'footer_html/', footer_views.footer_html, name='footer_html'),
 ]
diff --git a/readthedocs/restapi/views/core_views.py b/readthedocs/restapi/views/core_views.py
--- a/readthedocs/restapi/views/core_views.py
+++ b/readthedocs/restapi/views/core_views.py
@@ -6,11 +6,6 @@
 from rest_framework.renderers import JSONRenderer
 from rest_framework.response import Response
 
-import json
-import requests
-
-from django.conf import settings
-from django.core.cache import cache
 from django.shortcuts import get_object_or_404
 
 from readthedocs.builds.constants import LATEST
@@ -44,50 +39,3 @@
     return Response({
         'url': make_document_url(project=project, version=version.slug, page=doc)
     })
-
-
-@decorators.api_view(['GET'])
-@decorators.permission_classes((permissions.AllowAny,))
-@decorators.renderer_classes((JSONRenderer,))
-def embed(request):
-    """
-    Embed a section of content from any Read the Docs page.
-
-    Returns headers and content that matches the queried section.
-
-    ### Arguments
-
-        * project (required)
-        * doc (required)
-        * version (default latest)
-        * section
-
-    ### Example
-
-        GET https://readthedocs.org/api/v2/embed/?project=requests&doc=index&section=User%20Guide
-
-    # Current Request
-    """
-    project = request.GET.get('project')
-    version = request.GET.get('version', LATEST)
-    doc = request.GET.get('doc')
-    section = request.GET.get('section')
-
-    if project is None or doc is None:
-        return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)
-
-    embed_cache = cache.get('embed:%s' % project)
-    if embed_cache:
-        embed = json.loads(embed_cache)
-    else:
-        try:
-            resp = requests.get(
-                '{host}/api/v1/embed/'.format(host=settings.GROK_API_HOST),
-                params={'project': project, 'version': version, 'doc': doc, 'section': section}
-            )
-            embed = resp.json()
-            cache.set('embed:%s' % project, resp.content, 1800)
-        except Exception as e:
-            return Response({'error': '%s' % e.msg}, status=status.HTTP_400_BAD_REQUEST)
-
-    return Response(embed)

{"golden_diff": "diff --git a/readthedocs/restapi/urls.py b/readthedocs/restapi/urls.py\n--- a/readthedocs/restapi/urls.py\n+++ b/readthedocs/restapi/urls.py\n@@ -63,7 +63,6 @@\n ]\n \n function_urls = [\n-    url(r'embed/', core_views.embed, name='embed'),\n     url(r'docurl/', core_views.docurl, name='docurl'),\n     url(r'footer_html/', footer_views.footer_html, name='footer_html'),\n ]\ndiff --git a/readthedocs/restapi/views/core_views.py b/readthedocs/restapi/views/core_views.py\n--- a/readthedocs/restapi/views/core_views.py\n+++ b/readthedocs/restapi/views/core_views.py\n@@ -6,11 +6,6 @@\n from rest_framework.renderers import JSONRenderer\n from rest_framework.response import Response\n \n-import json\n-import requests\n-\n-from django.conf import settings\n-from django.core.cache import cache\n from django.shortcuts import get_object_or_404\n \n from readthedocs.builds.constants import LATEST\n@@ -44,50 +39,3 @@\n     return Response({\n         'url': make_document_url(project=project, version=version.slug, page=doc)\n     })\n-\n-\n-@decorators.api_view(['GET'])\n-@decorators.permission_classes((permissions.AllowAny,))\n-@decorators.renderer_classes((JSONRenderer,))\n-def embed(request):\n-    \"\"\"\n-    Embed a section of content from any Read the Docs page.\n-\n-    Returns headers and content that matches the queried section.\n-\n-    ### Arguments\n-\n-        * project (required)\n-        * doc (required)\n-        * version (default latest)\n-        * section\n-\n-    ### Example\n-\n-        GET https://readthedocs.org/api/v2/embed/?project=requests&doc=index&section=User%20Guide\n-\n-    # Current Request\n-    \"\"\"\n-    project = request.GET.get('project')\n-    version = request.GET.get('version', LATEST)\n-    doc = request.GET.get('doc')\n-    section = request.GET.get('section')\n-\n-    if project is None or doc is None:\n-        return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)\n-\n-    embed_cache = cache.get('embed:%s' % project)\n-    if embed_cache:\n-        embed = json.loads(embed_cache)\n-    else:\n-        try:\n-            resp = requests.get(\n-                '{host}/api/v1/embed/'.format(host=settings.GROK_API_HOST),\n-                params={'project': project, 'version': version, 'doc': doc, 'section': section}\n-            )\n-            embed = resp.json()\n-            cache.set('embed:%s' % project, resp.content, 1800)\n-        except Exception as e:\n-            return Response({'error': '%s' % e.msg}, status=status.HTTP_400_BAD_REQUEST)\n-\n-    return Response(embed)\n", "issue": "Remove /embed endpoint\nSimilar to #4731\r\n\r\nhttps://github.com/rtfd/readthedocs.org/blob/604e1fa0374a0ba1b242b88e6f242eff77b7b6c3/readthedocs/restapi/urls.py#L66-L66\r\n\r\nRaised in https://github.com/rtfd/readthedocs.org/pull/4731/files#r222783446\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n\"\"\"Define routes between URL paths and views/endpoints.\"\"\"\n\nfrom __future__ import (\n    absolute_import,\n    division,\n    print_function,\n    unicode_literals,\n)\n\nfrom django.conf import settings\nfrom django.conf.urls import include, url\nfrom rest_framework import routers\n\nfrom readthedocs.constants import pattern_opts\nfrom readthedocs.restapi import views\nfrom readthedocs.restapi.views import (\n    core_views,\n    footer_views,\n    integrations,\n    search_views,\n    task_views,\n)\n\nfrom .views.model_views import (\n    BuildCommandViewSet,\n    BuildViewSet,\n    DomainViewSet,\n    NotificationViewSet,\n    ProjectViewSet,\n    RemoteOrganizationViewSet,\n    RemoteRepositoryViewSet,\n    SocialAccountViewSet,\n    VersionViewSet,\n)\n\nrouter = routers.DefaultRouter()\nrouter.register(r'build', BuildViewSet, base_name='build')\nrouter.register(r'command', BuildCommandViewSet, base_name='buildcommandresult')\nrouter.register(r'version', VersionViewSet, base_name='version')\nrouter.register(r'project', ProjectViewSet, base_name='project')\nrouter.register(r'notification', NotificationViewSet, base_name='emailhook')\nrouter.register(r'domain', DomainViewSet, base_name='domain')\nrouter.register(\n    r'remote/org',\n    RemoteOrganizationViewSet,\n    base_name='remoteorganization',\n)\nrouter.register(\n    r'remote/repo',\n    RemoteRepositoryViewSet,\n    base_name='remoterepository',\n)\nrouter.register(\n    r'remote/account',\n    SocialAccountViewSet,\n    base_name='remoteaccount',\n)\n\nurlpatterns = [\n    url(r'^', include(router.urls)),\n]\n\nfunction_urls = [\n    url(r'embed/', core_views.embed, name='embed'),\n    url(r'docurl/', core_views.docurl, name='docurl'),\n    url(r'footer_html/', footer_views.footer_html, name='footer_html'),\n]\n\nsearch_urls = [\n    url(\n        r'index_search/',\n        search_views.index_search,\n        name='index_search',\n    ),\n    url(r'search/$', views.search_views.search, name='api_search'),\n    url(\n        r'search/project/$',\n        search_views.project_search,\n        name='api_project_search',\n    ),\n    url(\n        r'search/section/$',\n        search_views.section_search,\n        name='api_section_search',\n    ),\n]\n\ntask_urls = [\n    url(\n        r'jobs/status/(?P<task_id>[^/]+)/',\n        task_views.job_status,\n        name='api_job_status',\n    ),\n    url(\n        r'jobs/sync-remote-repositories/',\n        task_views.sync_remote_repositories,\n        name='api_sync_remote_repositories',\n    ),\n]\n\nintegration_urls = [\n    url(\n        r'webhook/github/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.GitHubWebhookView.as_view(),\n        name='api_webhook_github',\n    ),\n    url(\n        r'webhook/gitlab/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.GitLabWebhookView.as_view(),\n        name='api_webhook_gitlab',\n    ),\n    url(\n        r'webhook/bitbucket/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.BitbucketWebhookView.as_view(),\n        name='api_webhook_bitbucket',\n    ),\n    url(\n        r'webhook/generic/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.APIWebhookView.as_view(),\n        name='api_webhook_generic',\n    ),\n    url(\n        (\n            r'webhook/(?P<project_slug>{project_slug})/'\n            r'(?P<integration_pk>{integer_pk})/$'.format(**pattern_opts)\n        ),\n        integrations.WebhookView.as_view(),\n        name='api_webhook',\n    ),\n]\n\nurlpatterns += function_urls\nurlpatterns += search_urls\nurlpatterns += task_urls\nurlpatterns += integration_urls\n\nif 'readthedocsext.search' in settings.INSTALLED_APPS:\n    # pylint: disable=import-error\n    from readthedocsext.search.docsearch import DocSearch\n    api_search_urls = [\n        url(r'^docsearch/$', DocSearch.as_view(), name='doc_search'),\n    ]\n    urlpatterns += api_search_urls\n\nif 'readthedocsext.donate' in settings.INSTALLED_APPS:\n    # pylint: disable=import-error\n    from readthedocsext.donate.restapi.urls import urlpatterns \\\n        as sustainability_urls\n\n    urlpatterns += [\n        url(r'^sustainability/', include(sustainability_urls)),\n    ]\n", "path": "readthedocs/restapi/urls.py"}, {"content": "\"\"\"Utility endpoints relating to canonical urls, embedded content, etc.\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom rest_framework import decorators, permissions, status\nfrom rest_framework.renderers import JSONRenderer\nfrom rest_framework.response import Response\n\nimport json\nimport requests\n\nfrom django.conf import settings\nfrom django.core.cache import cache\nfrom django.shortcuts import get_object_or_404\n\nfrom readthedocs.builds.constants import LATEST\nfrom readthedocs.builds.models import Version\nfrom readthedocs.projects.models import Project\nfrom readthedocs.core.templatetags.core_tags import make_document_url\n\n\n@decorators.api_view(['GET'])\n@decorators.permission_classes((permissions.AllowAny,))\n@decorators.renderer_classes((JSONRenderer,))\ndef docurl(request):\n    \"\"\"\n    Get the url that a slug resolves to.\n\n    Example::\n\n        GET https://readthedocs.org/api/v2/docurl/?project=requests&version=latest&doc=index\n\n    \"\"\"\n    project = request.GET.get('project')\n    version = request.GET.get('version', LATEST)\n    doc = request.GET.get('doc', 'index')\n    if project is None:\n        return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)\n\n    project = get_object_or_404(Project, slug=project)\n    version = get_object_or_404(\n        Version.objects.public(request.user, project=project, only_active=False),\n        slug=version)\n    return Response({\n        'url': make_document_url(project=project, version=version.slug, page=doc)\n    })\n\n\n@decorators.api_view(['GET'])\n@decorators.permission_classes((permissions.AllowAny,))\n@decorators.renderer_classes((JSONRenderer,))\ndef embed(request):\n    \"\"\"\n    Embed a section of content from any Read the Docs page.\n\n    Returns headers and content that matches the queried section.\n\n    ### Arguments\n\n        * project (required)\n        * doc (required)\n        * version (default latest)\n        * section\n\n    ### Example\n\n        GET https://readthedocs.org/api/v2/embed/?project=requests&doc=index&section=User%20Guide\n\n    # Current Request\n    \"\"\"\n    project = request.GET.get('project')\n    version = request.GET.get('version', LATEST)\n    doc = request.GET.get('doc')\n    section = request.GET.get('section')\n\n    if project is None or doc is None:\n        return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)\n\n    embed_cache = cache.get('embed:%s' % project)\n    if embed_cache:\n        embed = json.loads(embed_cache)\n    else:\n        try:\n            resp = requests.get(\n                '{host}/api/v1/embed/'.format(host=settings.GROK_API_HOST),\n                params={'project': project, 'version': version, 'doc': doc, 'section': section}\n            )\n            embed = resp.json()\n            cache.set('embed:%s' % project, resp.content, 1800)\n        except Exception as e:\n            return Response({'error': '%s' % e.msg}, status=status.HTTP_400_BAD_REQUEST)\n\n    return Response(embed)\n", "path": "readthedocs/restapi/views/core_views.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n\"\"\"Define routes between URL paths and views/endpoints.\"\"\"\n\nfrom __future__ import (\n    absolute_import,\n    division,\n    print_function,\n    unicode_literals,\n)\n\nfrom django.conf import settings\nfrom django.conf.urls import include, url\nfrom rest_framework import routers\n\nfrom readthedocs.constants import pattern_opts\nfrom readthedocs.restapi import views\nfrom readthedocs.restapi.views import (\n    core_views,\n    footer_views,\n    integrations,\n    search_views,\n    task_views,\n)\n\nfrom .views.model_views import (\n    BuildCommandViewSet,\n    BuildViewSet,\n    DomainViewSet,\n    NotificationViewSet,\n    ProjectViewSet,\n    RemoteOrganizationViewSet,\n    RemoteRepositoryViewSet,\n    SocialAccountViewSet,\n    VersionViewSet,\n)\n\nrouter = routers.DefaultRouter()\nrouter.register(r'build', BuildViewSet, base_name='build')\nrouter.register(r'command', BuildCommandViewSet, base_name='buildcommandresult')\nrouter.register(r'version', VersionViewSet, base_name='version')\nrouter.register(r'project', ProjectViewSet, base_name='project')\nrouter.register(r'notification', NotificationViewSet, base_name='emailhook')\nrouter.register(r'domain', DomainViewSet, base_name='domain')\nrouter.register(\n    r'remote/org',\n    RemoteOrganizationViewSet,\n    base_name='remoteorganization',\n)\nrouter.register(\n    r'remote/repo',\n    RemoteRepositoryViewSet,\n    base_name='remoterepository',\n)\nrouter.register(\n    r'remote/account',\n    SocialAccountViewSet,\n    base_name='remoteaccount',\n)\n\nurlpatterns = [\n    url(r'^', include(router.urls)),\n]\n\nfunction_urls = [\n    url(r'docurl/', core_views.docurl, name='docurl'),\n    url(r'footer_html/', footer_views.footer_html, name='footer_html'),\n]\n\nsearch_urls = [\n    url(\n        r'index_search/',\n        search_views.index_search,\n        name='index_search',\n    ),\n    url(r'search/$', views.search_views.search, name='api_search'),\n    url(\n        r'search/project/$',\n        search_views.project_search,\n        name='api_project_search',\n    ),\n    url(\n        r'search/section/$',\n        search_views.section_search,\n        name='api_section_search',\n    ),\n]\n\ntask_urls = [\n    url(\n        r'jobs/status/(?P<task_id>[^/]+)/',\n        task_views.job_status,\n        name='api_job_status',\n    ),\n    url(\n        r'jobs/sync-remote-repositories/',\n        task_views.sync_remote_repositories,\n        name='api_sync_remote_repositories',\n    ),\n]\n\nintegration_urls = [\n    url(\n        r'webhook/github/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.GitHubWebhookView.as_view(),\n        name='api_webhook_github',\n    ),\n    url(\n        r'webhook/gitlab/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.GitLabWebhookView.as_view(),\n        name='api_webhook_gitlab',\n    ),\n    url(\n        r'webhook/bitbucket/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.BitbucketWebhookView.as_view(),\n        name='api_webhook_bitbucket',\n    ),\n    url(\n        r'webhook/generic/(?P<project_slug>{project_slug})/$'\n        .format(**pattern_opts),\n        integrations.APIWebhookView.as_view(),\n        name='api_webhook_generic',\n    ),\n    url(\n        (\n            r'webhook/(?P<project_slug>{project_slug})/'\n            r'(?P<integration_pk>{integer_pk})/$'.format(**pattern_opts)\n        ),\n        integrations.WebhookView.as_view(),\n        name='api_webhook',\n    ),\n]\n\nurlpatterns += function_urls\nurlpatterns += search_urls\nurlpatterns += task_urls\nurlpatterns += integration_urls\n\nif 'readthedocsext.search' in settings.INSTALLED_APPS:\n    # pylint: disable=import-error\n    from readthedocsext.search.docsearch import DocSearch\n    api_search_urls = [\n        url(r'^docsearch/$', DocSearch.as_view(), name='doc_search'),\n    ]\n    urlpatterns += api_search_urls\n\nif 'readthedocsext.donate' in settings.INSTALLED_APPS:\n    # pylint: disable=import-error\n    from readthedocsext.donate.restapi.urls import urlpatterns \\\n        as sustainability_urls\n\n    urlpatterns += [\n        url(r'^sustainability/', include(sustainability_urls)),\n    ]\n", "path": "readthedocs/restapi/urls.py"}, {"content": "\"\"\"Utility endpoints relating to canonical urls, embedded content, etc.\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom rest_framework import decorators, permissions, status\nfrom rest_framework.renderers import JSONRenderer\nfrom rest_framework.response import Response\n\nfrom django.shortcuts import get_object_or_404\n\nfrom readthedocs.builds.constants import LATEST\nfrom readthedocs.builds.models import Version\nfrom readthedocs.projects.models import Project\nfrom readthedocs.core.templatetags.core_tags import make_document_url\n\n\n@decorators.api_view(['GET'])\n@decorators.permission_classes((permissions.AllowAny,))\n@decorators.renderer_classes((JSONRenderer,))\ndef docurl(request):\n    \"\"\"\n    Get the url that a slug resolves to.\n\n    Example::\n\n        GET https://readthedocs.org/api/v2/docurl/?project=requests&version=latest&doc=index\n\n    \"\"\"\n    project = request.GET.get('project')\n    version = request.GET.get('version', LATEST)\n    doc = request.GET.get('doc', 'index')\n    if project is None:\n        return Response({'error': 'Need project and doc'}, status=status.HTTP_400_BAD_REQUEST)\n\n    project = get_object_or_404(Project, slug=project)\n    version = get_object_or_404(\n        Version.objects.public(request.user, project=project, only_active=False),\n        slug=version)\n    return Response({\n        'url': make_document_url(project=project, version=version.slug, page=doc)\n    })\n", "path": "readthedocs/restapi/views/core_views.py"}]}