Datablock (Independent Publisher) (#2788)

* Revert "Merge branch 'microsoft:dev' into dev"

This reverts commit 096a7c3199, reversing
changes made to cb0948670f.

* Revert "Merge branch 'microsoft:dev' into dev"

This reverts commit cb0948670f, reversing
changes made to dc26e8a026.

* Revert "Revert "Merge branch 'microsoft:dev' into dev""

This reverts commit 01764d0a6d.

* Revert "Revert "Merge branch 'microsoft:dev' into dev""

This reverts commit a3f086ef0f.

* Add files via upload

* Revert "Add files via upload"

This reverts commit eeff7b7a02.

* Add files via upload

* Delete independent-publisher-connectors/FileIO directory

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Revert "Add files via upload"

This reverts commit 1d85506958.

* Add files via upload

* Update apiDefinition.swagger.json
This commit is contained in:
Troy Taylor 2023-12-20 10:11:33 -05:00 коммит произвёл GitHub
Родитель 3aa9e1469b
Коммит a972c8485f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 213 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,124 @@
{
"swagger": "2.0",
"info": {
"title": "Databox",
"description": "Build dashboards and track performance from everywhere. Connect your data from any tool and track it from any device.",
"version": "1.0.0",
"contact": {
"name": "Troy Taylor",
"url": "https://www.hitachisolutions.com",
"email": "ttaylor@hitachisolutions.com"
}
},
"host": "push.databox.com",
"basePath": "/",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/": {
"post": {
"responses": {
"200": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "The status of the request.",
"title": "Status"
},
"message": {
"type": "string",
"description": "The message of the request.",
"title": "Message"
},
"id": {
"type": "string",
"description": "The identifier of the request.",
"title": "ID"
}
}
}
}
},
"summary": "Send data",
"description": "Send a metric and value to your Datablock.",
"operationId": "DataPost",
"parameters": [
{
"name": "Accept",
"in": "header",
"required": true,
"type": "string",
"default": "application/vnd.databox.v2+json",
"x-ms-visibility": "internal"
},
{
"name": "body",
"in": "body",
"required": false,
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"metric_key_id": {
"type": "string",
"description": "The Metric Key identifier of the metric you want to send data to.",
"title": "Metric Key ID"
},
"value": {
"type": "number",
"format": "float",
"description": "The value you want to send to the metric, either an integer or a float.",
"title": "Value"
}
},
"required": [
"metric_key_id",
"value"
]
}
}
}
]
}
}
},
"definitions": {},
"parameters": {},
"responses": {},
"securityDefinitions": {
"basic-auth": {
"type": "basic"
}
},
"security": [
{
"basic-auth": []
}
],
"tags": [],
"x-ms-connector-metadata": [
{
"propertyName": "Website",
"propertyValue": "https://databox.com/"
},
{
"propertyName": "Privacy policy",
"propertyValue": "https://databox.com/privacy-policy"
},
{
"propertyName": "Categories",
"propertyValue": "Business Intelligence;Data"
}
]
}

Просмотреть файл

@ -0,0 +1,38 @@
{
"properties": {
"connectionParameters": {
"username": {
"type": "securestring",
"uiDefinition": {
"displayName": "Token",
"description": "The Token for this api",
"tooltip": "Provide the Token",
"constraints": {
"tabIndex": 2,
"clearText": true,
"required": "true"
}
}
},
"password": {
"type": "securestring",
"uiDefinition": {
"displayName": "Enter Space",
"description": "There is no password for this token, so just enter a space.",
"tooltip": "Enter a space.",
"constraints": {
"tabIndex": 3,
"clearText": false,
"required": "true"
}
}
}
},
"iconBrandColor": "#da3b01",
"scriptOperations": [],
"capabilities": [],
"policyTemplateInstances": [],
"publisher": "Troy Taylor",
"stackOwner": "Databox, Inc."
}
}

Просмотреть файл

@ -0,0 +1,17 @@
# Databox
Build dashboards and track performance from everywhere. Connect your data from any tool and track it from any device.
## Publisher: Troy Taylor, Hitachi Solutions
## Prerequisites
You must sign up for an account with [Databox](https://databox.com/signup).
## Obtaining Credentials
You will find your token in the [Data Manager section](https://app.databox.com/data-manager/connected).
## Supported Operations
### Send data
Send a metric and value to your Datablock.
## Known Issues and Limitations
The use of custom metrics requires the use of a paid plan or trial.

Просмотреть файл

@ -0,0 +1,34 @@
public class Script : ScriptBase
{
public override async Task<HttpResponseMessage> ExecuteAsync()
{
var requestContentAsString = await this.Context.Request.Content.ReadAsStringAsync().ConfigureAwait(false);
var requestContentAsJSON = JArray.Parse(requestContentAsString);
var data = new JArray();
foreach (var item in requestContentAsJSON)
{
var metricKeyId = "$" + (string)item["metric_key_id"];
var value = (float)item["value"];
var obj = new JObject();
obj[metricKeyId] = value;
data.Add(obj);
}
var newRequest = new JObject();
newRequest["data"] = data;
using (var stringWriter = new StringWriter())
{
JsonSerializer.CreateDefault().Serialize(stringWriter, newRequest);
var json = stringWriter.ToString();
this.Context.Request.Content = new StringContent(json, Encoding.UTF8, "application/json");
}
var response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(false);
return response;
}
}