Skip to content

AVEVA/sample-adh-change_broker_rest_api-dotnet

Repository files navigation

CONNECT data services Change Broker Service .NET REST API Sample

Build Status

Version 1.0.5

Developed against DotNet 8.0

Requirements

The .NET Core CLI is referenced in this sample, and should be installed to run the sample from the command line.

Definitions

  • Cds: CONNECT data services
  • SDS: Sequential Data Store

About this repository

The sample code in this repository demonstrates REST API calls to Cds for creating a # to receive resource updates. #s allow clients to subscribe resources (for example, streams) and get updates for those resources.

The sample will perform the following procedures:

  1. Obtain an OAuth token for Cds using a client-credentials client
  2. Create SDS Types
  3. Create SDS Streams
  4. Create an Cds # against the created resources (streams)
  5. Make an API request to Get# to activate the #
  6. Make an API request to Get#Resources to view accessible and inaccessible resources in the #
  7. Make updates to the Streams (post data to stream)
  8. Make an API request to GetUpdates and ensure that data updates are received
  9. Create a new SDS Stream and make an API request to Update#Resources to include the new stream
  10. Make an API request to Get#Resources using query parameters to view # with updated resources
  11. Update streams using non-Insert operations
  12. Make an API request to GetUpdates using the bookmark from the previous GetUpdates response to demonstrate update retrieval of other operation types (for example, Replace, Update, Remove and RemoveWindow).
  13. Create additional #s and make an API request to GetAll#s with query parameters to view all #s
  14. Cleanup #s, streams, and type

NOTE: Communication with SDS will be done via the .NET OCS Clients Library. Communication with Change Broker will be done using Http.

Configuring the sample

The sample is configured using the file appsettings.placeholder.json. Before editing, 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.

{
  "NamespaceId": "PLACEHOLDER_REPLACE_WITH_NAMESPACE_ID",
  "TenantId": "PLACEHOLDER_REPLACE_WITH_TENANT_ID",
  "Resource": "https://uswe.datahub.connect.aveva.com",
  "ClientId": "PLACEHOLDER_REPLACE_WITH_CLIENT_ID",
  "ClientSecret": "PLACEHOLDER_REPLACE_WITH_CLIENT_SECRET",
}

Within the sample, there are configurable options for number of streams to create, the # name, query parameters, and number of additional #s to create. Please note: the maximum value for the count query parameter is 1,000 for get all #s and 10,000 for get # resources.

Running the sample

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

cd ChangeBrokerRestApi
dotnet restore
dotnet run

Running the automated test

To test the sample, run

cd ChangeBrokerRestApiTest
dotnet restore
dotnet test

Tested against DotNet 6.0.
For the Cds Change Broker samples page ReadMe
For the main Cds samples page ReadMe
For the main AVEVA samples page ReadMe

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8

Languages