contextbase-plugin-hubspot 0.2.6__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.
- contextbase_plugin_hubspot-0.2.6.dist-info/METADATA +9 -0
- contextbase_plugin_hubspot-0.2.6.dist-info/RECORD +9 -0
- contextbase_plugin_hubspot-0.2.6.dist-info/WHEEL +4 -0
- plugin_hubspot/__init__.py +1 -0
- plugin_hubspot/binding_config.py +16 -0
- plugin_hubspot/component.py +99 -0
- plugin_hubspot/defs/__init__.py +1 -0
- plugin_hubspot/defs/defs.yaml +1 -0
- plugin_hubspot/plugin.json +7 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: contextbase-plugin-hubspot
|
|
3
|
+
Version: 0.2.6
|
|
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.2.6
|
|
8
|
+
Requires-Dist: dagster==1.12.14
|
|
9
|
+
Requires-Python: >=3.14, <3.15
|
|
@@ -0,0 +1,9 @@
|
|
|
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=R9FlTDUWUY2HCSwmYP1MsSoSbvsjfjV-u_EkhsyL0Q4,3404
|
|
4
|
+
plugin_hubspot/defs/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
5
|
+
plugin_hubspot/defs/defs.yaml,sha256=guUrcBV5PfKJZK9ogkhwIYKg94GZxVec35DYd744ofQ,52
|
|
6
|
+
plugin_hubspot/plugin.json,sha256=lvn3eoL-QB-JExaOLhUyb0gMyQTdbsepYJ4OYySV7KM,83
|
|
7
|
+
contextbase_plugin_hubspot-0.2.6.dist-info/WHEEL,sha256=i9aSRDivn5iP9LaR1BLQX2GNAuriQWPsFwbbWygTX2k,81
|
|
8
|
+
contextbase_plugin_hubspot-0.2.6.dist-info/METADATA,sha256=Q-EC3GV7c1TrjtrgHGqOT5UHi_lgrSI9beAQBvCC37g,326
|
|
9
|
+
contextbase_plugin_hubspot-0.2.6.dist-info/RECORD,,
|
|
@@ -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.control_plane import ControlPlaneClient
|
|
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 shared_types.api_key_auth import ApiKeyAuth
|
|
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: ApiKeyAuth,
|
|
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),
|
|
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
|
+
control_plane: dg.ResourceParam[ControlPlaneClient],
|
|
64
|
+
):
|
|
65
|
+
binding = resolve_partition_binding(
|
|
66
|
+
context=context,
|
|
67
|
+
control_plane=control_plane,
|
|
68
|
+
plugin_id=PLUGIN_ID,
|
|
69
|
+
)
|
|
70
|
+
binding_id = str(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 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type: plugin_hubspot.component.HubspotSyncComponent
|