Skip to content

Commit 39affb3

Browse files
committed
fixes applied to Pipedrive source v2 as per comments
1 parent cb76ca8 commit 39affb3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sources/pipedrive/rest_v2/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
import dlt
1010
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
1212
from dlt.sources.rest_api.typing import EndpointResource
1313

1414
from ..settings import ENTITIES_V2, NESTED_ENTITIES_V2
1515

1616

1717
@dlt.source(name="pipedrive_v2")
1818
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"],
2121
resources: Optional[List[str]] = None,
2222
prefix: str = "v2_",
2323
) -> Iterable[DltResource]:
@@ -101,7 +101,7 @@ def rest_v2_resources(
101101

102102
# Use native rest_api_source nested endpoint syntax: {resources.parent_name.id}
103103
nested_resource_def: Dict[str, Any] = {
104-
"name": nested_name,
104+
"name": f"{prefix}{nested_name}",
105105
"endpoint": {
106106
"path": endpoint_path.replace(
107107
"{id}", f"{{resources.{parent_name}.id}}"
@@ -145,6 +145,8 @@ def rest_v2_resources(
145145
"resources": cast(List[Union[str, EndpointResource, DltResource]], resources),
146146
}
147147

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

Comments
 (0)