Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove v1,v2,v3 support for bulk articles upload #2445

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions portality/templates-v2/public/api/v4/api_docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,6 @@
<h1>API </h1>
<div class="alert alert--message">
<p>This is the current version of the DOAJ API</p>
<p>Please review the below timeline and migration notes, and upgrade your integrations
as soon as possible.</p>

<p>Documentation for the previous version of the API (v3) is available <a href="{{ url_for("api_v3.docs") }}">here</a></p>

<p>This new version of the API introduces significant performance improvements on the bulk article upload endpoint (/api/bulk/articles).</p>

<p>This change is not backwards compatible with the previous API version, so if you rely on bulk article uploads, you will need to upgrade your integrations to use the new version.</p>

<p>This upgrade affects only the /api/bulk/articles endpoint. If you do not use this feature, your API integrations will continue to work normally.</p>

<p>The bulk articles endpoint has changed from a synchronous upload to an asynchronous one. In this new version, you upload a batch of articles to be ingested, and the system will respond immediately with an "Accepted" response, and a link to a status endpoint which will track the import progress of your request. This has been done for several reasons:</p>
<ul style="margin-left: 0.75rem !important">
<li>It is consistent with the manual bulk upload approach we have in the user interface</li>
<li>It allows us to manage the performance of the API better</li>
<li>It mitigates issues some users have had with large uploads timing out</li>
</ul>

<h2>Timeline</h2>
<ol style="margin-left: 0.75rem !important; list-style: auto">
<li><strong>18th July 2024</strong> The v4 API became the "current" API version and is available at /api AND /api/v4. At this point, old integrations with the bulk article upload have ceased to work, and you must switch to using /api/v3 if you want to get it to work again. If you wish to continue using this feature long-term, you must upgrade your integrations.</li>

<li><strong>Early 2025</strong> (exact date to be confirmed) All previous API versions (v1, v2 and v3) will cease to support bulk article uploads, and if you wish to use this feature, you must use the v4 API. All other backwards-compatible API features in those previous versions of the API will continue to work as normal.</li>

</ol>

<p>Please get in touch if you have any questions.</p>
</div>
{% include "public/api/includes/_swagger_description.html" %}
<h2 id="swagger_info">Full API reference</h2>
Expand Down
2 changes: 1 addition & 1 deletion portality/view/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def delete_article(article_id):
def bulk_article_create():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.bulk_article_create', **request.args), code=301)
return api_v3.bulk_article_create()
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/bulk/articles", methods=["DELETE"])
Expand Down
2 changes: 1 addition & 1 deletion portality/view/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def delete_article(article_id):
def bulk_article_create():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.bulk_article_create', **request.args), code=301)
return api_v3.bulk_article_create()
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/bulk/articles", methods=["DELETE"])
Expand Down
16 changes: 2 additions & 14 deletions portality/view/api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ANALYTICS_CATEGORY = app.config.get('ANALYTICS_CATEGORY_API', 'API Hit')
ANALYTICS_ACTIONS = app.config.get('ANALYTICS_ACTIONS_API', {})

API_UNSUPPORTED_ERROR = "Version 3 is no longer supported."

@blueprint.route('/')
def api_root():
Expand Down Expand Up @@ -249,22 +250,9 @@ def _load_income_articles_json(request):
@blueprint.route("/bulk/articles", methods=["POST"])
@api_key_required
@write_required(api=True)
@swag(swag_summary='Bulk article creation <span class="red">[Authenticated, not public]</span>',
swag_spec=ArticlesBulkApi.create_swag()) # must be applied after @api_key_(optional|required) decorators. They don't preserve func attributes.
@plausible.pa_event(ANALYTICS_CATEGORY, action=ANALYTICS_ACTIONS.get('bulk_article_create', 'Bulk article create'))
def bulk_article_create():
data = _load_income_articles_json(request)

# delegate to the API implementation
ids = ArticlesBulkApi.create(data, current_user._get_current_object())

# get all the locations for the ids
inl = []
for id in ids:
inl.append((id, url_for("api_v3.retrieve_article", article_id=id)))

# respond with a suitable Created response
return bulk_created(inl)
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/bulk/articles", methods=["DELETE"])
Expand Down
Loading