diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/404.html b/404.html new file mode 100644 index 000000000..65c88a6f2 --- /dev/null +++ b/404.html @@ -0,0 +1,6173 @@ + + + + +
+ + + + + + + + + + + + + + + + + + +RTDIP REST APIs require Azure Active Directory Authentication and passing the token received as an authorization
header in the form of a Bearer token. An example of the REST API header is Authorization: Bearer <<token>>
If a developer or business user would like to leverage the RTDIP REST API suite, it is recommended that they use the Identity Packages provided by Azure to obtain a token.
+Note
+Note that the above packages have the ability to obtain tokens for end users and service principals and support all available authentication options.
+Ensure to install the relevant package and obtain a token.
+See the examples section to see various authentication methods implemented.
+ + + + + + +The RTDIP repository contains the code to deploy the RTDIP REST APIs to your own Azure Cloud environment. The APIs are built as part of the rtdip repository CI/CD pipelines and the image is deployed to Docker Hub repo rtdip/api
. Below contains information on how to build and deploy the containers from source or to setup your function app to use the deployed container image provided by RTDIP.
To deploy the RTDIP APIs directly from the repository, follow the steps below:
+docker build --tag <container_registry_url>/rtdip-api:v0.1.0 -f src/api/Dockerfile .
+
docker login <container_registry_url>
+
docker push <container_registry_url>/rtdip-api:v0.1.0
+
az functionapp config container set --name <function_app_name> --resource-group <resource_group_name> --docker-custom-image-name <container_registry_url>/rtdip-api:v0.1.0
+
To deploy the RTDIP APIs from Docker Hub, follow the steps below:
+az functionapp config container set --name <function_app_name> --resource-group <resource_group_name> --docker-custom-image-name rtdip/api:azure-<version>
+
Below are examples of how to execute APIs using various authentication options and API methods.
+A python example of obtaining a token as a user can be found below using the azure-identity
python package to authenticate with Azure AD.
POST Requests
+The POST request can be used to pass many tags to the API. This is the preferred method when passing large volumes of tags to the API.
+from azure.identity import DefaultAzureCredential
+import requests
+
+authentication = DefaultAzureCredential()
+access_token = authentication.get_token("2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default").token
+
+params = {
+"business_unit": "Business Unit",
+"region": "Region",
+"asset": "Asset Name",
+"data_security_level": "Security Level",
+"data_type": "float",
+"tag_name": "TAG1",
+"tag_name": "TAG2",
+"start_date": "2022-01-01",
+"end_date": "2022-01-01",
+"include_bad_data": True
+}
+
+url = "https://example.com/api/v1/events/raw"
+
+payload={}
+headers = {
+'Authorization': 'Bearer {}'.format(access_token)
+}
+
+response = requests.request("GET", url, headers=headers, params=params, data=payload)
+
+print(response.json())
+
from azure.identity import DefaultAzureCredential
+import requests
+
+authentication = DefaultAzureCredential()
+access_token = authentication.get_token("2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default").token
+
+params = {
+"business_unit": "Business Unit",
+"region": "Region",
+"asset": "Asset Name",
+"data_security_level": "Security Level",
+"data_type": "float",
+"start_date": "2022-01-01T15:00:00",
+"end_date": "2022-01-01T16:00:00",
+"include_bad_data": True
+}
+
+url = "https://example.com/api/v1/events/raw"
+
+payload={"tag_name": ["TAG1", "TAG2"]}
+
+headers = {
+"Authorization": "Bearer {}".format(access_token),
+}
+
+# Requests automatically sets the Content-Type to application/json when the request body is passed via the json parameter
+response = requests.request("POST", url, headers=headers, params=params, json=payload)
+
+print(response.json())
+
Authentication using Service Principals is similar to end user authentication. An example, using Python is provided below where the azure-identity
package is not used, instead a direct REST API call is made to retrieve the token.
curl --location --request POST 'https://login.microsoftonline.com/{tenant id}/oauth2/v2.0/token' \
+--form 'grant_type="client_credentials"' \
+--form 'client_id="<<client id>>"' \
+--form 'client_secret="<<client secret>>"' \
+--form 'scope="2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default"'
+
import requests
+
+url = "https://login.microsoftonline.com/{tenant id}/oauth2/v2.0/token"
+
+payload={'grant_type': 'client_credentials',
+'client_id': '<<client id>>',
+'client_secret': '<<client secret>>',
+'scope': '2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default'}
+files=[]
+headers = {}
+
+response = requests.request("POST", url, headers=headers, data=payload, files=files)
+
+access_token = response.json()["access_token"]
+
+params = {
+ "business_unit": "Business Unit",
+ "region": "Region",
+ "asset": "Asset Name",
+ "data_security_level": "Security Level",
+ "data_type": "float",
+ "tag_name": "TAG1",
+ "tag_name": "TAG2",
+ "start_date": "2022-01-01",
+ "end_date": "2022-01-01",
+ "include_bad_data": True
+}
+
+url = "https://example.com/api/v1/events/raw"
+
+payload={}
+headers = {
+'Authorization': 'Bearer {}'.format(access_token)
+}
+
+response = requests.request("GET", url, headers=headers, params=params, data=payload)
+
+print(response.text)
+
RTDIP provides REST API endpoints for querying data in the platform. The APIs are a wrapper to the python RTDIP SDK and provide similar functionality for users and applications that are unable to leverage the python RTDIP SDK. It is recommended to read the RTDIP SDK documentation and in particular the Functions section for more information about the options and logic behind each API.
+ + + + + + +RTDIP REST API documentation is available in a number of formats, as described below.
+RTDIP REST APIs are built to OpenAPI standard 3.0.2. You can obtain the OpenAPI JSON schema at the following endpoint of your deployed APIs https://{domain name}/api/openapi.json
It is recommended to review the Swagger documentation that can be found at the following endpoint of your deployed APIs https://{domain name}/docs
for more information about the parameters and options for each API. It is also possible to try out each API from this link.
Additionally, further information about each API can be found in Redoc format at the following endpoint of your deployed APIs https://{domain name}/redoc
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var _a=/["'&<>]/;Pn.exports=Aa;function Aa(e){var t=""+e,r=_a.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i