File tree 3 files changed +38
-3
lines changed
3 files changed +38
-3
lines changed Original file line number Diff line number Diff line change
1
+ import logging
2
+ from typing import Any , Optional
3
+
4
+ from api_v2 .postman_collection .dto import PostmanCollection
5
+ from plugins .api .dto import metadata
6
+
7
+ logger = logging .getLogger (__name__ )
8
+
9
+
10
+ class ApiDeploymentDTORegistry :
11
+ _dto_class : Optional [Any ] = None # Store the selected DTO class (cached)
12
+
13
+ @classmethod
14
+ def load_dto (cls ) -> Optional [Any ]:
15
+ class_name = PostmanCollection .__name__
16
+ if metadata .get (class_name ):
17
+ return metadata [class_name ].class_name
18
+ return PostmanCollection # Return as soon as we find a valid DTO
19
+
20
+ @classmethod
21
+ def get_dto (cls ) -> Optional [type ]:
22
+ """Returns the first available DTO class, or None if unavailable."""
23
+ return cls .load_dto ()
Original file line number Diff line number Diff line change 2
2
import logging
3
3
from typing import Any , Optional
4
4
5
+ from api_v2 .api_deployment_dto_registry import ApiDeploymentDTORegistry
5
6
from api_v2 .constants import ApiExecution
6
7
from api_v2 .deployment_helper import DeploymentHelper
7
8
from api_v2 .exceptions import NoActiveAPIKeyError
8
9
from api_v2 .models import APIDeployment
9
- from api_v2 .postman_collection .dto import PostmanCollection
10
10
from api_v2 .serializers import (
11
11
APIDeploymentListSerializer ,
12
12
APIDeploymentSerializer ,
@@ -156,8 +156,8 @@ def download_postman_collection(
156
156
if not api_key_inst :
157
157
logger .error (f"No active API key set for deployment { instance .pk } " )
158
158
raise NoActiveAPIKeyError (deployment_name = instance .display_name )
159
-
160
- postman_collection = PostmanCollection .create (
159
+ dto_class = ApiDeploymentDTORegistry . get_dto ()
160
+ postman_collection = dto_class .create (
161
161
instance = instance , api_key = api_key_inst .api_key
162
162
)
163
163
response = HttpResponse (
Original file line number Diff line number Diff line change
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+
5
+ @dataclass
6
+ class MetadataDto :
7
+ name : str
8
+ class_name : Any
9
+ is_active : bool
10
+
11
+
12
+ metadata = {}
You can’t perform that action at this time.
0 commit comments