Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
api_based_extension_fields.py24 linesDownload Raw Back to fields
1from flask_restful import fields2 3from libs.helper import TimestampField4 5 6class HiddenAPIKey(fields.Raw):7    def output(self, key, obj):8        api_key = obj.api_key9        # If the length of the api_key is less than 8 characters, show the first and last characters10        if len(api_key) <= 8:11            return api_key[0] + "******" + api_key[-1]12        # If the api_key is greater than 8 characters, show the first three and the last three characters13        else:14            return api_key[:3] + "******" + api_key[-3:]15 16 17api_based_extension_fields = {18    "id": fields.String,19    "name": fields.String,20    "api_endpoint": fields.String,21    "api_key": HiddenAPIKey,22    "created_at": TimestampField,23}24