How to get the Respiratory Rate from the Google Fit REST API - google-fit

I am using the Google Fit REST API and want to get the respiratory rate. In the Google Fit app on Android, there is support to add Respiratory Rate. The API that I am using to fetch the data is GET /fitness/v1/users/me/dataSources/{dataSourceId}/datasets/{datasetId} but unable to find the dataSourceId for respiratory rate. Unable to find anything in the documentation at https://developers.google.com/fit/datatypes/health. Usually, the GET /fitness/v1/users/me/dataSources API lists all the data sources but there is nothing for the respiratory rate. Below is the response after granting ALL the Fitness API permissions
{
"dataSource": [
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "duration",
"format": "integer"
}
],
"name": "com.google.active_minutes"
},
"dataStreamName": "merge_active_minutes",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.active_minutes:com.google.android.gms:merge_active_minutes",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataStreamName": "session_activity_segment",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.apps.fitness:session_activity_segment",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataStreamName": "merge_activity_segments",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:merge_activity_segments",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataStreamName": "session_activity_segment",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:session_activity_segment",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "body_temperature",
"format": "floatPoint"
},
{
"optional": true,
"name": "body_temperature_measurement_location",
"format": "integer"
}
],
"name": "com.google.body.temperature"
},
"dataStreamName": "merged",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.body.temperature:com.google.android.gms:merged",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "calories",
"format": "floatPoint"
}
],
"name": "com.google.calories.expended"
},
"dataStreamName": "merge_calories_expended",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.calories.expended:com.google.android.gms:merge_calories_expended",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "distance",
"format": "floatPoint"
}
],
"name": "com.google.distance.delta"
},
"dataStreamName": "merge_distance_delta",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.distance.delta:com.google.android.gms:merge_distance_delta",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "intensity",
"format": "floatPoint"
}
],
"name": "com.google.heart_minutes"
},
"dataStreamName": "merge_heart_minutes",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "bpm",
"format": "floatPoint"
}
],
"name": "com.google.heart_rate.bpm"
},
"dataStreamName": "merge_heart_rate_bpm",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "bpm",
"format": "floatPoint"
}
],
"name": "com.google.heart_rate.bpm"
},
"dataStreamName": "resting_heart_rate<-merge_heart_rate_bpm",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.heart_rate.bpm:com.google.android.gms:resting_heart_rate<-merge_heart_rate_bpm",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "oxygen_saturation",
"format": "floatPoint"
},
{
"name": "supplemental_oxygen_flow_rate",
"format": "floatPoint"
},
{
"optional": true,
"name": "oxygen_therapy_administration_mode",
"format": "integer"
},
{
"optional": true,
"name": "oxygen_saturation_system",
"format": "integer"
},
{
"optional": true,
"name": "oxygen_saturation_measurement_method",
"format": "integer"
}
],
"name": "com.google.oxygen_saturation"
},
"dataStreamName": "merged",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.oxygen_saturation:com.google.android.gms:merged",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "sleep_segment_type",
"format": "integer"
}
],
"name": "com.google.sleep.segment"
},
"dataStreamName": "merged",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.sleep.segment:com.google.android.gms:merged",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "speed",
"format": "floatPoint"
}
],
"name": "com.google.speed"
},
"dataStreamName": "merge_speed",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.speed:com.google.android.gms:merge_speed",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataStreamName": "estimated_steps",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataStreamName": "merge_step_deltas",
"application": {
"packageName": "com.google.android.gms"
},
"dataStreamId": "derived:com.google.step_count.delta:com.google.android.gms:merge_step_deltas",
"type": "derived"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "duration",
"format": "integer"
}
],
"name": "com.google.active_minutes"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.active_minutes:com.google.android.apps.fitness:user_input",
"type": "raw"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.activity.segment:com.google.android.apps.fitness:user_input",
"type": "raw"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "body_temperature",
"format": "floatPoint"
},
{
"optional": true,
"name": "body_temperature_measurement_location",
"format": "integer"
}
],
"name": "com.google.body.temperature"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.body.temperature:com.google.android.apps.fitness:user_input",
"type": "raw"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "intensity",
"format": "floatPoint"
}
],
"name": "com.google.heart_minutes"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.heart_minutes:com.google.android.apps.fitness:user_input",
"type": "raw"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "bpm",
"format": "floatPoint"
}
],
"name": "com.google.heart_rate.bpm"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.heart_rate.bpm:com.google.android.apps.fitness:user_input",
"type": "raw"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "oxygen_saturation",
"format": "floatPoint"
},
{
"name": "supplemental_oxygen_flow_rate",
"format": "floatPoint"
},
{
"optional": true,
"name": "oxygen_therapy_administration_mode",
"format": "integer"
},
{
"optional": true,
"name": "oxygen_saturation_system",
"format": "integer"
},
{
"optional": true,
"name": "oxygen_saturation_measurement_method",
"format": "integer"
}
],
"name": "com.google.oxygen_saturation"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.oxygen_saturation:com.google.android.apps.fitness:user_input",
"type": "raw"
},
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "steps",
"format": "integer"
}
],
"name": "com.google.step_count.delta"
},
"dataStreamName": "user_input",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"dataStreamId": "raw:com.google.step_count.delta:com.google.android.apps.fitness:user_input",
"type": "raw"
}
]
}
What data source ID do I need to use to get the respiratory rate?

