Skip to content

Commit bf280b7

Browse files
authored
Merge pull request #438 from OP-TED/feature/TED-1235
add SHORT_UUID
2 parents 76f04b1 + 1fe9163 commit bf280b7

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
uvicorn[standard]
1+
uvicorn[standard]

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ ordered-set~=4.0.2
2525
json2html~=1.3.0
2626
minio~=7.1.1
2727
certifi
28-
networkx~=2.8.8
28+
networkx~=2.8.8
29+
shortuuid~=1.0.11

ted_sws/notice_transformer/entrypoints/api/digest_service/routes/hashing.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import uuid
33
from enum import Enum
44
from typing import Optional
5-
5+
import shortuuid
66
from fastapi import APIRouter
77

88
from ted_sws.notice_transformer.entrypoints.api.digest_service.common import ResponseType, single_result_response, \
@@ -30,6 +30,7 @@ class UUIDNamespaceType(Enum):
3030
class UUIDVersion(Enum):
3131
UUID3 = "UUID3"
3232
UUID5 = "UUID5"
33+
SHORT_UUID = "short"
3334

3435

3536
def string_md5(value: str):
@@ -73,7 +74,7 @@ async def fn_md5(value: str, response_type: Optional[ResponseType] = ResponseTyp
7374
async def fn_uuid(
7475
value: str,
7576
process_type: Optional[UUIDInputProcessType] = UUIDInputProcessType.XPATH,
76-
version: Optional[UUIDVersion] = UUIDVersion.UUID3,
77+
version: Optional[UUIDVersion] = UUIDVersion.SHORT_UUID,
7778
ns_type: Optional[UUIDNamespaceType] = UUIDNamespaceType.URL,
7879
response_type: Optional[ResponseType] = ResponseType.RAW
7980
):
@@ -95,7 +96,9 @@ async def fn_uuid(
9596
uuid_ns = uuid_ns_by_type(ns_type)
9697

9798
uuid_result: uuid.UUID
98-
if version == UUIDVersion.UUID5:
99+
if version == UUIDVersion.SHORT_UUID:
100+
uuid_result = shortuuid.uuid(name=value)
101+
elif version == UUIDVersion.UUID5:
99102
uuid_result = uuid.uuid5(uuid_ns, value)
100103
else:
101104
uuid_result = uuid.uuid3(uuid_ns, value)

0 commit comments

Comments
 (0)