### Run Newman automated tests (Bash) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Sequence of Bash commands to install dependencies, install Newman globally, prepare the appsettings.json configuration, and execute the Postman collection with Newman for CI/CD integration. ```bash # Install dependencies\nnpm ci\n\n# Install Newman globally\nnpm install -g newman\n\n# Configure authentication - create appsettings.json from template\ncp appsettings.placeholder.json appsettings.json\n\n# Edit appsettings.json with your credentials\n[{\n \"Resource\": \"https://uswe.datahub.connect.aveva.com\",\n \"ApiVersion\": \"v1\",\n \"TenantId\": \"your-tenant-id\",\n \"NamespaceId\": \"your-namespace-id\",\n \"ClientId\": \"your-client-id\",\n \"ClientSecret\": \"your-client-secret\",\n \"StreamId\": \"your-stream-id\"\n}]\n\n# Run the collection with Newman\nnewman run ./postman_collection.json -d ./appsettings.json ``` -------------------------------- ### Postman Collection Variables Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Configuration and setup for the Postman collection used for testing. ```APIDOC ## Configuration and Setup ### Postman Collection Variables ```json { "ClientId": "your-client-id-from-portal", "ClientSecret": "your-client-secret-from-portal", "TenantId": "your-tenant-id", "NamespaceId": "your-namespace-id", "StreamId": "your-stream-id", "Resource": "https://uswe.datahub.connect.aveva.com", "ApiVersion": "v1" } ``` ``` -------------------------------- ### GET /api/v1/Tenants/{tenantId}/Namespaces Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Lists all namespaces within a specified tenant. Namespaces organize data streams and provide isolation for different applications. ```APIDOC ## GET /api/v1/Tenants/{tenantId}/Namespaces ### Description Lists all namespaces within a tenant. Namespaces are logical containers that organize data streams and provide isolation for different applications or business units within the CONNECT data services platform. ### Method GET ### Endpoint https://uswe.datahub.connect.aveva.com/api/v1/Tenants/{{TenantId}}/Namespaces ### Parameters #### Path Parameters - **tenantId** (string) - Required - The ID of the tenant whose namespaces are to be listed. #### Query Parameters None ### Request Example ```bash curl -X GET "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ### Response #### Success Response (200) - **Id** (string) - The unique identifier of the namespace. - **Region** (string) - The region where the namespace is located. - **Self** (string) - A URL pointing to the namespace resource. - **Description** (string) - A description of the namespace. - **State** (string) - The current state of the namespace (e.g., 'Active'). - **Owner** (object) - Information about the owner of the namespace. - **Type** (string) - The type of the owner (e.g., 'User'). - **TenantId** (string) - The tenant ID of the owner. - **ObjectId** (string) - The object ID of the owner. #### Response Example ```json [ { "Id": "production-namespace", "Region": "WestUS", "Self": "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/production-namespace", "Description": "Production data namespace", "State": "Active", "Owner": { "Type": "User", "TenantId": "YOUR_TENANT_ID", "ObjectId": "user-guid" } }, { "Id": "development-namespace", "Region": "WestUS", "Self": "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/development-namespace", "Description": "Development environment namespace", "State": "Active" } ] ``` ### Postman Configuration #### Test Script ```javascript if (pm.collectionVariables.get("TenantId") != '') { pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); } ``` ``` -------------------------------- ### List Namespaces within a Tenant (Bash/Curl) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This snippet demonstrates how to list all namespaces within a specific tenant using a GET request with Bearer token authentication. It requires the tenant ID and the access token. The response is a JSON array of namespace objects, including their IDs, regions, and descriptions. ```bash curl -X GET "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces" \ -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjEyMyIsInR5cCI6IkpXVCJ9..." ``` -------------------------------- ### GET /api/v1/Tenants/{tenantId} Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Retrieves tenant information using the bearer token. Returns basic metadata about the authenticated tenant. ```APIDOC ## GET /api/v1/Tenants/{tenantId} ### Description Retrieves tenant information from CONNECT data services using the bearer token. This endpoint returns basic metadata about the authenticated tenant including tenant ID, state, and configuration details. ### Method GET ### Endpoint https://uswe.datahub.connect.aveva.com/api/v1/Tenants/{{TenantId}} ### Parameters #### Path Parameters - **tenantId** (string) - Required - The ID of the tenant to retrieve information for. #### Query Parameters None ### Request Example ```bash curl -X GET "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ### Response #### Success Response (200) - **Id** (string) - The unique identifier of the tenant. - **Alias** (string) - An alias for the tenant. - **State** (string) - The current state of the tenant (e.g., 'Active'). - **Created** (string) - The timestamp when the tenant was created. - **LastModified** (string) - The timestamp when the tenant was last modified. #### Response Example ```json { "Id": "tenant-12345-abcde", "Alias": "MyCompanyTenant", "State": "Active", "Created": "2024-01-15T10:30:00Z", "LastModified": "2024-03-20T14:22:00Z" } ``` ### Postman Configuration - **Auth Type**: Bearer Token - **Token**: `{{token}}` - **URL**: `{{Resource}}/api/{{ApiVersion}}/Tenants/{{TenantId}}` ``` -------------------------------- ### GET /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams/{streamId}/Data Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This endpoint retrieves time-series data from a specific stream with pagination. It requires authentication and parameters for `startIndex` and `count`. ```APIDOC ## GET /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams/{streamId}/Data ### Description Retrieves time-series data from a specific stream with pagination. ### Method GET ### Endpoint /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams/{streamId}/Data ### Parameters #### Path Parameters - **tenantId** (string) - Required - The ID of the tenant. - **namespaceId** (string) - Required - The ID of the namespace. - **streamId** (string) - Required - The ID of the stream. #### Query Parameters - **startIndex** (string) - Required - ISO 8601 timestamp or numeric index. - **count** (integer) - Required - Number of data points to retrieve. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Timestamp** (string) - The timestamp of the data point. - **Temperature** (number) - The temperature value. - **Unit** (string) - The unit of the temperature. #### Response Example ```json [ { "Timestamp": "2024-01-01T00:00:00Z", "Temperature": 72.5, "Unit": "Fahrenheit" }, { "Timestamp": "2024-01-01T00:01:00Z", "Temperature": 72.7, "Unit": "Fahrenheit" }, { "Timestamp": "2024-01-01T00:02:00Z", "Temperature": 72.6, "Unit": "Fahrenheit" } ] ``` ``` -------------------------------- ### List streams in a namespace using curl (Bash) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Uses a GET request with an Authorization bearer token to retrieve all streams within a specified tenant and namespace. Requires the tenant and namespace IDs to be substituted. Returns a JSON array of stream objects. ```bash curl -X GET \"https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/YOUR_NAMESPACE_ID/Streams\" \\ -H \"Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjEyMyIsInR5cCI6IkpXVCJ9...\" ``` -------------------------------- ### GET /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This endpoint retrieves a list of streams within a specified namespace. It requires authentication using a bearer token and the tenant and namespace IDs. ```APIDOC ## GET /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams ### Description Retrieves a list of streams within a specified namespace. ### Method GET ### Endpoint /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams ### Parameters #### Path Parameters - **tenantId** (string) - Required - The ID of the tenant. - **namespaceId** (string) - Required - The ID of the namespace. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Id** (string) - The ID of the stream. - **Name** (string) - The name of the stream. - **Description** (string) - A description of the stream. - **TypeId** (string) - The type ID of the stream. - **Self** (string) - The self link of the stream. #### Response Example ```json [ { "Id": "sensor-temperature-01", "Name": "Temperature Sensor 01", "Description": "Building A temperature readings", "TypeId": "temperature-type", "Self": "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/YOUR_NAMESPACE_ID/Streams/sensor-temperature-01" }, { "Id": "sensor-pressure-01", "Name": "Pressure Sensor 01", "Description": "Building A pressure readings", "TypeId": "pressure-type", "Self": "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/YOUR_NAMESPACE_ID/Streams/sensor-pressure-01" } ] ``` ``` -------------------------------- ### Retrieve paginated stream data using curl (Bash) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt GET request with startIndex and count query parameters to fetch a specific range of time‑series data from a stream. Replace placeholders with actual tenant, namespace, stream IDs, and a valid bearer token. ```bash curl -X GET \"https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/YOUR_NAMESPACE_ID/Streams/sensor-temperature-01/Data?startIndex=2024-01-01T00:00:00Z&count=100\" \\ -H \"Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjEyMyIsInR5cCI6IkpXVCJ9...\" ``` -------------------------------- ### GET /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Retrieves all data streams within a specified namespace. Streams are time-series data collections with defined schemas. ```APIDOC ## GET /api/v1/Tenants/{tenantId}/Namespaces/{namespaceId}/Streams ### Description Retrieves all data streams within a specified namespace. Streams represent time-series data collections with defined schemas and are the fundamental data storage units in CONNECT data services. ### Method GET ### Endpoint https://uswe.datahub.connect.aveva.com/api/v1/Tenants/{{TenantId}}/Namespaces/{{NamespaceId}}/Streams ### Parameters #### Path Parameters - **tenantId** (string) - Required - The ID of the tenant. - **namespaceId** (string) - Required - The ID of the namespace. #### Query Parameters None ### Request Example ```bash curl -X GET "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID/Namespaces/YOUR_NAMESPACE_ID/Streams" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ### Response #### Success Response (200) - **Id** (string) - The unique identifier of the stream. - **NamespaceId** (string) - The ID of the namespace the stream belongs to. - **Name** (string) - The name of the stream. - **Description** (string) - A description of the stream. - **Created** (string) - The timestamp when the stream was created. - **LastModified** (string) - The timestamp when the stream was last modified. - **Schema** (object) - The schema definition for the stream. #### Response Example ```json [ { "Id": "stream-abc-123", "NamespaceId": "production-namespace", "Name": "TemperatureData", "Description": "Real-time temperature readings from sensors", "Created": "2024-02-01T09:00:00Z", "LastModified": "2024-03-15T11:45:00Z", "Schema": { "type": "object", "properties": { "timestamp": {"type": "string", "format": "date-time"}, "sensorId": {"type": "string"}, "value": {"type": "number"} }, "required": ["timestamp", "sensorId", "value"] } } ] ``` ``` -------------------------------- ### Retrieve Tenant Info using Bearer Token (Bash/Curl) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This snippet shows how to retrieve tenant information from CONNECT data services using a GET request with a Bearer token in the Authorization header. It requires the tenant ID and the obtained access token. The response contains tenant details like ID, Alias, State, and timestamps. ```bash curl -X GET "https://uswe.datahub.connect.aveva.com/api/v1/Tenants/YOUR_TENANT_ID" \ -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjEyMyIsInR5cCI6IkpXVCJ9..." ``` -------------------------------- ### Newman Automated Testing Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Instructions for running the collection with Newman for automated testing. ```APIDOC ## Newman Automated Testing ```bash # Install dependencies npm ci # Install Newman globally npm install -g newman # Configure authentication - create appsettings.json from template cp appsettings.placeholder.json appsettings.json # Edit appsettings.json with your credentials # See example above # Run the collection with Newman newman run ./postman_collection.json -d ./appsettings.json # Expected output # ... (Newman output indicating successful test runs) ... ``` -------------------------------- ### Define Postman collection variables (JSON) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt JSON object containing environment variables required by the Postman collection, such as client credentials, tenant and namespace IDs, and API endpoint information. ```json {\n \"ClientId\": \"your-client-id-from-portal\",\n \"ClientSecret\": \"your-client-secret-from-portal\",\n \"TenantId\": \"your-tenant-id\",\n \"NamespaceId\": \"your-namespace-id\",\n \"StreamId\": \"your-stream-id\",\n \"Resource\": \"https://uswe.datahub.connect.aveva.com\",\n \"ApiVersion\": \"v1\"\n} ``` -------------------------------- ### Auto-Discover Token Endpoint (Postman Pre-request Script) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This Postman pre-request script automatically discovers the token endpoint URL by querying the OpenID Connect configuration. It then stores the discovered token endpoint in a collection variable for subsequent use. This script is crucial for dynamic token acquisition. ```javascript pm.sendRequest(pm.collectionVariables.get('Resource') + '/identity/.well-known/openid-configuration', (error, response) => { if (error) { console.log(error); } else { jsonResponse = JSON.parse(response.text()) token_endpoint = jsonResponse['token_endpoint'] pm.collectionVariables.set('token_endpoint', token_endpoint) } }); ``` -------------------------------- ### Obtain Bearer Token using Client Credentials (Bash/Curl) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This snippet demonstrates how to obtain an OAuth 2.0 bearer token using the client credentials grant type via a curl command. It requires client ID, client secret, and specifies the grant type. The response includes the access token, expiration time, and token type. ```bash curl -X POST "https://uswe.datahub.connect.aveva.com/identity/connect/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "grant_type=client_credentials" ``` -------------------------------- ### Validate Tenant Info Response (Postman Test Script) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This Postman test script validates the response for retrieving tenant information. It checks if the status code is 200, but only if a TenantId is present in the collection variables, indicating a valid request context. ```javascript if (pm.collectionVariables.get("TenantId") != '') { pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); } ``` -------------------------------- ### POST /identity/connect/token Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Authenticates using client credentials to obtain an OAuth 2.0 bearer token. This endpoint supports automatic token endpoint discovery and stores the token for subsequent requests. ```APIDOC ## POST /identity/connect/token ### Description Authenticates with CONNECT data services using client credentials to obtain an OAuth 2.0 bearer token. This endpoint implements the client credentials grant flow, automatically discovers the token endpoint via OpenID Connect configuration, and stores the retrieved token in a Postman collection variable for subsequent requests. ### Method POST ### Endpoint https://uswe.datahub.connect.aveva.com/identity/connect/token ### Parameters #### Query Parameters - **client_id** (string) - Required - Your client ID. - **client_secret** (string) - Required - Your client secret. - **grant_type** (string) - Required - Must be 'client_credentials'. ### Request Example ```bash curl -X POST "https://uswe.datahub.connect.aveva.com/identity/connect/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "grant_type=client_credentials" ``` ### Response #### Success Response (200) - **access_token** (string) - The obtained bearer token. - **expires_in** (integer) - The token's expiration time in seconds. - **token_type** (string) - The type of token, typically 'Bearer'. #### Response Example ```json { "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEyMyIsInR5cCI6IkpXVCJ9...", "expires_in": 3600, "token_type": "Bearer" } ``` ### Postman Configuration #### Pre-request Script (Auto-discovery) ```javascript pm.sendRequest(pm.collectionVariables.get('Resource') + '/identity/.well-known/openid-configuration', (error, response) => { if (error) { console.log(error); } else { jsonResponse = JSON.parse(response.text()) token_endpoint = jsonResponse['token_endpoint'] pm.collectionVariables.set('token_endpoint', token_endpoint) } }); ``` #### Test Script (Token Storage) ```javascript pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); var jsonData = JSON.parse(responseBody); pm.collectionVariables.set("token", jsonData.access_token); ``` ``` -------------------------------- ### Store Bearer Token in Collection Variable (Postman Test Script) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt This Postman test script validates the token acquisition response and stores the obtained bearer token in a collection variable named 'token'. This variable can then be used in subsequent requests for authentication. It includes a status code check. ```javascript pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); var jsonData = JSON.parse(responseBody); pm.collectionVariables.set("token", jsonData.access_token); ``` -------------------------------- ### Validate stream list response in Postman (JavaScript) Source: https://context7.com/aveva/sample-adh-authentication_client_credentials_simple-postman/llms.txt Postman test script that checks required collection variables are set and asserts that the HTTP response status is 200. Useful for CI/CD validation of the list‑streams request. ```javascript if (pm.collectionVariables.get(\"NamespaceId\") != '' && pm.collectionVariables.get(\"TenantId\") != '') {\n pm.test(\"Status code is 200\", function () {\n pm.response.to.have.status(200);\n });\n} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.