Use request_body_json function

Since the credential API and trust API were one of the first APIs
converted to flask, there weren't using a utility method to parse
JSON out of request bodies.

This commit makes both APIs re-use common code to get request
bodies.

Change-Id: Ic67fb1bc45018cdc6c3598adbc43cfc57f8592ab
This commit is contained in:
Lance Bragstad 2018-10-22 20:04:32 +00:00
parent e287f58fbb
commit 8819bbec6e
2 changed files with 3 additions and 3 deletions

View File

@ -129,7 +129,7 @@ class CredentialResource(ks_flask.ResourceBase):
def post(self):
# Create a new credential
credential = flask.request.json.get('credential', {})
credential = self.request_body_json.get('credential', {})
target = {}
target['credential'] = credential
ENFORCER.enforce_call(
@ -150,7 +150,7 @@ class CredentialResource(ks_flask.ResourceBase):
)
PROVIDERS.credential_api.get_credential(credential_id)
credential = flask.request.json.get('credential', {})
credential = self.request_body_json.get('credential', {})
validation.lazy_validate(schema.credential_update, credential)
self._require_matching_id(credential)
ref = PROVIDERS.credential_api.update_credential(

View File

@ -207,7 +207,7 @@ class TrustResource(ks_flask.ResourceBase):
The User creating the trust must be the trustor.
"""
ENFORCER.enforce_call(action='identity:create_trust')
trust = flask.request.json.get('trust', {})
trust = self.request_body_json.get('trust', {})
validation.lazy_validate(schema.trust_create, trust)
self._check_unrestricted()