Island: Add a patch method for PropagationConfig

Patch method is required to change the whole collection with one request. We need to change all configured credentials for configuration use case
This commit is contained in:
vakarisz 2022-07-15 17:18:18 +03:00 committed by Ilija Lazoroski
parent 4b0f56d8d8
commit 47a87e14e6
1 changed files with 10 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class PropagationCredentials(AbstractResource):
return propagation_credentials, HTTPStatus.OK return propagation_credentials, HTTPStatus.OK
def post(self, collection=None): def post(self, collection=None):
credentials = [Credentials.from_json(c) for c in request.json] credentials = [Credentials.from_mapping(c) for c in request.json]
if collection == _configured_collection: if collection == _configured_collection:
self._credentials_repository.save_configured_credentials(credentials) self._credentials_repository.save_configured_credentials(credentials)
@ -42,6 +42,15 @@ class PropagationCredentials(AbstractResource):
return {}, HTTPStatus.NO_CONTENT return {}, HTTPStatus.NO_CONTENT
def patch(self, collection=None):
if collection != _configured_collection:
return {}, HTTPStatus.METHOD_NOT_ALLOWED
credentials = [Credentials.from_mapping(c) for c in request.json]
self._credentials_repository.remove_configured_credentials()
self._credentials_repository.save_configured_credentials(credentials)
return {}, HTTPStatus.NO_CONTENT
def delete(self, collection=None): def delete(self, collection=None):
if collection == _configured_collection: if collection == _configured_collection:
self._credentials_repository.remove_configured_credentials() self._credentials_repository.remove_configured_credentials()