function to update Patches has been added
This commit is contained in:
parent
a13081cd71
commit
608959df07
|
|
@ -23,7 +23,7 @@
|
||||||
#!docs/README.md
|
#!docs/README.md
|
||||||
gen/openapi_server/__main__.py
|
gen/openapi_server/__main__.py
|
||||||
gen/openapi_server/encoder.py
|
gen/openapi_server/encoder.py
|
||||||
gen/openapi_server/controllers
|
# gen/openapi_server/controllers
|
||||||
gen/openapi_server/test
|
gen/openapi_server/test
|
||||||
gen/openapi_server
|
gen/openapi_server
|
||||||
openapi_server/models/base_model.py
|
openapi_server/models/base_model.py
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,27 @@ paths:
|
||||||
"400":
|
"400":
|
||||||
description: bad payload
|
description: bad payload
|
||||||
/patchnotes/{patchID}:
|
/patchnotes/{patchID}:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- Patchnotes
|
||||||
|
description: Updates one Patch
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: patchID
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: uuid
|
||||||
|
type: string
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/patch_notes'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: patch updated
|
||||||
|
"404":
|
||||||
|
description: no patch found
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- Patchnotes
|
- Patchnotes
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#docs/*.md
|
#docs/*.md
|
||||||
# Then explicitly reverse the ignore rule for a single file:
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
#!docs/README.md
|
#!docs/README.md
|
||||||
openapi_server/controllers/patchnotes_controller.py
|
# openapi_server/controllers/patchnotes_controller.py
|
||||||
openapi_server/__main__.py
|
openapi_server/__main__.py
|
||||||
openapi_server/encoder.py
|
openapi_server/encoder.py
|
||||||
openapi_server/models/base_model.py
|
openapi_server/models/base_model.py
|
||||||
|
|
@ -6,6 +6,7 @@ README.md
|
||||||
git_push.sh
|
git_push.sh
|
||||||
openapi_server/__init__.py
|
openapi_server/__init__.py
|
||||||
openapi_server/controllers/__init__.py
|
openapi_server/controllers/__init__.py
|
||||||
|
openapi_server/controllers/patchnotes_controller.py
|
||||||
openapi_server/controllers/security_controller.py
|
openapi_server/controllers/security_controller.py
|
||||||
openapi_server/models/__init__.py
|
openapi_server/models/__init__.py
|
||||||
openapi_server/models/patch_notes.py
|
openapi_server/models/patch_notes.py
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from xxlimited_35 import error
|
|
||||||
|
|
||||||
from bson import json_util
|
from bson import json_util
|
||||||
from connexion import ProblemException
|
from connexion import ProblemException
|
||||||
from connexion.lifecycle import ConnexionResponse
|
|
||||||
from flask import Response
|
from flask import Response
|
||||||
|
|
||||||
from openapi_server import util
|
|
||||||
from openapi_server.__main__ import collection
|
from openapi_server.__main__ import collection
|
||||||
from openapi_server.models.patch_notes import PatchNotes # noqa: E501
|
from openapi_server.models.patch_notes import PatchNotes # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def patchnotes_date_get(date): # noqa: E501
|
def patchnotes_date_get(date): # noqa: E501
|
||||||
"""patchnotes_date_get
|
"""patchnotes_date_get
|
||||||
|
|
||||||
|
|
@ -72,6 +70,47 @@ def patchnotes_patch_iddelete(patch_id): # noqa: E501
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def patchnotes_patch_idput(patch_id, body): # noqa: E501
|
||||||
|
"""patchnotes_patch_idput
|
||||||
|
|
||||||
|
Updates one Patch # noqa: E501
|
||||||
|
|
||||||
|
:param body:
|
||||||
|
:param patch_id:
|
||||||
|
:type patch_id: str
|
||||||
|
:type patch_id: str
|
||||||
|
|
||||||
|
:rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]]
|
||||||
|
"""
|
||||||
|
pn = PatchNotes.from_dict(body)
|
||||||
|
try:
|
||||||
|
date_obj = datetime.strptime(pn.patch_date, '%Y-%m-%d').date()
|
||||||
|
date_str = date_obj.strftime('%Y-%m-%d')
|
||||||
|
except ValueError as e:
|
||||||
|
raise ProblemException(
|
||||||
|
title="Bad Request",
|
||||||
|
detail="The date is invalid. Needs to be in this Format YYYY-MM-DD",
|
||||||
|
status=400,
|
||||||
|
)
|
||||||
|
query_filter = {'patchID': patch_id}
|
||||||
|
updated_post = {'$set':
|
||||||
|
{
|
||||||
|
'title': pn.title,
|
||||||
|
'changes': pn.changes,
|
||||||
|
'date': date_str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = collection.update_one(query_filter, updated_post)
|
||||||
|
if result.modified_count == 0:
|
||||||
|
raise ProblemException(
|
||||||
|
title="Not found",
|
||||||
|
detail="No document has been deleted",
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
logging.error(result)
|
||||||
|
return Response("Document was updated", status=200, mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
def patchnotes_post(body):
|
def patchnotes_post(body):
|
||||||
"""patchnotes_post
|
"""patchnotes_post
|
||||||
|
|
||||||
|
|
@ -114,3 +153,4 @@ def patchnotes_post(body):
|
||||||
patch_note = patch_note_obj.to_dict()
|
patch_note = patch_note_obj.to_dict()
|
||||||
return Response(json_util.dumps(patch_note), mimetype='application/json',
|
return Response(json_util.dumps(patch_note), mimetype='application/json',
|
||||||
status=200)
|
status=200)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,31 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Patchnotes
|
- Patchnotes
|
||||||
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
|
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
|
||||||
|
put:
|
||||||
|
description: Updates one Patch
|
||||||
|
operationId: patchnotes_patch_idput
|
||||||
|
parameters:
|
||||||
|
- explode: false
|
||||||
|
in: path
|
||||||
|
name: patchID
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: uuid
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/patch_notes'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: patch updated
|
||||||
|
"404":
|
||||||
|
description: no patch found
|
||||||
|
tags:
|
||||||
|
- Patchnotes
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
patch_notes:
|
patch_notes:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue