def status(client, access_key, status): try: status = cred_lib.status(client, access_key, status) utils.check(status) click.secho(f"Credentials status changed", fg="green") except Exception as exc: click.secho( f"Credentials fetching failed. \n{exc}", fg="yellow", bold=True, err=True )
def put(self): parser = reqparse.RequestParser() parser.add_argument("access_key", type=str, required=True) parser.add_argument("status", type=str, required=True, default="true") args = parser.parse_args() try: stats = "activated" if args["status"].lower( ) == "true" else "deactivated" status = credential.status(get_client(), args["access_key"], args["status"]) if "reason" in status: current_app.logger.error(status["reason"]) return response(status["status_code"], message=status["reason"]) return response(200, f"Credential status has been {stats}.") except Exception as e: current_app.logger.error(f"{e}") return response(500, f"{e}")
def test_status(): assert cred.status(fake_client(), "key") == "Done"