n8n-nodes-ionos
Version:
n8n nodes for IONOS DNS, Domain, SSL/Certificate management, Cloud AI, Cloud Infrastructure, Container Registry, Database as a Service, CDN, VPN Gateway, Activity Log, Billing, Logging, Monitoring, Object Storage Management, Network File Storage, Identity
1,255 lines (1,254 loc) • 56.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IonosCloudDnsService = void 0;
const baseUrl = 'https://dns.de-fra.ionos.com';
class IonosCloudDnsService {
description = {
displayName: 'IONOS Cloud DNS Service',
name: 'ionosCloudDnsService',
icon: 'file:ionos.svg',
group: ['transform'],
version: 1,
subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}',
description: 'Manage IONOS Cloud DNS zones, records, DNSSEC, and reverse DNS. Developped with Love by Ascenzia (ascenzia.fr)',
defaults: {
name: 'IONOS Cloud DNS Service',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'ionosCloud',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Zone',
value: 'zone',
description: 'Manage DNS zones',
},
{
name: 'Secondary Zone',
value: 'secondaryZone',
description: 'Manage secondary DNS zones',
},
{
name: 'Record',
value: 'record',
description: 'Manage DNS records',
},
{
name: 'Zone File',
value: 'zoneFile',
description: 'Import/Export zone files',
},
{
name: 'DNSSEC Key',
value: 'dnssecKey',
description: 'Manage DNSSEC keys',
},
{
name: 'Reverse Record',
value: 'reverseRecord',
description: 'Manage reverse DNS (PTR) records',
},
{
name: 'Quota',
value: 'quota',
description: 'Get quota information',
},
],
default: 'zone',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['zone'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a DNS zone',
action: 'Create a DNS zone',
},
{
name: 'Get',
value: 'get',
description: 'Get a DNS zone',
action: 'Get a DNS zone',
},
{
name: 'Get Many',
value: 'getMany',
description: 'Get many DNS zones',
action: 'Get many DNS zones',
},
{
name: 'Update',
value: 'update',
description: 'Update a DNS zone',
action: 'Update a DNS zone',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a DNS zone',
action: 'Delete a DNS zone',
},
],
default: 'create',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['secondaryZone'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a secondary zone',
action: 'Create a secondary zone',
},
{
name: 'Get',
value: 'get',
description: 'Get a secondary zone',
action: 'Get a secondary zone',
},
{
name: 'Get Many',
value: 'getMany',
description: 'Get many secondary zones',
action: 'Get many secondary zones',
},
{
name: 'Update',
value: 'update',
description: 'Update a secondary zone',
action: 'Update a secondary zone',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a secondary zone',
action: 'Delete a secondary zone',
},
{
name: 'Transfer',
value: 'transfer',
description: 'Trigger AXFR transfer',
action: 'Trigger AXFR transfer',
},
],
default: 'create',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['record'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a DNS record',
action: 'Create a DNS record',
},
{
name: 'Get',
value: 'get',
description: 'Get a DNS record',
action: 'Get a DNS record',
},
{
name: 'Get Many',
value: 'getMany',
description: 'Get many DNS records',
action: 'Get many DNS records',
},
{
name: 'Update',
value: 'update',
description: 'Update a DNS record',
action: 'Update a DNS record',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a DNS record',
action: 'Delete a DNS record',
},
],
default: 'create',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['zoneFile'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Export zone file',
action: 'Export zone file',
},
{
name: 'Import',
value: 'import',
description: 'Import zone file',
action: 'Import zone file',
},
],
default: 'get',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['dnssecKey'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create DNSSEC keys',
action: 'Create DNSSEC keys',
},
{
name: 'Get Many',
value: 'getMany',
description: 'Get DNSSEC keys',
action: 'Get DNSSEC keys',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete DNSSEC keys',
action: 'Delete DNSSEC keys',
},
],
default: 'getMany',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['reverseRecord'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a reverse DNS record',
action: 'Create a reverse DNS record',
},
{
name: 'Get',
value: 'get',
description: 'Get a reverse DNS record',
action: 'Get a reverse DNS record',
},
{
name: 'Get Many',
value: 'getMany',
description: 'Get many reverse DNS records',
action: 'Get many reverse DNS records',
},
{
name: 'Update',
value: 'update',
description: 'Update a reverse DNS record',
action: 'Update a reverse DNS record',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a reverse DNS record',
action: 'Delete a reverse DNS record',
},
],
default: 'create',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['quota'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get quota information',
action: 'Get quota information',
},
],
default: 'get',
},
{
displayName: 'Zone ID',
name: 'zoneId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['zone'],
operation: ['get', 'update', 'delete'],
},
},
default: '',
description: 'The unique ID (UUID) of the zone',
},
{
displayName: 'Zone ID',
name: 'zoneId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'get', 'getMany', 'update', 'delete'],
},
},
default: '',
description: 'The unique ID (UUID) of the zone containing the record',
},
{
displayName: 'Zone ID',
name: 'zoneId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['zoneFile'],
operation: ['get', 'import'],
},
},
default: '',
description: 'The unique ID (UUID) of the zone',
},
{
displayName: 'Zone ID',
name: 'zoneId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create', 'getMany', 'delete'],
},
},
default: '',
description: 'The unique ID (UUID) of the zone for DNSSEC operations',
},
{
displayName: 'Zone Name',
name: 'zoneName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['zone'],
operation: ['create'],
},
},
default: '',
placeholder: 'example.com',
description: 'The zone name (domain)',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
displayOptions: {
show: {
resource: ['zone'],
operation: ['create', 'update'],
},
},
default: '',
description: 'Description for the zone',
},
{
displayName: 'Enabled',
name: 'enabled',
type: 'boolean',
displayOptions: {
show: {
resource: ['zone'],
operation: ['create', 'update'],
},
},
default: true,
description: 'Whether the zone is enabled',
},
{
displayName: 'Secondary Zone ID',
name: 'secondaryZoneId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['secondaryZone'],
operation: ['get', 'update', 'delete', 'transfer'],
},
},
default: '',
description: 'The unique ID (UUID) of the secondary zone',
},
{
displayName: 'Zone Name',
name: 'zoneName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['secondaryZone'],
operation: ['create'],
},
},
default: '',
placeholder: 'secondary.example.com',
description: 'The zone name for the secondary zone',
},
{
displayName: 'Primary IPs',
name: 'primaryIps',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['secondaryZone'],
operation: ['create', 'update'],
},
},
default: '',
placeholder: '192.0.2.1,192.0.2.2',
description: 'Comma-separated list of primary server IPs',
},
{
displayName: 'Record ID',
name: 'recordId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['record'],
operation: ['get', 'update', 'delete'],
},
},
default: '',
description: 'The unique ID (UUID) of the record',
},
{
displayName: 'Record Name',
name: 'recordName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'update'],
},
},
default: '',
placeholder: 'www',
description: 'The record name (subdomain, use empty string for root)',
},
{
displayName: 'Record Type',
name: 'recordType',
type: 'options',
required: true,
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'update'],
},
},
options: [
{
name: 'A',
value: 'A',
description: 'IPv4 address',
},
{
name: 'AAAA',
value: 'AAAA',
description: 'IPv6 address',
},
{
name: 'CNAME',
value: 'CNAME',
description: 'Canonical name',
},
{
name: 'MX',
value: 'MX',
description: 'Mail exchange',
},
{
name: 'TXT',
value: 'TXT',
description: 'Text record',
},
{
name: 'SRV',
value: 'SRV',
description: 'Service locator',
},
{
name: 'NS',
value: 'NS',
description: 'Name server',
},
{
name: 'CAA',
value: 'CAA',
description: 'Certification Authority Authorization',
},
{
name: 'SSHFP',
value: 'SSHFP',
description: 'SSH fingerprint',
},
{
name: 'TLSA',
value: 'TLSA',
description: 'TLS authentication',
},
{
name: 'HTTPS',
value: 'HTTPS',
description: 'HTTPS binding',
},
{
name: 'SVCB',
value: 'SVCB',
description: 'Service binding',
},
],
default: 'A',
description: 'The DNS record type',
},
{
displayName: 'Content',
name: 'content',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'update'],
},
},
default: '',
placeholder: '192.0.2.1',
description: 'The record content/value',
},
{
displayName: 'TTL',
name: 'ttl',
type: 'number',
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'update'],
},
},
default: 3600,
description: 'Time to live in seconds',
},
{
displayName: 'Priority',
name: 'priority',
type: 'number',
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'update'],
recordType: ['MX', 'SRV'],
},
},
default: 10,
description: 'Priority value for MX/SRV records',
},
{
displayName: 'Enabled',
name: 'recordEnabled',
type: 'boolean',
displayOptions: {
show: {
resource: ['record'],
operation: ['create', 'update'],
},
},
default: true,
description: 'Whether the record is enabled',
},
{
displayName: 'Zone File Content',
name: 'zoneFileContent',
type: 'string',
typeOptions: {
rows: 15,
},
required: true,
displayOptions: {
show: {
resource: ['zoneFile'],
operation: ['import'],
},
},
default: '',
placeholder: '$ORIGIN example.com.\n$TTL 3600\n@ IN SOA ns1.example.com. admin.example.com. (\n 2024010101 ; serial\n 3600 ; refresh\n 1800 ; retry\n 604800 ; expire\n 86400 ) ; minimum\n',
description: 'The zone file content in BIND format',
},
{
displayName: 'Algorithm',
name: 'dnssecAlgorithm',
type: 'options',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
options: [
{
name: 'RSASHA256',
value: 'RSASHA256',
},
{
name: 'ECDSAP256SHA256',
value: 'ECDSAP256SHA256',
},
{
name: 'ECDSAP384SHA384',
value: 'ECDSAP384SHA384',
},
{
name: 'ED25519',
value: 'ED25519',
},
],
default: 'ECDSAP256SHA256',
description: 'The DNSSEC signing algorithm',
},
{
displayName: 'KSK Bits (Key Signing Key Length)',
name: 'dnssecKskBits',
type: 'options',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
options: [
{
name: '1024 bits',
value: 1024,
},
{
name: '2048 bits',
value: 2048,
},
{
name: '4096 bits',
value: 4096,
},
],
default: 2048,
description: 'Key Signing Key length in bits. Must be >= ZSK Bits.',
},
{
displayName: 'ZSK Bits (Zone Signing Key Length)',
name: 'dnssecZskBits',
type: 'options',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
options: [
{
name: '1024 bits',
value: 1024,
},
{
name: '2048 bits',
value: 2048,
},
{
name: '4096 bits',
value: 4096,
},
],
default: 1024,
description: 'Zone Signing Key length in bits. Must be <= KSK Bits.',
},
{
displayName: 'NSEC Mode',
name: 'dnssecNsecMode',
type: 'options',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
options: [
{
name: 'NSEC',
value: 'NSEC',
},
{
name: 'NSEC3',
value: 'NSEC3',
},
],
default: 'NSEC3',
description: 'NSEC mode for DNSSEC',
},
{
displayName: 'NSEC3 Iterations',
name: 'dnssecNsec3Iterations',
type: 'number',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
typeOptions: {
minValue: 0,
maxValue: 50,
},
default: 10,
description: 'Number of iterations for NSEC3 (between 0 and 50)',
},
{
displayName: 'NSEC3 Salt Bits',
name: 'dnssecNsec3SaltBits',
type: 'options',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
options: [
{
name: '64 bits',
value: 64,
},
{
name: '72 bits',
value: 72,
},
{
name: '80 bits',
value: 80,
},
{
name: '88 bits',
value: 88,
},
{
name: '96 bits',
value: 96,
},
{
name: '104 bits',
value: 104,
},
{
name: '112 bits',
value: 112,
},
{
name: '120 bits',
value: 120,
},
{
name: '128 bits',
value: 128,
},
],
default: 64,
description: 'Salt length in bits for NSEC3 (between 64 and 128, multiples of 8)',
},
{
displayName: 'Signature Validity (Days)',
name: 'dnssecValidity',
type: 'number',
displayOptions: {
show: {
resource: ['dnssecKey'],
operation: ['create'],
},
},
typeOptions: {
minValue: 90,
maxValue: 365,
},
default: 180,
description: 'Signature validity in days (between 90 and 365)',
},
{
displayName: 'Reverse Record ID',
name: 'reverseRecordId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['reverseRecord'],
operation: ['get', 'update', 'delete'],
},
},
default: '',
description: 'The unique ID of the reverse record',
},
{
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['reverseRecord'],
operation: ['create'],
},
},
default: '',
placeholder: '203.0.113.1 or 2001:db8::1',
description: 'The IP address must be from a RESERVED IP in your IONOS account. For IPv4: must be a reserved IP. For IPv6: must belong to a /56 IPv6 block assigned to your VDC with /128 prefix.',
},
{
displayName: 'Name',
name: 'reverseName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['reverseRecord'],
operation: ['create', 'update'],
},
},
default: '',
placeholder: 'host.example.com',
description: 'The hostname for the reverse DNS record',
},
{
displayName: 'Description',
name: 'reverseDescription',
type: 'string',
displayOptions: {
show: {
resource: ['reverseRecord'],
operation: ['create', 'update'],
},
},
default: '',
description: 'Description for the reverse record',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getMany'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getMany'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 1000,
},
default: 100,
description: 'Max number of results to return',
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
displayOptions: {
show: {
resource: ['zone'],
operation: ['getMany'],
},
},
options: [
{
displayName: 'State',
name: 'state',
type: 'options',
options: [
{
name: 'Available',
value: 'AVAILABLE',
},
{
name: 'Provisioning',
value: 'PROVISIONING',
},
{
name: 'Failed',
value: 'FAILED',
},
],
default: 'AVAILABLE',
description: 'Filter by zone state',
},
{
displayName: 'Zone Name',
name: 'zoneName',
type: 'string',
default: '',
description: 'Filter by zone name',
},
],
},
],
};
async execute() {
const items = this.getInputData();
const returnData = [];
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < items.length; i++) {
try {
let responseData = {};
if (resource === 'zone') {
if (operation === 'create') {
const zoneName = this.getNodeParameter('zoneName', i);
const description = this.getNodeParameter('description', i, '');
const enabled = this.getNodeParameter('enabled', i, true);
const body = {
properties: {
zoneName,
enabled,
},
};
if (description) {
body.properties.description = description;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'POST',
url: `${baseUrl}/zones`,
body,
headers: { 'Content-Type': 'application/json' },
});
}
else if (operation === 'get') {
const zoneId = this.getNodeParameter('zoneId', i);
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/zones/${zoneId}`,
});
}
else if (operation === 'getMany') {
const returnAll = this.getNodeParameter('returnAll', i);
const limit = this.getNodeParameter('limit', i, 100);
const filters = this.getNodeParameter('filters', i, {});
const qs = {};
if (!returnAll) {
qs.limit = limit;
}
if (filters.state) {
qs['filter.state'] = filters.state;
}
if (filters.zoneName) {
qs['filter.zoneName'] = filters.zoneName;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/zones`,
qs,
});
responseData = responseData.items;
}
else if (operation === 'update') {
const zoneId = this.getNodeParameter('zoneId', i);
const description = this.getNodeParameter('description', i, '');
const enabled = this.getNodeParameter('enabled', i, true);
const body = {
properties: {
enabled,
},
};
if (description) {
body.properties.description = description;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'PUT',
url: `${baseUrl}/zones/${zoneId}`,
body,
headers: { 'Content-Type': 'application/json' },
});
}
else if (operation === 'delete') {
const zoneId = this.getNodeParameter('zoneId', i);
await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'DELETE',
url: `${baseUrl}/zones/${zoneId}`,
});
responseData = { success: true };
}
}
else if (resource === 'secondaryZone') {
if (operation === 'create') {
const zoneName = this.getNodeParameter('zoneName', i);
const primaryIps = this.getNodeParameter('primaryIps', i);
const body = {
properties: {
zoneName,
primaryIps: primaryIps.split(',').map((ip) => ip.trim()),
},
};
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'POST',
url: `${baseUrl}/secondaryzones`,
body,
headers: { 'Content-Type': 'application/json' },
});
}
else if (operation === 'get') {
const secondaryZoneId = this.getNodeParameter('secondaryZoneId', i);
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/secondaryzones/${secondaryZoneId}`,
});
}
else if (operation === 'getMany') {
const returnAll = this.getNodeParameter('returnAll', i);
const limit = this.getNodeParameter('limit', i, 100);
const qs = {};
if (!returnAll) {
qs.limit = limit;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/secondaryzones`,
qs,
});
responseData = responseData.items;
}
else if (operation === 'update') {
const secondaryZoneId = this.getNodeParameter('secondaryZoneId', i);
const primaryIps = this.getNodeParameter('primaryIps', i);
const body = {
properties: {
primaryIps: primaryIps.split(',').map((ip) => ip.trim()),
},
};
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'PUT',
url: `${baseUrl}/secondaryzones/${secondaryZoneId}`,
body,
headers: { 'Content-Type': 'application/json' },
});
}
else if (operation === 'delete') {
const secondaryZoneId = this.getNodeParameter('secondaryZoneId', i);
await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'DELETE',
url: `${baseUrl}/secondaryzones/${secondaryZoneId}`,
});
responseData = { success: true };
}
else if (operation === 'transfer') {
const secondaryZoneId = this.getNodeParameter('secondaryZoneId', i);
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'PUT',
url: `${baseUrl}/secondaryzones/${secondaryZoneId}/axfr`,
headers: { 'Content-Type': 'application/json' },
});
}
}
else if (resource === 'record') {
const zoneId = this.getNodeParameter('zoneId', i);
if (operation === 'create') {
const recordName = this.getNodeParameter('recordName', i);
const recordType = this.getNodeParameter('recordType', i);
const content = this.getNodeParameter('content', i);
const ttl = this.getNodeParameter('ttl', i, 3600);
const recordEnabled = this.getNodeParameter('recordEnabled', i, true);
const body = {
properties: {
name: recordName,
type: recordType,
content,
ttl,
enabled: recordEnabled,
},
};
if (recordType === 'MX' || recordType === 'SRV') {
const priority = this.getNodeParameter('priority', i, 10);
body.properties.priority = priority;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'POST',
url: `${baseUrl}/zones/${zoneId}/records`,
body,
headers: { 'Content-Type': 'application/json' },
});
}
else if (operation === 'get') {
const recordId = this.getNodeParameter('recordId', i);
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/zones/${zoneId}/records/${recordId}`,
});
}
else if (operation === 'getMany') {
const returnAll = this.getNodeParameter('returnAll', i);
const limit = this.getNodeParameter('limit', i, 100);
const qs = {};
if (!returnAll) {
qs.limit = limit;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/zones/${zoneId}/records`,
qs,
});
responseData = responseData.items;
}
else if (operation === 'update') {
const recordId = this.getNodeParameter('recordId', i);
const recordName = this.getNodeParameter('recordName', i);
const recordType = this.getNodeParameter('recordType', i);
const content = this.getNodeParameter('content', i);
const ttl = this.getNodeParameter('ttl', i, 3600);
const recordEnabled = this.getNodeParameter('recordEnabled', i, true);
const body = {
properties: {
name: recordName,
type: recordType,
content,
ttl,
enabled: recordEnabled,
},
};
if (recordType === 'MX' || recordType === 'SRV') {
const priority = this.getNodeParameter('priority', i, 10);
body.properties.priority = priority;
}
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'PUT',
url: `${baseUrl}/zones/${zoneId}/records/${recordId}`,
body,
headers: { 'Content-Type': 'application/json' },
});
}
else if (operation === 'delete') {
const recordId = this.getNodeParameter('recordId', i);
await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'DELETE',
url: `${baseUrl}/zones/${zoneId}/records/${recordId}`,
});
responseData = { success: true };
}
}
else if (resource === 'zoneFile') {
const zoneId = this.getNodeParameter('zoneId', i);
if (operation === 'get') {
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'GET',
url: `${baseUrl}/zones/${zoneId}/zonefile`,
});
}
else if (operation === 'import') {
const zoneFileContent = this.getNodeParameter('zoneFileContent', i);
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'ionosCloud', {
method: 'PUT',
url: `${baseUrl}/zones/${zoneId}/zonefile`,
body: zoneFileContent,
headers: { 'Content-Type': 'text/plain' },
});
}
}
else if (resource === 'dnssecKey') {
const zoneId = this.getNodeParameter('zoneId', i);
if (operation === 'create') {
const dnssecAlgorithm = this.getNodeParameter('dnssecAlgorithm', i, 'ECDSAP256SHA256');
const dnssecKskBits = this.getNodeParameter('dnssecKskBits', i, 2048);
const dnssecZskBits = this.getNodeParameter('dnssecZskBits', i, 1024);
const dnssecNsecMode = this.getNodeParameter('dnssecNsecMode', i, 'NSEC3');
const dnssecNsec3Iterations = this.getNodeParameter('dnssecNsec3Iterations', i, 10);
const dnssecNsec3SaltBits = this.getNodeParameter('dnssecNsec3SaltBits', i, 64);
const dnssecValidity = this.getNodeParameter('dnssecValidity', i, 180);
const body = {
properties: {
keyParameters: {
algorithm: dnssecAlgorithm,
kskBits: dnssecKskBits,
zskBits: dnssecZskBits,
},
nsecParameters: {
nsecMode: dnssecNsecMode,
nsec3Iterations: dnssecNsec3Iterations,
nsec3SaltBits: dnssecNsec3SaltBits,
},
validity: dnssecValidity,
},