ingestr 0.13.26__py3-none-any.whl → 0.13.28__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ingestr might be problematic. Click here for more details.

ingestr/src/buildinfo.py CHANGED
@@ -1 +1 @@
1
- version = "v0.13.26"
1
+ version = "v0.13.28"
@@ -56,6 +56,7 @@ def hubspot(
56
56
  api_key: str = dlt.secrets.value,
57
57
  include_history: bool = False,
58
58
  include_custom_props: bool = True,
59
+ custom_object: str = None,
59
60
  ) -> Sequence[DltResource]:
60
61
  """
61
62
  A DLT source that retrieves data from the HubSpot API using the
@@ -162,13 +163,13 @@ def hubspot(
162
163
  props,
163
164
  include_custom_props,
164
165
  )
165
-
166
+
166
167
  @dlt.resource(name="schemas", write_disposition="merge", primary_key="id")
167
168
  def schemas(
168
169
  api_key: str = api_key,
169
170
  ) -> Iterator[TDataItems]:
170
171
  """Hubspot schemas resource"""
171
- yield from fetch_data(CRM_SCHEMAS_ENDPOINT, api_key)
172
+ yield from fetch_data(CRM_SCHEMAS_ENDPOINT, api_key,resource_name="schemas")
172
173
 
173
174
  @dlt.resource(name="quotes", write_disposition="replace")
174
175
  def quotes(
@@ -186,7 +187,34 @@ def hubspot(
186
187
  include_custom_props,
187
188
  )
188
189
 
189
- return companies, contacts, deals, tickets, products, quotes, schemas
190
+ @dlt.resource(write_disposition="merge", primary_key="hs_object_id")
191
+ def custom(
192
+ api_key: str = api_key,
193
+ custom_object_name: str = custom_object,
194
+ ) -> Iterator[TDataItems]:
195
+
196
+ get_custom_object = schemas(api_key)
197
+ object_type_id = None
198
+ for custom_object in get_custom_object:
199
+ if custom_object["name"] == custom_object_name.capitalize():
200
+ object_type_id = custom_object["objectTypeId"]
201
+ break
202
+ if object_type_id is None:
203
+ raise ValueError(f"There is no such custom object as {custom_object_name}")
204
+ custom_object_properties= f"crm/v3/properties/{object_type_id}"
205
+
206
+ props_pages = fetch_data(custom_object_properties, api_key)
207
+ props = []
208
+ for page in props_pages:
209
+ props.extend([prop["name"] for prop in page])
210
+ props = ",".join(sorted(list(set(props))))
211
+
212
+ custom_object_endpoint= f"crm/v3/objects/{object_type_id}/?properties={props}"
213
+
214
+ """Hubspot custom object details resource"""
215
+ yield from fetch_data(custom_object_endpoint, api_key,resource_name="custom")
216
+
217
+ return companies, contacts, deals, tickets, products, quotes, schemas, custom
190
218
 
191
219
 
192
220
  def crm_objects(
@@ -90,7 +90,7 @@ def fetch_property_history(
90
90
 
91
91
 
92
92
  def fetch_data(
93
- endpoint: str, api_key: str, params: Optional[Dict[str, Any]] = None
93
+ endpoint: str, api_key: str, params: Optional[Dict[str, Any]] = None,resource_name: str = None
94
94
  ) -> Iterator[List[Dict[str, Any]]]:
95
95
  """
96
96
  Fetch data from HUBSPOT endpoint using a specified API key and yield the properties of each result.
@@ -132,7 +132,7 @@ def fetch_data(
132
132
  if "results" in _data:
133
133
  _objects: List[Dict[str, Any]] = []
134
134
  for _result in _data["results"]:
135
- if endpoint == "/crm/v3/schemas":
135
+ if resource_name == "schemas":
136
136
  _objects.append({
137
137
  "name": _result["labels"].get("singular", ""),
138
138
  "objectTypeId": _result.get("objectTypeId", ""),
@@ -142,6 +142,10 @@ def fetch_data(
142
142
  "createdAt": _result.get("createdAt", ""),
143
143
  "updatedAt": _result.get("updatedAt", "")
144
144
  })
145
+ elif resource_name == "custom":
146
+ _objects.append(
147
+ _result.get("properties", ""),
148
+ )
145
149
  else:
146
150
  _obj = _result.get("properties", _result)
147
151
  if "id" not in _obj and "id" in _result:
ingestr/src/sources.py CHANGED
@@ -803,7 +803,20 @@ class HubspotSource:
803
803
  raise ValueError("api_key in the URI is required to connect to Hubspot")
804
804
 
805
805
  endpoint = None
806
- if table in ["contacts", "companies", "deals", "tickets", "products", "quotes", "schemas"]:
806
+
807
+ if table.startswith("custom:"):
808
+ fields = table.split(":", 2)
809
+ if len(fields) != 2:
810
+ raise ValueError(
811
+ "Invalid Hubspot custom table format. Expected format: custom:<custom_object_type>"
812
+ )
813
+ endpoint = fields[1]
814
+ return hubspot(
815
+ api_key=api_key[0],
816
+ custom_object=endpoint,
817
+ ).with_resources("custom")
818
+
819
+ elif table in ["contacts", "companies", "deals", "tickets", "products", "quotes", "schemas"]:
807
820
  endpoint = table
808
821
  else:
809
822
  raise ValueError(
@@ -1398,13 +1411,19 @@ class GoogleAnalyticsSource:
1398
1411
  parse_uri = urlparse(uri)
1399
1412
  source_fields = parse_qs(parse_uri.query)
1400
1413
  cred_path = source_fields.get("credentials_path")
1414
+ cred_base64 = source_fields.get("credentials_base64")
1401
1415
 
1402
- if not cred_path:
1403
- raise ValueError("credentials_path is required to connect Google Analytics")
1404
- credentials = {}
1416
+ if not cred_path and not cred_base64:
1417
+ raise ValueError("credentials_path or credentials_base64 is required to connect Google Analytics")
1405
1418
 
1406
- with open(cred_path[0], "r") as f:
1407
- credentials = json.load(f)
1419
+ credentials = {}
1420
+ if cred_path:
1421
+ with open(cred_path[0], "r") as f:
1422
+ credentials = json.load(f)
1423
+ elif cred_base64:
1424
+ credentials = json.loads(
1425
+ base64.b64decode(cred_base64[0]).decode("utf-8")
1426
+ )
1408
1427
 
1409
1428
  property_id = source_fields.get("property_id")
1410
1429
  if not property_id:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ingestr
3
- Version: 0.13.26
3
+ Version: 0.13.28
4
4
  Summary: ingestr is a command-line application that ingests data from various sources and stores them in any database.
5
5
  Project-URL: Homepage, https://github.com/bruin-data/ingestr
6
6
  Project-URL: Issues, https://github.com/bruin-data/ingestr/issues
@@ -74,7 +74,7 @@ Requires-Dist: google-cloud-storage==3.1.0
74
74
  Requires-Dist: google-crc32c==1.6.0
75
75
  Requires-Dist: google-resumable-media==2.7.2
76
76
  Requires-Dist: googleapis-common-protos==1.69.0
77
- Requires-Dist: greenlet==3.1.1
77
+ Requires-Dist: greenlet==3.2.0
78
78
  Requires-Dist: grpcio-status==1.62.3
79
79
  Requires-Dist: grpcio==1.70.0
80
80
  Requires-Dist: hdbcli==2.23.27
@@ -2,7 +2,7 @@ ingestr/conftest.py,sha256=Q03FIJIZpLBbpj55cfCHIKEjc1FCvWJhMF2cidUJKQU,1748
2
2
  ingestr/main.py,sha256=wvbRCJ2--M0Zw2cYtSH874TxTtlD0wadHREeLG3anOY,25618
3
3
  ingestr/src/.gitignore,sha256=8cX1AZTSI0TcdZFGTmS_oyBjpfCzhOEt0DdAo2dFIY8,203
4
4
  ingestr/src/blob.py,sha256=onMe5ZHxPXTdcB_s2oGNdMo-XQJ3ajwOsWE9eSTGFmc,1495
5
- ingestr/src/buildinfo.py,sha256=VzL8INFpli0urCbtG-JAzjTMJgmPVwIKFd9agl-cDsY,21
5
+ ingestr/src/buildinfo.py,sha256=oC8nu6AzLZ_pxgRfz88wvC4OwlhMFeJZSkZgNXnuiSA,21
6
6
  ingestr/src/destinations.py,sha256=vrGij4qMPCdXTMIimROWBJFqzOqCM4DFmgyubgSHejA,11279
7
7
  ingestr/src/errors.py,sha256=Ufs4_DfE77_E3vnA1fOQdi6cmuLVNm7_SbFLkL1XPGk,686
8
8
  ingestr/src/factory.py,sha256=659h_sVRBhtPv2dvtOK8tf3PtUhlK3KsWLrb20_iQKw,5333
@@ -10,7 +10,7 @@ ingestr/src/filters.py,sha256=5LNpBgm8FJXdrFHGyM7dLVyphKykSpPk7yuQAZ8GML4,1133
10
10
  ingestr/src/loader.py,sha256=9NaWAyfkXdqAZSS-N72Iwo36Lbx4PyqIfaaH1dNdkFs,1712
11
11
  ingestr/src/partition.py,sha256=E0WHqh1FTheQAIVK_-jWUx0dgyYZCD1VxlAm362gao4,964
12
12
  ingestr/src/resource.py,sha256=XG-sbBapFVEM7OhHQFQRTdTLlh-mHB-N4V1t8F8Tsww,543
13
- ingestr/src/sources.py,sha256=pF0o1xi84hDo_fdM2o_Wmhcrye_mr55dMQ1BvL8sZZA,73582
13
+ ingestr/src/sources.py,sha256=GNX3dLFFqNxe6-humD46PZI9nh84tyuiwh9Cl0RwUg8,74309
14
14
  ingestr/src/table_definition.py,sha256=REbAbqdlmUMUuRh8nEQRreWjPVOQ5ZcfqGkScKdCrmk,390
15
15
  ingestr/src/time.py,sha256=H_Fk2J4ShXyUM-EMY7MqCLZQhlnZMZvO952bmZPc4yE,254
16
16
  ingestr/src/version.py,sha256=J_2xgZ0mKlvuHcjdKCx2nlioneLH0I47JiU_Slr_Nwc,189
@@ -61,8 +61,8 @@ ingestr/src/google_sheets/helpers/api_calls.py,sha256=RiVfdacbaneszhmuhYilkJnkc9
61
61
  ingestr/src/google_sheets/helpers/data_processing.py,sha256=RNt2MYfdJhk4bRahnQVezpNg2x9z0vx60YFq2ukZ8vI,11004
62
62
  ingestr/src/gorgias/__init__.py,sha256=_mFkMYwlY5OKEY0o_FK1OKol03A-8uk7bm1cKlmt5cs,21432
63
63
  ingestr/src/gorgias/helpers.py,sha256=DamuijnvhGY9hysQO4txrVMf4izkGbh5qfBKImdOINE,5427
64
- ingestr/src/hubspot/__init__.py,sha256=nHjMvqUAUNVy9dX-1YiaY6PeplDnzc_LjQl25DdVrYg,9765
65
- ingestr/src/hubspot/helpers.py,sha256=vJPaF9qU71-w-LUe4NaRowioIJG3GfX4MObyitHJC6U,7388
64
+ ingestr/src/hubspot/__init__.py,sha256=seijVlwBXE3-5SRtLjfJwbk1ZvckUj0IYBL0w69k464,10983
65
+ ingestr/src/hubspot/helpers.py,sha256=jwWQy0AjVaMq4B033dAiQh2oehhYdFWLkynA43QsQzM,7573
66
66
  ingestr/src/hubspot/settings.py,sha256=hXnIhE4_FlhtgUiCjMLGGZJ_lBlBQJ0YWi6lHJ6Q3WU,2234
67
67
  ingestr/src/kafka/__init__.py,sha256=wMCXdiraeKd1Kssi9WcVCGZaNGm2tJEtnNyuB4aR5_k,3541
68
68
  ingestr/src/kafka/helpers.py,sha256=V9WcVn3PKnEpggArHda4vnAcaV8VDuh__dSmRviJb5Y,7502
@@ -121,8 +121,8 @@ ingestr/testdata/delete_insert_part2.csv,sha256=B_KUzpzbNdDY_n7wWop1mT2cz36TmayS
121
121
  ingestr/testdata/merge_expected.csv,sha256=DReHqWGnQMsf2PBv_Q2pfjsgvikYFnf1zYcQZ7ZqYN0,276
122
122
  ingestr/testdata/merge_part1.csv,sha256=Pw8Z9IDKcNU0qQHx1z6BUf4rF_-SxKGFOvymCt4OY9I,185
123
123
  ingestr/testdata/merge_part2.csv,sha256=T_GiWxA81SN63_tMOIuemcvboEFeAmbKc7xRXvL9esw,287
124
- ingestr-0.13.26.dist-info/METADATA,sha256=cPGZ4OGDE-jWfIm8D5gEOLCGyMOioafvTC27zlxeHvo,13659
125
- ingestr-0.13.26.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
126
- ingestr-0.13.26.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
127
- ingestr-0.13.26.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
128
- ingestr-0.13.26.dist-info/RECORD,,
124
+ ingestr-0.13.28.dist-info/METADATA,sha256=-jYfvk0dlu8EvEDi2df5163aCHLX-JTkru0dmQroa0M,13659
125
+ ingestr-0.13.28.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
126
+ ingestr-0.13.28.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
127
+ ingestr-0.13.28.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
128
+ ingestr-0.13.28.dist-info/RECORD,,