Create
- async AsyncCogniteClient.transformations.external_data_sources.create(
- data_source: ExternalDataSourceWrite | Sequence[ExternalDataSourceWrite],
-
Fails with a 409 if any external ID in the request already exists for the project; no items are created in that case. To modify an existing data source, delete it and create a replacement.
- Parameters:
data_source (ExternalDataSourceWrite | Sequence[ExternalDataSourceWrite]) – The data source(s) to create.
- Returns:
The created data source(s).
- Return type:
- Raises:
CogniteDuplicatedError – If an external ID in the request already exists for the project.
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.create(data_source)