forked from github/plane
feat: release information endpoint (#876)
* dev: init release notes * feat: API endpoint to fetch get last 5 release information
This commit is contained in:
parent
952d35dd79
commit
73a8bbb31f
@ -146,6 +146,9 @@ from plane.api.views import (
|
|||||||
# Gpt
|
# Gpt
|
||||||
GPTIntegrationEndpoint,
|
GPTIntegrationEndpoint,
|
||||||
## End Gpt
|
## End Gpt
|
||||||
|
# Release Notes
|
||||||
|
ReleaseNotesEndpoint,
|
||||||
|
## End Release Notes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1284,4 +1287,11 @@ urlpatterns = [
|
|||||||
name="importer",
|
name="importer",
|
||||||
),
|
),
|
||||||
## End Gpt
|
## End Gpt
|
||||||
|
# Release Notes
|
||||||
|
path(
|
||||||
|
"release-notes/",
|
||||||
|
ReleaseNotesEndpoint.as_view(),
|
||||||
|
name="release-notes",
|
||||||
|
),
|
||||||
|
## End Release Notes
|
||||||
]
|
]
|
||||||
|
@ -138,3 +138,6 @@ from .estimate import (
|
|||||||
ProjectEstimatePointEndpoint,
|
ProjectEstimatePointEndpoint,
|
||||||
BulkEstimatePointEndpoint,
|
BulkEstimatePointEndpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
from .release import ReleaseNotesEndpoint
|
||||||
|
21
apiserver/plane/api/views/release.py
Normal file
21
apiserver/plane/api/views/release.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Third party imports
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import status
|
||||||
|
from sentry_sdk import capture_exception
|
||||||
|
|
||||||
|
# Module imports
|
||||||
|
from .base import BaseAPIView
|
||||||
|
from plane.utils.integrations.github import get_release_notes
|
||||||
|
|
||||||
|
|
||||||
|
class ReleaseNotesEndpoint(BaseAPIView):
|
||||||
|
def get(self, request):
|
||||||
|
try:
|
||||||
|
release_notes = get_release_notes()
|
||||||
|
return Response(release_notes, status=status.HTTP_200_OK)
|
||||||
|
except Exception as e:
|
||||||
|
capture_exception(e)
|
||||||
|
return Response(
|
||||||
|
{"error": "Something went wrong please try again later"},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
)
|
@ -83,3 +83,6 @@ LOGGER_BASE_URL = os.environ.get("LOGGER_BASE_URL", False)
|
|||||||
|
|
||||||
CELERY_RESULT_BACKEND = os.environ.get("REDIS_URL")
|
CELERY_RESULT_BACKEND = os.environ.get("REDIS_URL")
|
||||||
CELERY_BROKER_URL = os.environ.get("REDIS_URL")
|
CELERY_BROKER_URL = os.environ.get("REDIS_URL")
|
||||||
|
|
||||||
|
|
||||||
|
GITHUB_ACCESS_TOKEN = os.environ.get("GITHUB_ACCESS_TOKEN", False)
|
@ -240,7 +240,9 @@ SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN", False)
|
|||||||
LOGGER_BASE_URL = os.environ.get("LOGGER_BASE_URL", False)
|
LOGGER_BASE_URL = os.environ.get("LOGGER_BASE_URL", False)
|
||||||
|
|
||||||
redis_url = os.environ.get("REDIS_URL")
|
redis_url = os.environ.get("REDIS_URL")
|
||||||
broker_url = f"{redis_url}?ssl_cert_reqs={ssl.CERT_NONE.name}&ssl_ca_certs={certifi.where()}"
|
broker_url = (
|
||||||
|
f"{redis_url}?ssl_cert_reqs={ssl.CERT_NONE.name}&ssl_ca_certs={certifi.where()}"
|
||||||
|
)
|
||||||
|
|
||||||
if DOCKERIZED:
|
if DOCKERIZED:
|
||||||
CELERY_BROKER_URL = REDIS_URL
|
CELERY_BROKER_URL = REDIS_URL
|
||||||
@ -248,3 +250,5 @@ if DOCKERIZED:
|
|||||||
else:
|
else:
|
||||||
CELERY_RESULT_BACKEND = broker_url
|
CELERY_RESULT_BACKEND = broker_url
|
||||||
CELERY_BROKER_URL = broker_url
|
CELERY_BROKER_URL = broker_url
|
||||||
|
|
||||||
|
GITHUB_ACCESS_TOKEN = os.environ.get("GITHUB_ACCESS_TOKEN", False)
|
||||||
|
@ -204,3 +204,5 @@ broker_url = f"{redis_url}?ssl_cert_reqs={ssl.CERT_NONE.name}&ssl_ca_certs={cert
|
|||||||
|
|
||||||
CELERY_RESULT_BACKEND = broker_url
|
CELERY_RESULT_BACKEND = broker_url
|
||||||
CELERY_BROKER_URL = broker_url
|
CELERY_BROKER_URL = broker_url
|
||||||
|
|
||||||
|
GITHUB_ACCESS_TOKEN = os.environ.get("GITHUB_ACCESS_TOKEN", False)
|
||||||
|
@ -5,6 +5,7 @@ from urllib.parse import urlparse, parse_qs
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def get_jwt_token():
|
def get_jwt_token():
|
||||||
@ -128,3 +129,24 @@ def get_github_repo_details(access_tokens_url, owner, repo):
|
|||||||
).json()
|
).json()
|
||||||
|
|
||||||
return open_issues, total_labels, collaborators
|
return open_issues, total_labels, collaborators
|
||||||
|
|
||||||
|
|
||||||
|
def get_release_notes():
|
||||||
|
token = settings.GITHUB_ACCESS_TOKEN
|
||||||
|
|
||||||
|
if token:
|
||||||
|
headers = {
|
||||||
|
"Authorization": "Bearer " + str(token),
|
||||||
|
"Accept": "application/vnd.github.v3+json",
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
headers = {
|
||||||
|
"Accept": "application/vnd.github.v3+json",
|
||||||
|
}
|
||||||
|
url = "https://api.github.com/repos/makeplane/plane/releases?per_page=5&page=1"
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
|
||||||
|
if response.status_code != 200:
|
||||||
|
return {"error": "Unable to render information from Github Repository"}
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
Loading…
Reference in New Issue
Block a user