contextbase-plugin-hubspot 0.0.0a1__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.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.3
2
+ Name: contextbase-plugin-hubspot
3
+ Version: 0.0.0a1
4
+ Summary: HubSpot plugin for ContextBase (PyAirbyte-backed)
5
+ Author: Alizain Feerasta
6
+ Author-email: Alizain Feerasta <alizain.feerasta@gmail.com>
7
+ Requires-Dist: contextbase-shared-plugins==0.0.0a1
8
+ Requires-Dist: dagster==1.12.14
9
+ Requires-Python: >=3.12, <3.13
@@ -0,0 +1,8 @@
1
+ plugin_hubspot/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
+ plugin_hubspot/binding_config.py,sha256=yk72jxAcRTBdrKFbBSRGAVGy_39PrbVkPu00X2WpwXQ,396
3
+ plugin_hubspot/component.py,sha256=eqUQjB1E0DzDBa2bwkmIYhsfD3bn3oHPu1a8p9gbKSE,3437
4
+ plugin_hubspot/plugin.json,sha256=lvn3eoL-QB-JExaOLhUyb0gMyQTdbsepYJ4OYySV7KM,83
5
+ contextbase_plugin_hubspot-0.0.0a1.dist-info/WHEEL,sha256=i9aSRDivn5iP9LaR1BLQX2GNAuriQWPsFwbbWygTX2k,81
6
+ contextbase_plugin_hubspot-0.0.0a1.dist-info/entry_points.txt,sha256=cUIkWlFpgN2sm7kzEdNW6BhkPMdzHqpUbP65wJpAsGE,80
7
+ contextbase_plugin_hubspot-0.0.0a1.dist-info/METADATA,sha256=bAWeTmsnVxX66ndbRcm6CiCsL3ESDITieqS7U_NlqXg,330
8
+ contextbase_plugin_hubspot-0.0.0a1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.11.15
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [contextlayer.plugins]
2
+ hubspot = plugin_hubspot.component:HubspotSyncComponent
3
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Annotated
4
+
5
+ from pydantic import Field
6
+
7
+ from shared_plugins.bindings import (
8
+ BaseBindingConfigModel,
9
+ StrictNonNegativeInt,
10
+ UtcTimestampText,
11
+ )
12
+
13
+
14
+ class HubspotBindingConfig(BaseBindingConfigModel):
15
+ start_date: UtcTimestampText | None = None
16
+ lookback_window: Annotated[StrictNonNegativeInt, Field(le=576000)] | None = None
@@ -0,0 +1,99 @@
1
+ import dagster as dg
2
+ from dagster import AssetExecutionContext
3
+ from shared_plugins.automation import non_overlapping_automation_condition
4
+ from shared_plugins.bindings import (
5
+ parse_binding_config,
6
+ require_api_key,
7
+ )
8
+ from shared_plugins.base_platform import BasePlatformClient
9
+ from shared_plugins.dlt import resolve_partition_binding
10
+ from shared_plugins.naming import (
11
+ dagster_airbyte_sync_asset_key,
12
+ dagster_asset_group_name,
13
+ dagster_asset_tags,
14
+ dagster_partition_def_name,
15
+ dagster_pool_name,
16
+ plugin_id_from_module,
17
+ )
18
+ from shared_plugins.pyairbyte import (
19
+ build_pyairbyte_source,
20
+ require_pyairbyte_selected_stream_names,
21
+ run_pyairbyte_sync,
22
+ )
23
+ from base_client import BindingAuth_ApiKey
24
+
25
+ from .binding_config import HubspotBindingConfig
26
+
27
+ PLUGIN_ID = plugin_id_from_module(__file__)
28
+ DOCKER_IMAGE = "airbyte/source-hubspot:6.4.2"
29
+
30
+
31
+ def _build_connector_config(
32
+ cfg: HubspotBindingConfig,
33
+ auth: BindingAuth_ApiKey,
34
+ ) -> dict[str, object]:
35
+ return {
36
+ **cfg.model_dump(mode="json", exclude_none=True),
37
+ "credentials": {
38
+ "credentials_title": "Private App Credentials",
39
+ "access_token": auth.api_key,
40
+ },
41
+ }
42
+
43
+
44
+ class HubspotSyncComponent(dg.Component):
45
+ def build_defs(self, context: dg.ComponentLoadContext) -> dg.Definitions:
46
+ partitions_def = dg.DynamicPartitionsDefinition(
47
+ name=dagster_partition_def_name(PLUGIN_ID)
48
+ )
49
+
50
+ @dg.asset(
51
+ key=dagster_airbyte_sync_asset_key(PLUGIN_ID),
52
+ group_name=dagster_asset_group_name(PLUGIN_ID),
53
+ tags=dagster_asset_tags(PLUGIN_ID, extra_tags={"ctx_primary": "true"}),
54
+ automation_condition=non_overlapping_automation_condition(
55
+ dg.AutomationCondition.on_missing()
56
+ | dg.AutomationCondition.on_cron("*/15 * * * *")
57
+ ),
58
+ partitions_def=partitions_def,
59
+ pool=dagster_pool_name(PLUGIN_ID),
60
+ )
61
+ def hubspot_sync_asset(
62
+ context: AssetExecutionContext,
63
+ base_platform: dg.ResourceParam[BasePlatformClient],
64
+ ):
65
+ binding = resolve_partition_binding(
66
+ context=context,
67
+ base_platform=base_platform,
68
+ plugin_id=PLUGIN_ID,
69
+ )
70
+ binding_id = binding.binding_id
71
+ cfg = parse_binding_config(binding, HubspotBindingConfig)
72
+ auth = require_api_key(binding)
73
+ selected_stream_names = require_pyairbyte_selected_stream_names(binding)
74
+
75
+ connector_config = _build_connector_config(cfg, auth)
76
+ source = build_pyairbyte_source(
77
+ docker_image=DOCKER_IMAGE,
78
+ connector_config=connector_config,
79
+ )
80
+
81
+ return run_pyairbyte_sync(
82
+ context=context,
83
+ plugin_id=PLUGIN_ID,
84
+ binding_id=binding_id,
85
+ selected_stream_names=selected_stream_names,
86
+ source=source,
87
+ )
88
+
89
+ automation_sensor = dg.AutomationConditionSensorDefinition(
90
+ name="hubspot_automation_sensor",
91
+ target=dg.AssetSelection.assets(hubspot_sync_asset),
92
+ default_status=dg.DefaultSensorStatus.RUNNING,
93
+ minimum_interval_seconds=30,
94
+ )
95
+
96
+ return dg.Definitions(
97
+ assets=[hubspot_sync_asset],
98
+ sensors=[automation_sensor],
99
+ )
@@ -0,0 +1,7 @@
1
+ {
2
+ "auth": {
3
+ "type": "api_key"
4
+ },
5
+ "mode": "dagster",
6
+ "plugin_id": "hubspot"
7
+ }