Generation of SDK¶
In most of the usage demonstration we wil work with the following model of a windmill.
Generation of SDK¶
To create a new Python SDK for the data model above, we assume you have installed cognite-pygen[cli]
withe the CLI option.
Furthermore, we have the model above located in the space power-models
with the external id Windmill
and this is version 1
.
We generate a new SDK with the following command
pygen --space power-models --external-id Windmill --version 1 --tenant-id <tenant-id> --client-id <client-id> --client-secret <client-secret> --cdf-cluster <cdf-cluster> --cdf-procect <cdf-project> --top-level-package windmill.client --client-name WindmillClient
This create the SDK with the following folder structure
windmill/
├── _api
│ ├── __init__.py
│ ├── _core.py
│ ├── blade.py
│ ├── blade_query.py
│ ├── blade_sensor_positions.py
...
│ ├── windmill.py
│ ├── windmill_blades.py
│ ├── windmill-metmast.py
│ └── windmill_query.py
├── data_classes
│ ├── `__init__`.py
│ ├── _core.py
│ ├── _blade.py
│ ├── _gearbox.py
│ ├── _generator.py
│ ├── _high_speed_shaft.py
│ ├── _main_shaft.py
│ ├── _metmast.py
│ ├── _nacelle.py
│ ├── _power_inverter.py
│ ├── _rotor.py
│ ├── _sensor_position.py
│ └── _windmill.py
├── __init__.py
└── _api_client.py
This is now available and can be imported
Creating Client¶
We have a configuration file next to this notebook with the format
[cognite]
project = "<cdf-project>"
tenant_id = "<tenant-id>"
cdf_cluster = "<cdf-cluster>"
client_id = "<client-id>"
client_secret = "<client-secret>"
This enables us to easily create a new movie client
In [2]:
Copied!
from windmill import WindmillClient
from windmill import WindmillClient
In [3]:
Copied!
client = WindmillClient.from_toml("config.toml")
client = WindmillClient.from_toml("config.toml")
The client has now been instantiated and is ready to go, listing filtering and retrieving.
In [4]:
Copied!
client
client
Out[4]:
WindmillClient generated from data model ("power-models", "Windmill", "1")
with the following APIs available
.blade
.gearbox
.generator
.high_speed_shaft
.main_shaft
.metmast
.nacelle
.power_inverter
.rotor
.sensor_position
.windmill
and with the methods:
.upsert - Create or update any instance.
.delete - Delete instances.
with the following APIs available
.blade
.gearbox
.generator
.high_speed_shaft
.main_shaft
.metmast
.nacelle
.power_inverter
.rotor
.sensor_position
.windmill
and with the methods:
.upsert - Create or update any instance.
.delete - Delete instances.
In [ ]:
Copied!