|
8 | 8 |
|
9 | 9 | import dlt |
10 | 10 | from dlt.sources import DltResource |
11 | | -from dlt.sources.rest_api import rest_api_source, RESTAPIConfig |
| 11 | +from dlt.sources.rest_api import rest_api_resources, RESTAPIConfig |
12 | 12 | from dlt.sources.rest_api.typing import EndpointResource |
13 | 13 |
|
14 | 14 | from ..settings import ENTITIES_V2, NESTED_ENTITIES_V2 |
15 | 15 |
|
16 | 16 |
|
17 | 17 | @dlt.source(name="pipedrive_v2") |
18 | 18 | def pipedrive_v2_source( |
19 | | - pipedrive_api_key: Optional[str] = None, |
20 | | - company_domain: Optional[str] = None, |
| 19 | + pipedrive_api_key: Optional[str] = dlt.secrets["sources.pipedrive.pipedrive_api_key"], |
| 20 | + company_domain: Optional[str] = dlt.secrets["sources.pipedrive.company_domain"], |
21 | 21 | resources: Optional[List[str]] = None, |
22 | 22 | prefix: str = "v2_", |
23 | 23 | ) -> Iterable[DltResource]: |
@@ -101,7 +101,7 @@ def rest_v2_resources( |
101 | 101 |
|
102 | 102 | # Use native rest_api_source nested endpoint syntax: {resources.parent_name.id} |
103 | 103 | nested_resource_def: Dict[str, Any] = { |
104 | | - "name": nested_name, |
| 104 | + "name": f"{prefix}{nested_name}", |
105 | 105 | "endpoint": { |
106 | 106 | "path": endpoint_path.replace( |
107 | 107 | "{id}", f"{{resources.{parent_name}.id}}" |
@@ -145,6 +145,8 @@ def rest_v2_resources( |
145 | 145 | "resources": cast(List[Union[str, EndpointResource, DltResource]], resources), |
146 | 146 | } |
147 | 147 |
|
148 | | - api_source = rest_api_source(config) |
149 | | - for resource in api_source.resources.values(): |
150 | | - yield resource.with_name(f"{prefix}{resource.name}") |
| 148 | + for resource in rest_api_resources(config): |
| 149 | + # Only prefix the table name for main resources (nested ones are already prefixed in name) |
| 150 | + if prefix and not resource.name.startswith(prefix): |
| 151 | + resource.table_name = f"{prefix}{resource.name}" |
| 152 | + yield resource |
0 commit comments