diff --git a/adapter/0.1.30.json b/adapter/0.1.30.json new file mode 100644 index 0000000..876d5b9 --- /dev/null +++ b/adapter/0.1.30.json @@ -0,0 +1,46 @@ +/** + * Copyright © 2016-2018 by IntegrIT S.A. dba Hackolade. All rights reserved. + * + * The copyright to the computer software herein is the property of IntegrIT S.A. + * The software may be used and/or copied only with the written permission of + * IntegrIT S.A. or in accordance with the terms and conditions stipulated in + * the agreement/contract under which the software has been supplied. + * + * { + * "add": { + * "entity": [], + * "container": [], + * "model": [], + * "view": [], + * "field": { + * "": [] + * } + * }, + * "remove": { + * "entity": [], + * "container": [], + * "model": [], + * "view": [], + * "field": { + * "": [] + * } + * }, + * "modify": { + * "entity": [ + * { + * "from": { }, + * "to": { } + * } + * ], + * "container": [], + * "model": [], + * "view": [], + * "field": [] + * }, + * } + */ + { + "add": { + "container": ["capacityMode"] + } +} \ No newline at end of file diff --git a/forward_engineering/applyToInstance/applyToInstanceHelper.js b/forward_engineering/applyToInstance/applyToInstanceHelper.js index 302b5a3..c4307f4 100644 --- a/forward_engineering/applyToInstance/applyToInstanceHelper.js +++ b/forward_engineering/applyToInstance/applyToInstanceHelper.js @@ -67,6 +67,16 @@ const applyToInstanceHelper = (_) => ({ return -1; } }, + + getContainerThroughputProps(containerData) { + if (containerData.capacityMode === "Serverless") { + return {}; + } + if (containerData.autopilot) { + return { maxThroughput: containerData.throughput || 4000 }; + } + return { throughput: containerData.throughput || 400 }; + } }); module.exports = applyToInstanceHelper; \ No newline at end of file diff --git a/forward_engineering/applyToInstance/index.js b/forward_engineering/applyToInstance/index.js index ecb0cc2..f74c897 100644 --- a/forward_engineering/applyToInstance/index.js +++ b/forward_engineering/applyToInstance/index.js @@ -87,9 +87,9 @@ module.exports = { logger.log('info', connectionInfo, 'Apply to instance connection settings', connectionInfo.hiddenKeys); const client = helper.setUpDocumentClient(connectionInfo); const script = parseScript(connectionInfo.script); - const containerData = _.get(connectionInfo, 'containerData'); - const databaseId = _.get(containerData, '[0].dbId'); - const containerId = _.get(containerData, '[0].name'); + const containerData = _.get(connectionInfo, 'containerData[0]'); + const databaseId = _.get(containerData, 'dbId'); + const containerId = _.get(containerData, 'name'); if (!databaseId) { return callback({ @@ -109,6 +109,8 @@ module.exports = { id: containerId, partitionKey: script.partitionKey, defaultTtl: helper.getTTL(containerData), + ...helper.getContainerThroughputProps(containerData), + }); progress('Add sample documents ...'); diff --git a/properties_pane/container_level/containerLevelConfig.json b/properties_pane/container_level/containerLevelConfig.json index 1c282f1..cf99c74 100644 --- a/properties_pane/container_level/containerLevelConfig.json +++ b/properties_pane/container_level/containerLevelConfig.json @@ -180,6 +180,13 @@ making sure that you maintain a proper JSON format. "template": "orderedList" }] }, + { + "propertyName": "Description", + "propertyKeyword": "description", + "propertyTooltip": "description", + "propertyType": "details", + "template": "textarea" + }, { "propertyName": "Database ID", "propertyKeyword": "dbId", @@ -191,17 +198,24 @@ making sure that you maintain a proper JSON format. } }, { - "propertyName": "Description", - "propertyKeyword": "description", - "propertyTooltip": "description", - "propertyType": "details", - "template": "textarea" + "propertyName": "Capacity mode", + "propertyKeyword": "capacityMode", + "propertyTooltip": "Choose the capacity mode", + "propertyType": "select", + "options": [ + "Provisioned throughput", + "Serverless" + ] }, { "propertyName": "Autoscale", "propertyKeyword": "autopilot", "propertyType": "checkbox", - "template": "boolean" + "template": "boolean", + "dependency": { + "key": "capacityMode", + "value": "Provisioned throughput" + } }, { "propertyName": "Maximum throughput (RU/s)", @@ -210,8 +224,17 @@ making sure that you maintain a proper JSON format. "propertyType": "numeric", "valueType": "number", "dependency": { - "key": "autopilot", - "value": true + "type": "and", + "values": [ + { + "key": "autopilot", + "value": true + }, + { + "key": "capacityMode", + "value": "Provisioned throughput" + } + ] } }, { @@ -221,8 +244,22 @@ making sure that you maintain a proper JSON format. "propertyType": "numeric", "valueType": "number", "dependency": { - "key": "autopilot", - "value": false + "type": "and", + "values": [ + { + "type": "not", + "values": [ + { + "key": "autopilot", + "value": true + } + ] + }, + { + "key": "capacityMode", + "value": "Provisioned throughput" + } + ] } }, { diff --git a/properties_pane/defaultData.json b/properties_pane/defaultData.json index 94797a8..14081be 100644 --- a/properties_pane/defaultData.json +++ b/properties_pane/defaultData.json @@ -23,7 +23,8 @@ "name": "New container", "partitionKey": [], "indexes": [], - "autopilot": false + "autopilot": false, + "capacityMode": "Provisioned throughput" }, "collection": { "collectionName": "New item type", diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index e01d98b..c3eb6ff 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -132,11 +132,12 @@ module.exports = { const udfs = await getUdfs(containerInstance); const collection = await getCollectionById(containerInstance); const offerInfo = await getOfferType(collection, logger); - const { autopilot, throughput } = getOfferProps(offerInfo); + const { autopilot, throughput, capacityMode } = getOfferProps(offerInfo); const partitionKey = getPartitionKey(collection); const indexes = getIndexes(collection.indexingPolicy); const bucketInfo = Object.assign({ dbId: data.database, + capacityMode, throughput, autopilot, partitionKey, @@ -552,16 +553,24 @@ function getUniqueKeys(collection) { } function getOfferProps(offer) { + if (!offer) { + return { + capacityMode: 'Serverless', + autopilot: false, + }; + } const isAutopilotOn = _.get(offer, 'content.offerAutopilotSettings'); if (isAutopilotOn) { return { autopilot: true, - throughput: offer.content.offerAutopilotSettings.maximumTierThroughput + throughput: offer.content.offerAutopilotSettings.maximumTierThroughput, + capacityMode: 'Provisioned throughput', }; } return { autopilot: false, - throughput: offer ? offer.content.offerThroughput : '' + throughput: offer ? offer.content.offerThroughput : '', + capacityMode: 'Provisioned throughput', }; }