Skip to content

AVEVA/sample-adh-event_store-python

Repository files navigation

CONNECT data services Event Store Python Sample

📢 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

Build Status

Developed against Python 3.11.3.

Requirements

  • 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

About this sample

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

  1. Get or create authorization tag
  2. Get or create enumeration
  3. Get or create reference data type
  4. Get or create an Asset to reference
  5. Upsert reference data
  6. Upsert reference data using reference data class
  7. Get or Create event type
  8. Upsert events
  9. Upsert events using event class
  10. Get authorization tags
  11. Get Enumerations
  12. Get reference data types
  13. Get reference data
  14. Get reference data with reference data class
  15. Get event types
  16. Get events
  17. Get events with event class
  18. Use a graphQL query to retrieve events, reference data, and assets
  19. Clean up the created events and reference data

Configuring the sample

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.

Configuring appsettings.json

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",
}

Running the sample

To run this example from the command line once the appsettings.json is configured, run

python program.py

Running the automated test

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

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages