📢 Notice: This sample uses the CONNECT data services Event Store, which is currently in preview. To get access to this feature, please reach out to your account manager. |
---|
Version: 1.0.2
Developed against Python 3.11.3.
- CONNECT data services with the Event Store feature enabled
- Python 3.7+
- Register a Client-Credentials Client in your CONNECT data services tenant and create a client secret to use in the configuration of this sample. (Video Walkthrough). Please note that a client is a different authentication method from using your user account to login.
- The client that is registered must have "Manage Permissions" access on all collections and collection items that you intend to set security for. Generally, the Tenant Administrator role will have manage access unless a custom configuration has been set.
- Install required modules:
pip install -r requirements.txt
This sample uses the sample python library, which makes REST API calls to Cds, to show usage of the CONNECT data services events store. The steps are as follows
- Get or create authorization tag
- Get or create enumeration
- Get or create reference data type
- Get or create an Asset to reference
- Upsert reference data
- Upsert reference data using reference data class
- Get or Create event type
- Upsert events
- Upsert events using event class
- Get authorization tags
- Get Enumerations
- Get reference data types
- Get reference data
- Get reference data with reference data class
- Get event types
- Get events
- Get events with event class
- Use a graphQL query to retrieve events, reference data, and assets
- Clean up the created events and reference data
The sample is configured by modifying the file appsettings.placeholder.json. Details on how to configure it can be found in the sections below. Before editing appsettings.placeholder.json, rename this file to appsettings.json
. This repository's .gitignore
rules should prevent the file from ever being checked in to any fork or branch, to ensure credentials are not compromised.
CONNECT data services is secured by obtaining tokens from its identity endpoint. Client credentials clients provide a client application identifier and an associated secret (or key) that are authenticated against the token endpoint. You must replace the placeholders in your appsettings.json
file with the authentication-related values from your tenant and a client-credentials client created in your Cds tenant.
{
"Resource": "https://uswe.datahub.connect.aveva.com",
"ApiVersion": "v1",
"TenantId": "PLACEHOLDER_REPLACE_WITH_TENANT_ID",
"NamespaceId": "PLACEHOLDER_REPLACE_WITH_NAMESPACE_ID",
"ClientId": "PLACEHOLDER_REPLACE_WITH_APPLICATION_IDENTIFIER",
"ClientSecret": "PLACEHOLDER_REPLACE_WITH_APPLICATION_SECRET",
}
To run this example from the command line once the appsettings.json
is configured, run
python program.py
To test the sample, run
pip install pytest
python -m pytest test.py
Note: Example ids for event types, reference data types, etc. are hardcoded, and will need to be updated if they are changed in program.py
Tested against Python 3.11.1
For the main Cds samples page ReadMe
For the main AVEVA samples page ReadMe