n8n-nodes-base
Version:
Base nodes of n8n
36 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.execute = execute;
const n8n_workflow_1 = require("n8n-workflow");
const helpers_1 = require("../helpers");
async function execute(i) {
const credentialType = (0, helpers_1.getActiveCredentialType)(this, i);
const host = await (0, helpers_1.getHost)(this, credentialType);
const catalogName = (0, helpers_1.extractResourceLocatorValue)(this.getNodeParameter('catalogName', i));
const schemaName = (0, helpers_1.extractResourceLocatorValue)(this.getNodeParameter('schemaName', i));
const volumeName = this.getNodeParameter('volumeName', i);
const volumeType = this.getNodeParameter('volumeType', i);
const additionalFields = this.getNodeParameter('additionalFields', i, {});
const body = {
catalog_name: catalogName,
schema_name: schemaName,
name: volumeName,
volume_type: volumeType,
};
if (volumeType === 'EXTERNAL' && !additionalFields.storage_location) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Storage Location is required for EXTERNAL volumes', { itemIndex: i });
}
if (additionalFields.comment)
body.comment = additionalFields.comment;
if (additionalFields.storage_location)
body.storage_location = additionalFields.storage_location;
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
method: 'POST',
url: `${host}/api/2.1/unity-catalog/volumes`,
body,
headers: { 'Content-Type': 'application/json' },
json: true,
});
return [{ json: response, pairedItem: { item: i } }];
}
//# sourceMappingURL=createVolume.operation.js.map