Create assets
- async AsyncCogniteClient.assets.create(
- asset: Asset | AssetWrite | Sequence[Asset] | Sequence[AssetWrite],
-
You can create an arbitrary number of assets, and the SDK will split the request into multiple requests. When specifying parent-child relation between assets using parentExternalId the link will be resvoled into an internal ID and stored as parentId.
- Parameters:
asset (Asset | AssetWrite | Sequence[Asset] | Sequence[AssetWrite]) – Asset or list of assets to create.
- Returns:
Created asset(s)
- Return type:
Examples
Create new assets:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes import AssetWrite >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> assets = [AssetWrite(name="asset1"), AssetWrite(name="asset2")] >>> res = client.assets.create(assets)
Create asset with label:
>>> from cognite.client.data_classes import AssetWrite, Label >>> asset = AssetWrite(name="my_pump", labels=[Label(external_id="PUMP")]) >>> res = client.assets.create(asset)