Related

How to convert json schema in one form to other surported by cerberus?

How can we convert this schema to the below one:
{
"entityName": "Firm",
"attributes": [
{
"name": "FirmKey",
"rules": [
{
"type": "primaryKey",
"severity": "reject",
"operator": "",
"value": "1"
},
{
"type": "dataType",
"severity": "reject",
"operator": "",
"dataType": "int"
},
{
"type": "notNull",
"severity": "reject",
"operator": ""
}
]
},
{
"key": "attributedcfd6d27",
"name": "FirmName",
"unit": "",
"rules": [
{
"type": "dataType",
"severity": "reject",
"operator": "",
"dataType": "string"
}
],
}
}
converted:
{
"FirmKey":
{
"type": "list",
"schema":
{
"isint":true,
"isNull": NaN
}
},
"FirmName":
{
"type": "list",
"description": "Firm’s legal name",
"schema":
{
"type":"string",
"isNull": NaN
}
}
}

Editing json content with azure logic app

I want to create a logic app which replaces the value of resourcename inside an alert json structure received by a logic app. The alarm structure is as follows:
{
"schemaId": "AzureMonitorMetricAlert",
"data": {
"version": "2.0",
"properties": null,
"status": "Deactivated",
"context": {
"timestamp": "2021-08-21T01:43:09.2000007Z",
"id": "/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/microsoft.insights/metricAlerts/teste%20-%20vpnp2s%20count",
"name": "teste - vpnp2s count",
"description": "",
"conditionType": "SingleResourceMultipleMetricCriteria",
"severity": "3",
"condition": {
"windowSize": "PT1M",
"allOf": [
{
"metricName": "P2SConnectionCount",
"metricNamespace": "Microsoft.Network/p2sVpnGateways",
"operator": "GreaterThanOrEqual",
"threshold": "1",
"timeAggregation": "Total",
"dimensions": [],
"metricValue": 0,
"webTestName": null
}
]
},
"subscriptionId": "<subscription_id>",
"resourceGroupName": "<my_resource_group>",
"resourceName": "some_resource_name",
"resourceType": "Microsoft.Network/p2sVpnGateways",
"resourceId": "/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/Microsoft.Network/p2sVpnGateways/<p2svpngatewayid>",
"portalLink": "https://portal.azure.com/#resource/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/Microsoft.Network/p2sVpnGateways/<theresourceid>"
}
}
}
I've been trying all sorts of mix with 'set variable', 'initialize variable', 'compose' blocks, but still no luck. Anyone has a clue?
Based on the above requirement i have created the logic app which replaces the resource name using HTTP request & replace actions.
Below is the code view of my logic app :
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"ConversionToString": {
"inputs": {
"variables": [
{
"name": "StringConversion",
"type": "string",
"value": "#{json(string(triggerBody()))}"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"FInalJsonOutput": {
"inputs": {
"variables": [
{
"name": "JsonOutput",
"type": "object",
"value": "#json(variables('replaceResouceName'))"
}
]
},
"runAfter": {
"ReplaceResourceName": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"ReplaceResourceName": {
"inputs": {
"variables": [
{
"name": "replaceResouceName",
"type": "string",
"value": "#{replace(variables('StringConversion'),'some_resource_name','newresource')}"
}
]
},
"runAfter": {
"ConversionToString": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"data": {
"properties": {
"context": {
"properties": {
"condition": {
"properties": {
"allOf": {
"items": {
"properties": {
"dimensions": {
"type": "array"
},
"metricName": {
"type": "string"
},
"metricNamespace": {
"type": "string"
},
"metricValue": {
"type": "integer"
},
"operator": {
"type": "string"
},
"threshold": {
"type": "string"
},
"timeAggregation": {
"type": "string"
},
"webTestName": {}
},
"required": [
"metricName",
"metricNamespace",
"operator",
"threshold",
"timeAggregation",
"dimensions",
"metricValue",
"webTestName"
],
"type": "object"
},
"type": "array"
},
"windowSize": {
"type": "string"
}
},
"type": "object"
},
"conditionType": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"portalLink": {
"type": "string"
},
"resourceGroupName": {
"type": "string"
},
"resourceId": {
"type": "string"
},
"resourceName": {
"type": "string"
},
"resourceType": {
"type": "string"
},
"severity": {
"type": "string"
},
"subscriptionId": {
"type": "string"
},
"timestamp": {
"type": "string"
}
},
"type": "object"
},
"properties": {},
"status": {
"type": "string"
},
"version": {
"type": "string"
}
},
"type": "object"
},
"schemaId": {
"type": "string"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
Here is the sample output for reference post running the above logic app

Error creating JSON Unexpected Character Sequence

I've been trying to create a basic json for our testes to throw up a machine a and when required. I got most of it done however I am getting the following errors:
Line 158 Unexpected character sequence in member name
Line 167 A member with the name 'Properties' already exists
I understand 67 needs to be unique, but everytime I change and remove the { it creates more errors.
And unexpected character is the { on line 157, which I'm guessing should be either a string, maybe?
My template is below.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"offer": {
"type": "string",
"defaultvalue": "Windows",
"allowedValues": [
"windows",
"centos",
"RHEL"
]
},
"sku": {
"type": "string",
"defaultvalue": "2012-r2-datacenter",
"allowedValues": [
"2012-R2-Datacenter",
"2012-R2",
"68",
"72",
"73",
"74"
]
},
"virtualMachineSize": {
"type": "string",
"defaultvalue": "standard_A0",
"allowedValues": [
"Standard_A0",
"Standard_A1",
"standard_A2"
]
},
"adminUsername": {
"type": "string"
},
"ipaddress": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
"networkSecurityGroupName": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
},
"storageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountId": {
"type": "string"
},
"subnetName": {
"type": "string"
},
"ContainerName": {
"type": "string"
},
"autoShutdownStatus": {
"type": "string"
},
"autoShutdownTime": {
"type": "string"
},
"autoShutdownTimeZone": {
"type": "string"
},
"autoShutdownNotificationStatus": {
"type": "string"
}
},
"variables": {
"vnetId": "[resourceId('avset','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"stdvhdcontainername": "[concat(parameters('Containername'))]",
"vmosidiskname": "[concat(parameters('virtualMachineName'),'-osdisk')]"
},
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat (parameters('diagnosticsStorageAccountName')), ['blob']]"
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"offer": "[concat(parameters('offer'))]",
"sku": "[concat(parameters('offer'))]",
"version": "latest"
}
},
"osDisk": {
"vhd": {
"name": "[variables('vmosidiskname')]",
"uri": "[concat('http://', parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdvhdcontainername'),'/', variables('vmosidiskname'), '.vhd')]"
},
"name": "[parameters('virtualMachineName')]"
},
"name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"location": "[parameters('location')]",
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"timeInMinutes": "30"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
]
},
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2016-09-01",
"location": "[parameters('location')]"
},
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateipaddress": "[concat(parameters('ipaddress'))]",
"privateIPAllocationMethod": "static"
}
}
]
}
},
"outputs": [
{
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
]
}
]
}
Any pointers would be greatly appreciated.. thanks for your help :)
Params are below:)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "westeurope"
},
"virtualMachineName": {
"value": "cent-os-vm2"
},
"virtualMachineSize": {
"value": "Standard_A0"
},
"adminUsername": {
"value": "localadmin"
},
"virtualNetworkName": {
"value": "avset-vnet"
},
"networkInterfaceName": {
"value": "cent-os-vm01652"
},
"networkSecurityGroupName": {
"value": "cent-os-vm01-nsg"
},
"storageAccountName": {
"value": "avsetdisks419"
},
"diagnosticsStorageAccountName": {
"value": "avsetdiag112"
},
"diagnosticsStorageAccountId": {
"value": "avsetdiag117"
},
"subnetName": {
"value": "default"
},
"autoShutdownStatus": {
"value": "Enabled"
},
"autoShutdownTime": {
"value": "19:00"
},
"autoShutdownTimeZone": {
"value": "UTC"
},
"autoShutdownNotificationStatus": {
"value": "Disabled"
},
"ContainerName": {
"value": "vhd"
},
"offer": {
"value": "windows"
},
"sku": {
"value": "2012-R2-Datacenter"
},
"ipaddress": {
"value": "10.0.1.9"
}
}
}
There are many mistakes in your template. The following template should work.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"offer": {
"type": "string",
"defaultvalue": "windows",
"allowedValues": [
"windows",
"centos",
"RHEL"
]
},
"sku": {
"type": "string",
"defaultvalue": "2012-R2-Datacenter",
"allowedValues": [
"2012-R2-Datacenter",
"2012-R2",
"68",
"72",
"73",
"74"
]
},
"virtualMachineSize": {
"type": "string",
"defaultvalue": "Standard_A0",
"allowedValues": [
"Standard_A0",
"Standard_A1",
"standard_A2"
]
},
"adminUsername": {
"type": "string"
},
"ipaddress": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
"networkSecurityGroupName": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
},
"storageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountId": {
"type": "string"
},
"subnetName": {
"type": "string"
},
"ContainerName": {
"type": "string"
},
"autoShutdownStatus": {
"type": "string"
},
"autoShutdownTime": {
"type": "string"
},
"autoShutdownTimeZone": {
"type": "string"
},
"autoShutdownNotificationStatus": {
"type": "string"
}
},
"variables": {
"vnetId": "[resourceId('avset','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"stdvhdcontainername": "[concat(parameters('Containername'))]",
"vmosidiskname": "[concat(parameters('virtualMachineName'),'-osdisk')]"
},
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat (parameters('diagnosticsStorageAccountName')), ['blob']]"
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"offer": "[concat(parameters('offer'))]",
"sku": "[concat(parameters('offer'))]",
"version": "latest"
}
},
"osDisk": {
"vhd": {
"name": "[variables('vmosidiskname')]",
"uri": "[concat('http://', parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdvhdcontainername'),'/', variables('vmosidiskname'), '.vhd')]"
},
"name": "[parameters('virtualMachineName')]"
}
}
},
{
"name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"location": "[parameters('location')]",
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"timeInMinutes": "30"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
]
}
},
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2016-09-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateipaddress": "[concat(parameters('ipaddress'))]",
"privateIPAllocationMethod": "static"
}
}
]
}
}
],
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
}
In line 162, it lost a ,. Resource Microsoft.Compute/virtualMachines,Microsoft.DevTestLab/schedules,Microsoft.Network/networkInterfaces are in parallel. But in your template, Microsoft.Compute/virtualMachines contains others, so you get error log with the name 'Properties' already exists.
Note: You also need check your default value. Please note that case sensitive.
Update:
Ipconfigurations is wrong, it should like below:
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
Update 2:
The template.json and parameters.json works for me. Maybe you could modify your template according to this example.

