Skip to content

Latest commit

 

History

History
82 lines (60 loc) · 4.05 KB

File metadata and controls

82 lines (60 loc) · 4.05 KB

AVEVA Data Hub Change Broker Service .NET REST API Sample

Build Status

Version 1.0.4

Developed against DotNet 6.0

Requirements

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

Definitions

  • ADH: AVEVA DataHub
  • SDS: Sequential Data Store

About this repository

The sample code in this repository demonstrates REST API calls to ADH for creating a Signup to receive resource updates. Signups 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 ADH using a client-credentials client
  2. Create SDS Types
  3. Create SDS Streams
  4. Create an ADH Signup against the created resources (streams)
  5. Make an API request to GetSignup to activate the signup
  6. Make an API request to GetSignupResources to view accessible and inaccessible resources in the signup
  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 UpdateSignupResources to include the new stream
  10. Make an API request to GetSignupResources using query parameters to view signup 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 signups and make an API request to GetAllSignups with query parameters to view all signups
  14. Cleanup signups, 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.

AVEVA Data Hub 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 ADH 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 signup name, query parameters, and number of additional signups to create. Please note: the maximum value for the count query parameter is 1,000 for get all signups and 10,000 for get signup 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 ADH Change Broker samples page ReadMe
For the main ADH samples page ReadMe
For the main AVEVA samples page ReadMe