Upsert
- async AsyncCogniteClient.transformations.external_data_sources.upsert(
- data_source: ExternalDataSourceWrite | Sequence[ExternalDataSourceWrite],
- upsert_mode: Literal['replace'] = 'replace',
-
Each item replaces the stored data source in full, so every request must contain complete settings including the client secret. Reading a data source never returns the client secret, so re-registering one means constructing a new write object with the secret filled in.
- Parameters:
data_source (ExternalDataSourceWrite | Sequence[ExternalDataSourceWrite]) – The data source(s) to create or replace.
upsert_mode (Literal['replace']) – How existing data sources are updated. Currently only “replace” is supported, which fully replaces the existing data source. Defaults to “replace”.
- Returns:
The created or replaced data source(s).
- Return type:
Examples
Register a Fabric OneLake data source:
>>> import os >>> from cognite.client import CogniteClient, AsyncCogniteClient >>> from cognite.client.data_classes.transformations.externaldata import ( ... OneLakeCredentialsWrite, ... OneLakeExternalDataSourceWrite, ... OneLakeLocationDescription, ... OneLakeSettingsWrite, ... ) >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> data_source = OneLakeExternalDataSourceWrite( ... external_id="fabric-lakehouse-prod", ... name="Production lakehouse", ... data_set_id=123456, ... settings=OneLakeSettingsWrite( ... credentials=OneLakeCredentialsWrite( ... client_id="<azure-app-id>", ... tenant_id="<azure-tenant-uuid>", ... client_secret=os.environ["ONELAKE_CLIENT_SECRET"], ... ), ... location_description=OneLakeLocationDescription( ... workspace_id="<fabric-workspace-guid>", ... container_id="<fabric-lakehouse-guid>", ... ), ... ), ... ) >>> res = client.transformations.external_data_sources.upsert(data_source)