(
self,
create_dict: Dict,
**kwargs,
)
| 12 | |
| 13 | class ApikeyModelOperator(PostgresModelOperator): |
| 14 | async def create( |
| 15 | self, |
| 16 | create_dict: Dict, |
| 17 | **kwargs, |
| 18 | ) -> ModelEntity: |
| 19 | # handle kwargs |
| 20 | self._check_kwargs(object_id_required=None, **kwargs) |
| 21 | name = create_dict["name"] |
| 22 | |
| 23 | # generate id and apikey |
| 24 | new_id = Apikey.generate_random_id() |
| 25 | new_apikey = Apikey.generate_random_apikey(new_id) |
| 26 | new_encrypted_apikey = aes_encrypt(new_apikey) |
| 27 | |
| 28 | # create apikey |
| 29 | apikey = await super().create( |
| 30 | apikey_id=new_id, |
| 31 | create_dict={ |
| 32 | "name": name, |
| 33 | "encrypted_apikey": new_encrypted_apikey, |
| 34 | }, |
| 35 | ) |
| 36 | |
| 37 | return apikey |
| 38 | |
| 39 | |
| 40 | apikey_ops = ApikeyModelOperator( |
nothing calls this directly
no test coverage detected