Get and attach all child documents with it's parent in a single query elasticsearch

I have an elastic search implementation with parent and child relationship.
The parent (products) type has two child types(productfeatures, supplierpna).
I have the search feature on my application which needs to return the parent document based on the productcode field in the "products" type.
What I need is to get all child documents attached to the parent as a sub nested list with a single filtered query.
e.g. productcode = "123456" will return 10 products but some products has the child object and some don't, but I want to get the parent document regardless the child document existence.
I tried has_child option but it do not return the parent document when there is no child objects
Here is my mapping, any help in this regard will be very helpful.
{ "itdealer": {
"aliases": {},
"mappings": {
"products": {
"properties": {
"categoryname": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem",
"fields": {
"categoryname_ags": {
"type": "string",
"index": "not_analyzed"
}
}
},
"highPic": {
"type": "string",
"index": "no",
"include_in_all": false
},
"id": {
"type": "string"
},
"longDescription": {
"type": "string"
},
"lowPic": {
"type": "string",
"index": "no",
"include_in_all": false
},
"manufacturername": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem",
"fields": {
"manufacturername_ags": {
"type": "string",
"index": "not_analyzed"
}
}
},
"modelName": {
"type": "string",
"index": "no",
"include_in_all": false
},
"productManualPdfUrl": {
"type": "string",
"index": "no",
"include_in_all": false
},
"productPdfUrl": {
"type": "string",
"index": "no",
"include_in_all": false
},
"productSpecifications": {
"type": "nested",
"include_in_parent": true,
"include_in_root": true,
"include_in_all": true,
"properties": {
"featureGroupName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower",
"include_in_all": true
},
"featureGroupName.featureName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower",
"include_in_all": true
},
"featureGroupName.featureValue": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower",
"include_in_all": true
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "special",
"include_in_all": true
}
}
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"store": true,
"index_analyzer": "special"
},
"searchTerms": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem"
},
"shortDescription": {
"type": "string",
"store": true
},
"subCategoryname": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem",
"fields": {
"subCategoryname_ags": {
"type": "string",
"index": "not_analyzed"
}
}
},
"thumbPic": {
"type": "string",
"index": "no",
"include_in_all": false
},
"title": {
"type": "string",
"analyzer": "keylower",
"fields": {
"title_ac": {
"type": "string",
"index_analyzer": "pr_autocomplete",
"search_analyzer": "keylower"
},
"title_stem": {
"type": "string",
"index_analyzer": "stem",
"search_analyzer": "keylower"
}
}
},
"warrantyInfo": {
"type": "string",
"index": "no",
"include_in_all": false
}
}
},
"productfeatures": {
"_parent": {
"type": "products"
},
"_routing": {
"required": true
},
"properties": {
"featureGroupName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"featureGroupName.featureName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"featureGroupName.featureValue": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"features": {
"properties": {
"featureName": {
"type": "string"
},
"featureValue": {
"type": "string"
}
}
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "special"
}
}
},
"supplierpna": {
"_parent": {
"type": "products"
},
"_routing": {
"required": true
},
"properties": {
"freeStock": {
"type": "string",
"index": "no",
"include_in_all": false
},
"manufacturer": {
"type": "string",
"index": "no",
"include_in_all": false
},
"partNumber": {
"type": "string",
"index": "not_analyzed",
"store": true,
"index_analyzer": "special"
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"store": true
},
"rRP": {
"type": "double",
"store": true
},
"supplier": {
"type": "string",
"index": "not_analyzed",
"include_in_all": false
},
"supplierId": {
"type": "double",
"index": "no"
},
"supplierLogo": {
"type": "string",
"index": "no",
"include_in_all": false
},
"supplierName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"supplierProductDescription": {
"type": "string",
"index": "no",
"include_in_all": false
},
"supplierURL": {
"type": "string",
"index": "no",
"include_in_all": false
},
"updatedDate": {
"type": "date",
"index": "no",
"format": "dateOptionalTime",
"include_in_all": false
}
}
}
},
"settings": {
"index": {
"mapping": {
"allow_type_wrapper": "true"
},
"search": {
"slowlog": {
"threshold": {
"fetch": {
"warn": "1s"
}
}
}
},
"number_of_shards": "5",
"merge": {
"policy": {
"merge_factor": "10"
}
},
"creation_date": "1432827491555",
"analysis": {
"filter": {
"special": {
"split_on_numerics": "false",
"generate_word_parts": "false",
"preserve_original": "true",
"generate_number_parts": "false",
"split_on_case_change": "false",
"type_table": [
"# => ALPHA",
"- => ALPHA",
"$ => ALPHA",
"% => ALPHA"
],
"type": "word_delimiter"
},
"stemming": {
"type": "stemmer",
"language": "light_english"
},
"autocomplete": {
"min_gram": "1",
"type": "edge_ngram",
"stopwords": "_english_",
"max_gram": "20"
}
},
"analyzer": {
"special": {
"filter": [
"lowercase",
"special"
],
"type": "custom",
"tokenizer": "keyword"
},
"keylower": {
"filter": "lowercase",
"tokenizer": "standard"
},
"pr_autocomplete": {
"type": "custom",
"filter": [
"lowercase",
"autocomplete"
],
"tokenizer": "standard"
},
"stem": {
"filter": [
"lowercase",
"stemming"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1",
"version": {
"created": "1050299"
},
"uuid": "D1spSYWURBWIfXYRcsY6cg"
}
},
"warmers": {}}}
My current normal search query data
{
"query": {
"filtered": {
"query": {
"multi_match": {
"fields": [
"searchTerms",
"manufacturername^7",
"subCategoryname^4",
"title_ac^10",
"categoryname",
"shortDescription",
"productcode"
],
"query": "hp desktop",
"type": "cross_fields",
"operator": "or",
"tie_breaker": 0.3
}
}
}
},
"size": "10",
"from": "0",
"aggs": {
"manufacture": {
"terms": {
"field": "manufacturername_ags",
"size": 0,
"order": {
"_count": "desc"
}
}
},
"category": {
"terms": {
"field": "categoryname_ags",
"size": 0,
"order": {
"_count": "desc"
}
}
},
"subcategory": {
"terms": {
"field": "subCategoryname_ags",
"size": 0,
"order": {
"_count": "desc"
}
}
}
}
}
Right now this query only returns the parent document I want this query to be modified so that I will include the child objects both (productfeatures and supplierpna) in each parent document.

Swagger - Invalid JSON errors

I'm just starting with Swagger UI and I'm trying to understand how it works.
So far I've entered some JSON (manually) and this is the result:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "PhakeApps API",
"contact": {
"name": "PhakeApps API team",
"url": "http://phakeapps.com/"
},
"license": {
"name": "Creative Commons 4.0 International",
"url": "http://creativecommons.org/licenses/by/4.0/"
}
},
"host": "api.phakeapps.com",
"basePath": "/v1",
"schemes": [
"http"
],
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"paths": {
"/places/search": {
"post": {
"tags": [
"Places"
],
"description": "Search for (a) place(s) <br /><br /> <b>id</b> - The ID of the request. <br /> <b>api_key</b> - API Key for the platform the request is sent. <i>Currently, not required.</i> <br /> <b>Params</b> - Required. <i>See model & model schema.</i>",
"operationId": "PlacesSearch",
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"parameters": [
{
"name": "request",
"in": "body",
"paramType": "body",
"description": "Object containing the <u>id</u>, <u>api_key</u> and certain <u>params</u>.",
"required": true,
"schema": {
"$ref": "#/definitions/Search"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/PlacesResult"
}
},
"403": {
"description": "Validation error or Server Failure",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"definitions": {
"PlacesResult": {
"required": [
"data",
"id",
"code"
],
"properties": {
"data": {
"$ref": "#/definitions/Places"
},
"id": {
"type": "integer",
"format": "int32"
},
"code": {
"type": "integer",
"format": "int32"
}
}
},
"Places": {
"required": [
"places"
],
"properties": {
"places": {
"$ref": "#/definitions/Place"
}
}
},
"City": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"Neighbourhood": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"Cuisine": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"Place": {
"required": [
"id",
"name",
"city",
"neighbourhood",
"address",
"cuisine",
"price",
"photos_cnt",
"lat",
"lng",
"is_fav"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"city": {
"type": "array",
"items": {
"$ref": "#/definitions/City"
}
},
"neighbourhood": {
"type": "array",
"items": {
"$ref": "#/definitions/Neighbourhood"
}
},
"address": {
"type": "string"
},
"cuisine": {
"type": "array",
"items": {
"$ref": "#/definitions/Cuisine"
}
},
"price": {
"type": "integer",
"format": "int32"
},
"photos_cnt": {
"type": "integer",
"format": "int32"
},
"lat": {
"type": "double"
},
"lng": {
"type": "double"
},
"is_fav": {
"type": "boolean"
}
}
},
"Search": {
"required": [
"id",
"api_key",
"params"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"api_key": {
"type": "string"
},
"params": {
"$ref": "#/definitions/SearchParams"
}
}
},
"SearchParams": {
"required": [
"user_id",
"city_id",
"people",
"dt",
"locale"
],
"properties": {
"user_id": {
"type": "string",
"default": "956dda4c21c72e48f5f17a7cd783a0f7"
},
"city_id": {
"type": "string",
"default": "4ec4b3e6098c9d23c925b0c2451eb06a"
},
"people": {
"type": "integer",
"format": "int32",
"minimum": 1,
"default": 2
},
"dt": {
"type": "integer",
"format": "int32",
"default": "1427742000"
},
"locale": {
"type": "string",
"default": "bg"
},
"place_id": {
"type": "string",
"default": "0"
},
"neighborhood_id": {
"type": "string",
"default": "0"
},
"cuisine_id": {
"type": "string",
"default": "0"
},
"kids_place": {
"type": "boolean",
"default": false
},
"price": {
"type": "integer",
"format": "int64",
"default": 1
},
"outdoors": {
"type": "boolean",
"default": false
}
}
},
"Error": {
"required": [
"code",
"data"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"data": {
"type": "array",
"items": {
"type": "array"
}
}
}
}
}
}
However, swagger's validator says it's not valid. The error I get is this
[
{
"level": "error",
"domain": "validation",
"keyword": "anyOf",
"message": "instance failed to match at least one required schema among 2",
"schema": {
"loadingURI": "http://json-schema.org/draft-04/schema#",
"pointer": "/properties/type"
},
"instance": {
"pointer": "/definitions/Place/properties/lat/type"
}
}
]
Note that it works as expected (so far). It displays the data (models and models' structure) properly. Make requests and retrieves responses. Yet the validator says it's not valid. (The yellow badge saying 'Invalid', not the red one that says 'Error').
What am I missing?
Your spec is indeed not valid. In your Place definition, you use "type": "double" to describe the type of the lat (and also lng) property, but such a type does not exist.
If you want to describe a numeric value of 'double' size, you should change the definition as follows:
"lng": {
"type": "number",
"format": "double"
}
Do that everywhere you use the double type, and it should resolve that issue.