Rest API to disable /enable Reflections

First thing to do is login to get the authorization token:

curl --request POST \
  --url http://localhost:9047/apiv2/login \
  --header 'authorization : _dremio6ro5jfgsbue98eeh0vmn9utnoa' \
  --header 'content-type: application/json' \
  --data '{
  "userName": "username",
  "password": "password"
}'

That will return a JSON object that contains a token value.

Next you have to get the id for the reflection - you can list all reflections using:

curl --request GET \
  --url http://localhost:9047/api/v3/reflection \
  --header 'authorization : _dremio${authorization}' \
  --header 'content-type: application/json'

This gives you a list of all reflections:

{
	"data": [
		{
			"id": "e7f924ca-0014-4288-85d9-d698c4e342a1",
			"type": "AGGREGATION",
			"name": "Aggregation Reflection",
			"tag": "5",
			"datasetId": "77d43461-bf46-47c0-9d04-d8b82b6794e5",
			"enabled": true,
			"partitionDistributionStrategy": "CONSOLIDATED",
			"entityType": "reflection"
		}
	]
}

The enabled field controls the enabling/disabling of a reflection. To update the reflection, you would PUT the reflection like this (in this case we disable the reflection):

curl --request PUT \
  --url http://localhost:9047/api/v3/reflection \
  --header 'authorization : _dremio6ro5jfgsbue98eeh0vmn9utnoa' \
  --header 'content-type: application/json' \
  --data '{
	"data": [
		{
			"id": "e7f924ca-0014-4288-85d9-d698c4e342a1",
			"type": "AGGREGATION",
			"name": "Aggregation Reflection",
			"tag": "5",
			"datasetId": "77d43461-bf46-47c0-9d04-d8b82b6794e5",
			"enabled": false,
			"measureFields": [
				{
					"name": "PdId",
					"measureTypeList": [
						"COUNT",
						"SUM",
						"MIN",
						"MAX"
					]
				},
				{
					"name": "Descript",
					"measureTypeList": [
						"COUNT",
						"MIN",
						"MAX"
					]
				}
			],
			"partitionDistributionStrategy": "CONSOLIDATED",
			"entityType": "reflection"
		}
	]
}'
2 Likes