Hello:
Please share some code example in python sdk to link a file to an asset.
thanks
Hello:
Please share some code example in python sdk to link a file to an asset.
thanks
Best answer by Andre Alves
I did not have time to test it, but according to the Cognite documentation, you can use FileMetadataUpdate
instead of updating directly as I mentioned before. Below is an example from the Cognite documentation on how to attach labels. In your case, you can replace labels
with asset_ids
as the parameter.
Attach labels to a files:
>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import FileMetadataUpdate
>>> client = CogniteClient()
>>> my_update = FileMetadataUpdate(id=1).labels.add(["PUMP", "VERIFIED"])
>>> res = client.files.update(my_update)
The documentation is available here: https://cognite-sdk-python.readthedocs-hosted.com/en/latest/files.html
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.