def delete(self, account): """ Delete an account's identity mapping. .. :quickref: Identities; Remove identity from account. :param account: Account identifier. :<json string identity: The identity name. :<json string authtype: The authentication type. :status 200: Successfully deleted. :status 401: Invalid auth token. :status 404: Account not found. :status 404: Identity not found. """ parameters = json_parameters() identity = param_get(parameters, 'identity') authtype = param_get(parameters, 'authtype') try: del_account_identity(identity, authtype, account, request.environ.get('issuer'), vo=request.environ.get('vo')) except AccessDenied as error: return generate_http_error_flask(401, error) except (AccountNotFound, IdentityError) as error: return generate_http_error_flask(404, error) return '', 200
def delete(self, account): """ --- summary: Delete identity description: Delete an account identity. tags: - Account parameters: - name: account in: path description: The account identifier. schema: type: string style: simple requestBody: content: 'application/json': schema: type: object required: - identity - authtype properties: identity: description: The identity. type: string authtype: description: The authtype. type: string responses: 200: description: OK 401: description: Invalid Auth Token 404: description: Account or identity not found """ parameters = json_parameters() identity = param_get(parameters, 'identity') authtype = param_get(parameters, 'authtype') try: del_account_identity(identity, authtype, account, request.environ.get('issuer'), vo=request.environ.get('vo')) except AccessDenied as error: return generate_http_error_flask(401, error) except (AccountNotFound, IdentityError) as error: return generate_http_error_flask(404, error) return '', 200
def delete(self, account): """ Delete an account's identity mapping. .. :quickref: Identities; Remove identity from account. :param account: Account identifier. :<json string identity: The identity name. :<json string authtype: The authentication type. :status 200: Successfully deleted. :status 401: Invalid auth token. :status 404: Account not found. :status 404: Identity not found. :status 500: Database exception. """ json_data = request.data.decode() try: parameter = loads(json_data) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'cannot decode json parameter dictionary') try: identity = parameter['identity'] authtype = parameter['authtype'] except KeyError as error: if error.args[0] == 'authtype' or error.args[0] == 'identity': return generate_http_error_flask(400, 'KeyError', '%s not defined' % str(error)) except TypeError: return generate_http_error_flask(400, 'TypeError', 'body must be a json dictionary') try: del_account_identity(identity, authtype, account, request.environ.get('issuer'), vo=request.environ.get('vo')) except AccessDenied as error: return generate_http_error_flask(401, 'AccessDenied', error.args[0]) except AccountNotFound as error: return generate_http_error_flask(404, 'AccountNotFound', error.args[0]) except IdentityError as error: return generate_http_error_flask(404, 'IdentityError', error.args[0]) except Exception as error: print(format_exc()) return str(error), 500 return '', 200
def DELETE(self, account): """ Delete an account's identity mapping. HTTP Success: 200 Created HTTP Error: 400 Bad Reqeust 401 Unauthorized 404 Not Found 500 Internal Error :param account: Account identifier. """ json_data = data() try: parameter = loads(json_data) except ValueError: raise generate_http_error( 400, 'ValueError', 'cannot decode json parameter dictionary') try: identity = parameter['identity'] authtype = parameter['authtype'] except KeyError as error: if error.args[0] == 'authtype' or error.args[0] == 'identity': raise generate_http_error(400, 'KeyError', '%s not defined' % str(error)) except TypeError: raise generate_http_error(400, 'TypeError', 'body must be a json dictionary') try: del_account_identity(identity, authtype, account, ctx.env.get('issuer'), vo=ctx.env.get('vo')) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except AccountNotFound as error: raise generate_http_error(404, 'AccountNotFound', error.args[0]) except IdentityError as error: raise generate_http_error(404, 'IdentityError', error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error) raise OK()
parameter = loads(json_data) except ValueError: raise generate_http_error( 400, 'ValueError', 'cannot decode json parameter dictionary') try: identity = parameter['identity'] authtype = parameter['authtype'] except KeyError, e: if e.args[0] == 'authtype' or e.args[0] == 'identity': raise generate_http_error(400, 'KeyError', '%s not defined' % str(e)) except TypeError: raise generate_http_error(400, 'TypeError', 'body must be a json dictionary') try: del_account_identity(identity, authtype, account) except AccessDenied, e: raise generate_http_error(401, 'AccessDenied', e.args[0][0]) except AccountNotFound, e: raise generate_http_error(404, 'AccountNotFound', e.args[0][0]) except IdentityError, e: raise generate_http_error(404, 'IdentityError', e.args[0][0]) except Exception, e: print format_exc() raise InternalError(e) raise OK() class Rules(RucioController): def GET(self, account):
""" json_data = data() try: parameter = loads(json_data) except ValueError: raise generate_http_error(400, 'ValueError', 'cannot decode json parameter dictionary') try: identity = parameter['identity'] authtype = parameter['authtype'] except KeyError, e: if e.args[0] == 'authtype' or e.args[0] == 'identity': raise generate_http_error(400, 'KeyError', '%s not defined' % str(e)) except TypeError: raise generate_http_error(400, 'TypeError', 'body must be a json dictionary') try: del_account_identity(identity, authtype, account) except AccessDenied, e: raise generate_http_error(401, 'AccessDenied', e.args[0][0]) except AccountNotFound, e: raise generate_http_error(404, 'AccountNotFound', e.args[0][0]) except IdentityError, e: raise generate_http_error(404, 'IdentityError', e.args[0][0]) except Exception, e: print format_exc() raise InternalError(e) raise OK() class Rules(RucioController):