UNPKG

n8n-nodes-ovh

Version:

Comprehensive n8n nodes for OVH API integration - Developed by Ascenzia, experts in AI agent creation

1,708 lines 79.9 kB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OvhDedicatedServer = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const crypto_1 = require("crypto");
class OvhDedicatedServer {
    constructor() {
        this.description = {
            displayName: 'OVH Dedicated Server',
            name: 'ovhDedicatedServer',
            icon: 'file:ovh.svg',
            group: ['transform'],
            version: 1,
            subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
            description: 'Manage OVH dedicated servers',
            defaults: {
                name: 'OVH Dedicated Server',
            },
            inputs: ["main"],
            outputs: ["main"],
            credentials: [
                {
                    name: 'ovhApi',
                    required: true,
                },
            ],
            properties: [
                {
                    displayName: 'Resource',
                    name: 'resource',
                    type: 'options',
                    noDataExpression: true,
                    options: [
                        {
                            name: 'Installation',
                            value: 'installation',
                        },
                        {
                            name: 'Intervention',
                            value: 'intervention',
                        },
                        {
                            name: 'IP',
                            value: 'ip',
                        },
                        {
                            name: 'Network',
                            value: 'network',
                        },
                        {
                            name: 'Option',
                            value: 'options',
                        },
                        {
                            name: 'Security',
                            value: 'security',
                        },
                        {
                            name: 'Server',
                            value: 'server',
                        },
                        {
                            name: 'Task',
                            value: 'task',
                        },
                    ],
                    default: 'server',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['server'],
                        },
                    },
                    options: [
                        {
                            name: 'Get',
                            value: 'get',
                            description: 'Get server information',
                            action: 'Get server information',
                        },
                        {
                            name: 'Get Hardware',
                            value: 'getHardware',
                            description: 'Get server hardware information',
                            action: 'Get server hardware information',
                        },
                        {
                            name: 'Get Many',
                            value: 'getAll',
                            description: 'Get many servers',
                            action: 'Get many servers',
                        },
                        {
                            name: 'Get Network',
                            value: 'getNetwork',
                            description: 'Get server network information',
                            action: 'Get server network information',
                        },
                        {
                            name: 'Get Service Info',
                            value: 'getServiceInfo',
                            description: 'Get server service information',
                            action: 'Get server service information',
                        },
                        {
                            name: 'Reboot',
                            value: 'reboot',
                            description: 'Reboot the server',
                            action: 'Reboot the server',
                        },
                    ],
                    default: 'get',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['task'],
                        },
                    },
                    options: [
                        {
                            name: 'Get',
                            value: 'get',
                            description: 'Get task information',
                            action: 'Get task information',
                        },
                        {
                            name: 'Get Many',
                            value: 'getAll',
                            description: 'Get many tasks',
                            action: 'Get many tasks',
                        },
                        {
                            name: 'Cancel',
                            value: 'cancel',
                            description: 'Cancel a task',
                            action: 'Cancel a task',
                        },
                    ],
                    default: 'get',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['ip'],
                        },
                    },
                    options: [
                        {
                            name: 'Get',
                            value: 'get',
                            description: 'Get IP information',
                            action: 'Get IP information',
                        },
                        {
                            name: 'Get Many',
                            value: 'getAll',
                            description: 'Get many IPs',
                            action: 'Get many i ps',
                        },
                    ],
                    default: 'get',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['installation'],
                        },
                    },
                    options: [
                        {
                            name: 'Get Status',
                            value: 'getStatus',
                            description: 'Get installation status',
                            action: 'Get installation status',
                        },
                        {
                            name: 'Get Templates',
                            value: 'getTemplates',
                            description: 'Get available OS templates',
                            action: 'Get available OS templates',
                        },
                        {
                            name: 'Start',
                            value: 'start',
                            description: 'Start OS installation',
                            action: 'Start OS installation',
                        },
                    ],
                    default: 'getStatus',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['network'],
                        },
                    },
                    options: [
                        {
                            name: 'Add Secondary DNS',
                            value: 'addSecondaryDns',
                            description: 'Add secondary DNS domain',
                            action: 'Add secondary DNS domain',
                        },
                        {
                            name: 'Create Virtual MAC',
                            value: 'createVirtualMac',
                            description: 'Create a virtual MAC address',
                            action: 'Create a virtual MAC address',
                        },
                        {
                            name: 'Delete Secondary DNS',
                            value: 'deleteSecondaryDns',
                            description: 'Delete secondary DNS domain',
                            action: 'Delete secondary DNS domain',
                        },
                        {
                            name: 'Delete Virtual MAC',
                            value: 'deleteVirtualMac',
                            description: 'Delete a virtual MAC address',
                            action: 'Delete a virtual MAC address',
                        },
                        {
                            name: 'Get Secondary DNS',
                            value: 'getSecondaryDns',
                            description: 'Get secondary DNS domains',
                            action: 'Get secondary DNS domains',
                        },
                        {
                            name: 'Get Virtual MACs',
                            value: 'getVirtualMacs',
                            description: 'Get virtual MAC addresses',
                            action: 'Get virtual MAC addresses',
                        },
                        {
                            name: 'IP Block Merge',
                            value: 'ipBlockMerge',
                            description: 'Merge IP blocks',
                            action: 'Merge IP blocks',
                        },
                    ],
                    default: 'getVirtualMacs',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['security'],
                        },
                    },
                    options: [
                        {
                            name: 'Get Firewall',
                            value: 'getFirewall',
                            description: 'Get firewall information',
                            action: 'Get firewall information',
                        },
                        {
                            name: 'Update Firewall',
                            value: 'updateFirewall',
                            description: 'Update firewall configuration',
                            action: 'Update firewall configuration',
                        },
                        {
                            name: 'Get IP Spoof',
                            value: 'getIpSpoof',
                            description: 'Get IP spoof protection status',
                            action: 'Get IP spoof protection status',
                        },
                    ],
                    default: 'getFirewall',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['options'],
                        },
                    },
                    options: [
                        {
                            name: 'Get Available Options',
                            value: 'getAvailable',
                            description: 'Get available server options',
                            action: 'Get available server options',
                        },
                    ],
                    default: 'getAvailable',
                },
                {
                    displayName: 'Operation',
                    name: 'operation',
                    type: 'options',
                    noDataExpression: true,
                    displayOptions: {
                        show: {
                            resource: ['intervention'],
                        },
                    },
                    options: [
                        {
                            name: 'Get',
                            value: 'get',
                            description: 'Get intervention information',
                            action: 'Get intervention information',
                        },
                        {
                            name: 'Get Many',
                            value: 'getAll',
                            description: 'Get many interventions',
                            action: 'Get many interventions',
                        },
                    ],
                    default: 'get',
                },
                {
                    displayName: 'Server Name or ID',
                    name: 'serverName',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServers',
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['server'],
                            operation: ['get', 'getHardware', 'getNetwork', 'getServiceInfo', 'reboot'],
                        },
                    },
                    description: 'The server name to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Reboot Options',
                    name: 'rebootOptions',
                    type: 'collection',
                    placeholder: 'Add Option',
                    default: {},
                    displayOptions: {
                        show: {
                            resource: ['server'],
                            operation: ['reboot'],
                        },
                    },
                    options: [
                        {
                            displayName: 'Reboot Type',
                            name: 'type',
                            type: 'options',
                            options: [
                                {
                                    name: 'Hard',
                                    value: 'hard',
                                    description: 'Forced reboot (immediate power cycle)',
                                },
                                {
                                    name: 'Hard IPMI',
                                    value: 'hard_ipmi',
                                    description: 'Hard reboot via IPMI',
                                },
                                {
                                    name: 'IPMI Cycle',
                                    value: 'ipmi_cycle',
                                    description: 'Power cycle via IPMI',
                                },
                                {
                                    name: 'IPMI Reset',
                                    value: 'ipmi_reset',
                                    description: 'Reset via IPMI',
                                },
                                {
                                    name: 'Soft',
                                    value: 'soft',
                                    description: 'Graceful reboot (recommended)',
                                },
                            ],
                            default: 'soft',
                            description: 'Type of reboot to perform',
                        },
                        {
                            displayName: 'Reason',
                            name: 'reason',
                            type: 'string',
                            default: '',
                            placeholder: 'Scheduled maintenance',
                            description: 'Reason for the reboot (for logging purposes)',
                        },
                    ],
                },
                {
                    displayName: 'Server Name or ID',
                    name: 'serverName',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServers',
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['task'],
                            operation: ['getAll', 'get', 'cancel'],
                        },
                    },
                    description: 'The server name to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Server Name or ID',
                    name: 'serverName',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServers',
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['ip'],
                            operation: ['getAll'],
                        },
                    },
                    description: 'The server name to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Task Name or ID',
                    name: 'taskId',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServerTasks',
                        loadOptionsDependsOn: ['serverName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['task'],
                            operation: ['get', 'cancel'],
                        },
                    },
                    description: 'The ID of the task. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'IP Address',
                    name: 'ipAddress',
                    type: 'string',
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['ip'],
                            operation: ['get'],
                        },
                    },
                    placeholder: '1.2.3.4',
                    description: 'The IP address to get information for',
                },
                {
                    displayName: 'Status',
                    name: 'status',
                    type: 'options',
                    displayOptions: {
                        show: {
                            resource: ['task'],
                            operation: ['getAll'],
                        },
                    },
                    options: [
                        {
                            name: 'All',
                            value: 'all',
                        },
                        {
                            name: 'Cancelled',
                            value: 'cancelled',
                        },
                        {
                            name: 'Customer Error',
                            value: 'customerError',
                        },
                        {
                            name: 'Doing',
                            value: 'doing',
                        },
                        {
                            name: 'Done',
                            value: 'done',
                        },
                        {
                            name: 'Init',
                            value: 'init',
                        },
                        {
                            name: 'OVH Error',
                            value: 'ovhError',
                        },
                        {
                            name: 'Todo',
                            value: 'todo',
                        },
                    ],
                    default: 'all',
                    description: 'Filter tasks by status',
                },
                {
                    displayName: 'Server Name or ID',
                    name: 'serverName',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServers',
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['installation', 'network', 'security', 'options', 'intervention'],
                        },
                    },
                    description: 'The server name to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Template Name or ID',
                    name: 'templateName',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getCompatibleTemplates',
                        loadOptionsDependsOn: ['serverName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['installation'],
                            operation: ['start'],
                        },
                    },
                    description: 'The OS template to install. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Partition Scheme Name or ID',
                    name: 'partitionSchemeName',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getPartitionSchemes',
                        loadOptionsDependsOn: ['serverName', 'templateName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['installation'],
                            operation: ['start'],
                        },
                    },
                    description: 'The partition scheme to use. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Installation Options',
                    name: 'installationOptions',
                    type: 'collection',
                    placeholder: 'Add Option',
                    default: {},
                    displayOptions: {
                        show: {
                            resource: ['installation'],
                            operation: ['start'],
                        },
                    },
                    options: [
                        {
                            displayName: 'Custom Hostname',
                            name: 'customHostname',
                            type: 'string',
                            default: '',
                            description: 'Set a custom hostname',
                        },
                        {
                            displayName: 'Hostname',
                            name: 'hostname',
                            type: 'string',
                            default: '',
                            placeholder: 'server.example.com',
                            description: 'Custom hostname for the server',
                        },
                        {
                            displayName: 'Language',
                            name: 'language',
                            type: 'options',
                            options: [
                                { name: 'Czech', value: 'cs' },
                                { name: 'Dutch', value: 'nl' },
                                { name: 'English', value: 'en' },
                                { name: 'Finnish', value: 'fi' },
                                { name: 'French', value: 'fr' },
                                { name: 'German', value: 'de' },
                                { name: 'Italian', value: 'it' },
                                { name: 'Lithuanian', value: 'lt' },
                                { name: 'Polish', value: 'pl' },
                                { name: 'Portuguese', value: 'pt' },
                                { name: 'Spanish', value: 'es' },
                            ],
                            default: 'en',
                            description: 'Installation language',
                        },
                        {
                            displayName: 'No RAID',
                            name: 'noRaid',
                            type: 'boolean',
                            default: false,
                            description: 'Whether to disable RAID',
                        },
                        {
                            displayName: 'Post Install Script',
                            name: 'postInstallationScriptLink',
                            type: 'string',
                            default: '',
                            placeholder: 'https://example.com/script.sh',
                            description: 'URL of script to run after installation',
                        },
                        {
                            displayName: 'Reset Hardware RAID',
                            name: 'resetHwRaid',
                            type: 'boolean',
                            default: false,
                            description: 'Whether to reset hardware RAID configuration',
                        },
                        {
                            displayName: 'SSH Key',
                            name: 'sshKeyName',
                            type: 'string',
                            default: '',
                            placeholder: 'my-ssh-key',
                            description: 'SSH key name for authentication',
                        },
                        {
                            displayName: 'Use Distribution Kernel',
                            name: 'useDistribKernel',
                            type: 'boolean',
                            default: true,
                            description: 'Whether to use the distribution kernel',
                        },
                    ],
                },
                {
                    displayName: 'Virtual MAC Name or ID',
                    name: 'virtualMac',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getVirtualMACs',
                        loadOptionsDependsOn: ['serverName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['network'],
                            operation: ['deleteVirtualMac'],
                        },
                    },
                    description: 'The virtual MAC address to delete. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'IP Address Name or ID',
                    name: 'ipAddress',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServerIPs',
                        loadOptionsDependsOn: ['serverName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['network'],
                            operation: ['createVirtualMac'],
                        },
                    },
                    description: 'The IP address to assign to the virtual MAC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'Virtual MAC Type',
                    name: 'virtualMacType',
                    type: 'options',
                    displayOptions: {
                        show: {
                            resource: ['network'],
                            operation: ['createVirtualMac'],
                        },
                    },
                    options: [
                        {
                            name: 'OVH',
                            value: 'ovh',
                        },
                        {
                            name: 'VMware',
                            value: 'vmware',
                        },
                    ],
                    default: 'ovh',
                    description: 'Type of virtual MAC to create',
                },
                {
                    displayName: 'Domain',
                    name: 'domain',
                    type: 'string',
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['network'],
                            operation: ['addSecondaryDns'],
                        },
                    },
                    placeholder: 'example.com',
                    description: 'The domain name to add',
                },
                {
                    displayName: 'Secondary DNS Domain Name or ID',
                    name: 'secondaryDnsDomain',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getSecondaryDNSDomains',
                        loadOptionsDependsOn: ['serverName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['network'],
                            operation: ['deleteSecondaryDns'],
                        },
                    },
                    description: 'The secondary DNS domain to delete. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
                {
                    displayName: 'IP Block',
                    name: 'ipBlock',
                    type: 'string',
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['network'],
                            operation: ['ipBlockMerge'],
                        },
                    },
                    placeholder: '1.2.3.0/24',
                    description: 'The IP block to merge',
                },
                {
                    displayName: 'Firewall Enabled',
                    name: 'firewallEnabled',
                    type: 'boolean',
                    default: false,
                    displayOptions: {
                        show: {
                            resource: ['security'],
                            operation: ['updateFirewall'],
                        },
                    },
                    description: 'Whether to enable the firewall',
                },
                {
                    displayName: 'Firewall Mode',
                    name: 'firewallMode',
                    type: 'options',
                    displayOptions: {
                        show: {
                            resource: ['security'],
                            operation: ['updateFirewall'],
                        },
                    },
                    options: [
                        {
                            name: 'Routed',
                            value: 'routed',
                        },
                        {
                            name: 'Transparent',
                            value: 'transparent',
                        },
                    ],
                    default: 'routed',
                },
                {
                    displayName: 'Intervention Name or ID',
                    name: 'interventionId',
                    type: 'options',
                    typeOptions: {
                        loadOptionsMethod: 'getServerInterventions',
                        loadOptionsDependsOn: ['serverName'],
                    },
                    default: '',
                    displayOptions: {
                        show: {
                            resource: ['intervention'],
                            operation: ['get'],
                        },
                    },
                    description: 'The ID of the intervention. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
                },
            ],
        };
        this.methods = {
            loadOptions: {
                async getServers() {
                    const returnData = [];
                    const credentials = await this.getCredentials('ovhApi');
                    const endpoint = credentials.endpoint;
                    const applicationKey = credentials.applicationKey;
                    const applicationSecret = credentials.applicationSecret;
                    const consumerKey = credentials.consumerKey;
                    const timestamp = Math.round(Date.now() / 1000);
                    const fullUrl = `${endpoint}/dedicated/server`;
                    const method = 'GET';
                    const signatureElements = [
                        applicationSecret,
                        consumerKey,
                        method,
                        fullUrl,
                        '',
                        timestamp,
                    ];
                    const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                    const headers = {
                        'X-Ovh-Application': applicationKey,
                        'X-Ovh-Consumer': consumerKey,
                        'X-Ovh-Signature': signature,
                        'X-Ovh-Timestamp': timestamp.toString(),
                    };
                    const options = {
                        method,
                        url: fullUrl,
                        headers,
                        json: true,
                    };
                    try {
                        const servers = await this.helpers.request(options);
                        if (Array.isArray(servers)) {
                            for (const server of servers) {
                                returnData.push({
                                    name: server,
                                    value: server,
                                });
                            }
                        }
                    }
                    catch (error) {
                        console.error('Error loading servers:', error);
                    }
                    return returnData.sort((a, b) => a.name.localeCompare(b.name));
                },
                async getCompatibleTemplates() {
                    const returnData = [];
                    try {
                        let serverName;
                        try {
                            serverName = this.getNodeParameter('serverName');
                        }
                        catch (error) {
                            return [{
                                    name: 'Please Select a Server First',
                                    value: '',
                                }];
                        }
                        if (!serverName || serverName.trim() === '') {
                            return [{
                                    name: 'Please Select a Server First',
                                    value: '',
                                }];
                        }
                        const credentials = await this.getCredentials('ovhApi');
                        const endpoint = credentials.endpoint;
                        const applicationKey = credentials.applicationKey;
                        const applicationSecret = credentials.applicationSecret;
                        const consumerKey = credentials.consumerKey;
                        const timestamp = Math.round(Date.now() / 1000);
                        const serverNameTrimmed = serverName.trim();
                        const fullUrl = `${endpoint}/dedicated/server/${serverNameTrimmed}/install/compatibleTemplates`;
                        const method = 'GET';
                        const signatureElements = [
                            applicationSecret,
                            consumerKey,
                            method,
                            fullUrl,
                            '',
                            timestamp,
                        ];
                        const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                        const headers = {
                            'X-Ovh-Application': applicationKey,
                            'X-Ovh-Consumer': consumerKey,
                            'X-Ovh-Signature': signature,
                            'X-Ovh-Timestamp': timestamp.toString(),
                        };
                        const options = {
                            method,
                            url: fullUrl,
                            headers,
                            json: true,
                        };
                        const response = await this.helpers.request(options);
                        if (Array.isArray(response)) {
                            for (const template of response) {
                                returnData.push({
                                    name: template,
                                    value: template,
                                });
                            }
                        }
                        else if (typeof response === 'object') {
                            for (const category in response) {
                                const templates = response[category];
                                if (Array.isArray(templates)) {
                                    for (const template of templates) {
                                        returnData.push({
                                            name: `${template} (${category})`,
                                            value: template,
                                        });
                                    }
                                }
                            }
                        }
                    }
                    catch (error) {
                        return [{
                                name: `Error: ${error.message || 'Failed to load templates'}`,
                                value: '',
                            }];
                    }
                    return returnData.sort((a, b) => a.name.localeCompare(b.name));
                },
                async getPartitionSchemes() {
                    const returnData = [];
                    try {
                        const serverName = this.getNodeParameter('serverName');
                        const templateName = this.getNodeParameter('templateName');
                        if (!serverName || !templateName) {
                            return [{
                                    name: 'Please Select a Server and Template First',
                                    value: '',
                                }];
                        }
                        const credentials = await this.getCredentials('ovhApi');
                        const endpoint = credentials.endpoint;
                        const applicationKey = credentials.applicationKey;
                        const applicationSecret = credentials.applicationSecret;
                        const consumerKey = credentials.consumerKey;
                        const timestamp = Math.round(Date.now() / 1000);
                        const serverNameTrimmed = serverName.trim();
                        const templateNameTrimmed = templateName.trim();
                        const path = `/dedicated/server/${serverNameTrimmed}/install/compatibleTemplatePartitionSchemes`;
                        const queryParams = `templateName=${encodeURIComponent(templateNameTrimmed)}`;
                        const fullUrl = `${endpoint}${path}?${queryParams}`;
                        const method = 'GET';
                        const signatureElements = [
                            applicationSecret,
                            consumerKey,
                            method,
                            fullUrl,
                            '',
                            timestamp,
                        ];
                        const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                        const headers = {
                            'X-Ovh-Application': applicationKey,
                            'X-Ovh-Consumer': consumerKey,
                            'X-Ovh-Signature': signature,
                            'X-Ovh-Timestamp': timestamp.toString(),
                        };
                        const options = {
                            method,
                            url: fullUrl,
                            headers,
                            json: true,
                        };
                        const schemes = await this.helpers.request(options);
                        if (Array.isArray(schemes)) {
                            returnData.push({
                                name: 'Default',
                                value: 'default',
                            });
                            for (const scheme of schemes) {
                                returnData.push({
                                    name: scheme,
                                    value: scheme,
                                });
                            }
                        }
                        else {
                            returnData.push({
                                name: 'Default',
                                value: 'default',
                            });
                        }
                    }
                    catch (error) {
                        return [{
                                name: 'Default',
                                value: 'default',
                            }];
                    }
                    return returnData.sort((a, b) => a.name.localeCompare(b.name));
                },
                async getServerTasks() {
                    const returnData = [];
                    const serverName = this.getNodeParameter('serverName');
                    if (!serverName) {
                        return returnData;
                    }
                    const credentials = await this.getCredentials('ovhApi');
                    const endpoint = credentials.endpoint;
                    const applicationKey = credentials.applicationKey;
                    const applicationSecret = credentials.applicationSecret;
                    const consumerKey = credentials.consumerKey;
                    const timestamp = Math.round(Date.now() / 1000);
                    const fullUrl = `${endpoint}/dedicated/server/${serverName}/task`;
                    const method = 'GET';
                    const signatureElements = [
                        applicationSecret,
                        consumerKey,
                        method,
                        fullUrl,
                        '',
                        timestamp,
                    ];
                    const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                    const headers = {
                        'X-Ovh-Application': applicationKey,
                        'X-Ovh-Consumer': consumerKey,
                        'X-Ovh-Signature': signature,
                        'X-Ovh-Timestamp': timestamp.toString(),
                    };
                    const options = {
                        method,
                        url: fullUrl,
                        headers,
                        json: true,
                    };
                    try {
                        const tasks = await this.helpers.request(options);
                        if (Array.isArray(tasks)) {
                            for (const task of tasks) {
                                returnData.push({
                                    name: `Task ${task}`,
                                    value: task,
                                });
                            }
                        }
                    }
                    catch (error) {
                        console.error('Error loading tasks:', error);
                    }
                    return returnData.sort((a, b) => Number(a.value) - Number(b.value));
                },
                async getServerInterventions() {
                    const returnData = [];
                    const serverName = this.getNodeParameter('serverName');
                    if (!serverName) {
                        return returnData;
                    }
                    const credentials = await this.getCredentials('ovhApi');
                    const endpoint = credentials.endpoint;
                    const applicationKey = credentials.applicationKey;
                    const applicationSecret = credentials.applicationSecret;
                    const consumerKey = credentials.consumerKey;
                    const timestamp = Math.round(Date.now() / 1000);
                    const fullUrl = `${endpoint}/dedicated/server/${serverName}/intervention`;
                    const method = 'GET';
                    const signatureElements = [
                        applicationSecret,
                        consumerKey,
                        method,
                        fullUrl,
                        '',
                        timestamp,
                    ];
                    const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                    const headers = {
                        'X-Ovh-Application': applicationKey,
                        'X-Ovh-Consumer': consumerKey,
                        'X-Ovh-Signature': signature,
                        'X-Ovh-Timestamp': timestamp.toString(),
                    };
                    const options = {
                        method,
                        url: fullUrl,
                        headers,
                        json: true,
                    };
                    try {
                        const interventions = await this.helpers.request(options);
                        if (Array.isArray(interventions)) {
                            for (const intervention of interventions) {
                                returnData.push({
                                    name: `Intervention ${intervention}`,
                                    value: intervention,
                                });
                            }
                        }
                    }
                    catch (error) {
                        console.error('Error loading interventions:', error);
                    }
                    return returnData.sort((a, b) => Number(a.value) - Number(b.value));
                },
                async getServerIPs() {
                    const returnData = [];
                    const serverName = this.getNodeParameter('serverName');
                    if (!serverName) {
                        return returnData;
                    }
                    const credentials = await this.getCredentials('ovhApi');
                    const endpoint = credentials.endpoint;
                    const applicationKey = credentials.applicationKey;
                    const applicationSecret = credentials.applicationSecret;
                    const consumerKey = credentials.consumerKey;
                    const timestamp = Math.round(Date.now() / 1000);
                    const fullUrl = `${endpoint}/dedicated/server/${serverName}/ips`;
                    const method = 'GET';
                    const signatureElements = [
                        applicationSecret,
                        consumerKey,
                        method,
                        fullUrl,
                        '',
                        timestamp,
                    ];
                    const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                    const headers = {
                        'X-Ovh-Application': applicationKey,
                        'X-Ovh-Consumer': consumerKey,
                        'X-Ovh-Signature': signature,
                        'X-Ovh-Timestamp': timestamp.toString(),
                    };
                    const options = {
                        method,
                        url: fullUrl,
                        headers,
                        json: true,
                    };
                    try {
                        const ips = await this.helpers.request(options);
                        if (Array.isArray(ips)) {
                            for (const ip of ips) {
                                returnData.push({
                                    name: ip,
                                    value: ip,
                                });
                            }
                        }
                    }
                    catch (error) {
                        console.error('Error loading IPs:', error);
                    }
                    return returnData.sort((a, b) => a.name.localeCompare(b.name));
                },
                async getVirtualMACs() {
                    const returnData = [];
                    const serverName = this.getNodeParameter('serverName');
                    if (!serverName) {
                        return returnData;
                    }
                    const credentials = await this.getCredentials('ovhApi');
                    const endpoint = credentials.endpoint;
                    const applicationKey = credentials.applicationKey;
                    const applicationSecret = credentials.applicationSecret;
                    const consumerKey = credentials.consumerKey;
                    const timestamp = Math.round(Date.now() / 1000);
                    const fullUrl = `${endpoint}/dedicated/server/${serverName}/virtualMac`;
                    const method = 'GET';
                    const signatureElements = [
                        applicationSecret,
                        consumerKey,
                        method,
                        fullUrl,
                        '',
                        timestamp,
                    ];
                    const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                    const headers = {
                        'X-Ovh-Application': applicationKey,
                        'X-Ovh-Consumer': consumerKey,
                        'X-Ovh-Signature': signature,
                        'X-Ovh-Timestamp': timestamp.toString(),
                    };
                    const options = {
                        method,
                        url: fullUrl,
                        headers,
                        json: true,
                    };
                    try {
                        const macs = await this.helpers.request(options);
                        if (Array.isArray(macs)) {
                            for (const mac of macs) {
                                returnData.push({
                                    name: mac,
                                    value: mac,
                                });
                            }
                        }
                    }
                    catch (error) {
                        console.error('Error loading virtual MACs:', error);
                    }
                    return returnData.sort((a, b) => a.name.localeCompare(b.name));
                },
                async getSecondaryDNSDomains() {
                    const returnData = [];
                    const serverName = this.getNodeParameter('serverName');
                    if (!serverName) {
                        return returnData;
                    }
                    const credentials = await this.getCredentials('ovhApi');
                    const endpoint = credentials.endpoint;
                    const applicationKey = credentials.applicationKey;
                    const applicationSecret = credentials.applicationSecret;
                    const consumerKey = credentials.consumerKey;
                    const timestamp = Math.round(Date.now() / 1000);
                    const fullUrl = `${endpoint}/dedicated/server/${serverName}/secondaryDnsDomains`;
                    const method = 'GET';
                    const signatureElements = [
                        applicationSecret,
                        consumerKey,
                        method,
                        fullUrl,
                        '',
                        timestamp,
                    ];
                    const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                    const headers = {
                        'X-Ovh-Application': applicationKey,
                        'X-Ovh-Consumer': consumerKey,
                        'X-Ovh-Signature': signature,
                        'X-Ovh-Timestamp': timestamp.toString(),
                    };
                    const options = {
                        method,
                        url: fullUrl,
                        headers,
                        json: true,
                    };
                    try {
                        const domains = await this.helpers.request(options);
                        if (Array.isArray(domains)) {
                            for (const domain of domains) {
                                returnData.push({
                                    name: domain,
                                    value: domain,
                                });
                            }
                        }
                    }
                    catch (error) {
                        console.error('Error loading secondary DNS domains:', error);
                    }
                    return returnData.sort((a, b) => a.name.localeCompare(b.name));
                },
            },
        };
    }
    async execute() {
        const items = this.getInputData();
        const returnData = [];
        const resource = this.getNodeParameter('resource', 0);
        const operation = this.getNodeParameter('operation', 0);
        const credentials = await this.getCredentials('ovhApi');
        const endpoint = credentials.endpoint;
        const applicationKey = credentials.applicationKey;
        const applicationSecret = credentials.applicationSecret;
        const consumerKey = credentials.consumerKey;
        for (let i = 0; i < items.length; i++) {
            try {
                let responseData;
                let method = 'GET';
                let path = '';
                let body = {};
                if (resource === 'server') {
                    if (operation === 'get') {
                        const serverName = this.getNodeParameter('serverName', i);
                        if (!serverName || serverName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverName.trim()}`;
                    }
                    else if (operation === 'getAll') {
                        path = '/dedicated/server';
                    }
                    else if (operation === 'getHardware') {
                        const serverName = this.getNodeParameter('serverName', i);
                        if (!serverName || serverName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverName.trim()}/specifications/hardware`;
                    }
                    else if (operation === 'getNetwork') {
                        const serverName = this.getNodeParameter('serverName', i);
                        if (!serverName || serverName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverName.trim()}/specifications/network`;
                    }
                    else if (operation === 'getServiceInfo') {
                        const serverName = this.getNodeParameter('serverName', i);
                        if (!serverName || serverName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverName.trim()}/serviceInfos`;
                    }
                    else if (operation === 'reboot') {
                        method = 'POST';
                        const serverName = this.getNodeParameter('serverName', i);
                        if (!serverName || serverName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                                itemIndex: i,
                            });
                        }
                        const rebootOptions = this.getNodeParameter('rebootOptions', i);
                        path = `/dedicated/server/${serverName.trim()}/reboot`;
                        body = {};
                        if (rebootOptions.type) {
                            body.type = rebootOptions.type;
                        }
                        if (rebootOptions.reason) {
                            body.reason = rebootOptions.reason;
                        }
                    }
                }
                else if (resource === 'task') {
                    const serverName = this.getNodeParameter('serverName', i);
                    if (!serverName || serverName.trim() === '') {
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                            itemIndex: i,
                        });
                    }
                    const serverNameTrimmed = serverName.trim();
                    if (operation === 'get') {
                        const taskId = this.getNodeParameter('taskId', i);
                        if (!taskId && taskId !== 0) {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Task ID is required', { itemIndex: i });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/task/${taskId}`;
                    }
                    else if (operation === 'getAll') {
                        path = `/dedicated/server/${serverNameTrimmed}/task`;
                        try {
                            const status = this.getNodeParameter('status', i, 'all');
                            if (status !== 'all') {
                                path += `?status=${status}`;
                            }
                        }
                        catch (error) {
                        }
                    }
                    else if (operation === 'cancel') {
                        method = 'POST';
                        const taskId = this.getNodeParameter('taskId', i);
                        if (!taskId && taskId !== 0) {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Task ID is required', { itemIndex: i });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/task/${taskId}/cancel`;
                    }
                }
                else if (resource === 'ip') {
                    if (operation === 'getAll') {
                        const serverName = this.getNodeParameter('serverName', i);
                        if (!serverName || serverName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverName.trim()}/ips`;
                    }
                    else if (operation === 'get') {
                        const ipAddress = this.getNodeParameter('ipAddress', i);
                        if (!ipAddress || ipAddress.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'IP address is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/ip/${encodeURIComponent(ipAddress.trim())}`;
                    }
                }
                else if (resource === 'installation') {
                    const serverName = this.getNodeParameter('serverName', i);
                    if (!serverName || serverName.trim() === '') {
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                            itemIndex: i,
                        });
                    }
                    const serverNameTrimmed = serverName.trim();
                    if (operation === 'getStatus') {
                        path = `/dedicated/server/${serverNameTrimmed}/install/status`;
                    }
                    else if (operation === 'getTemplates') {
                        path = `/dedicated/server/${serverNameTrimmed}/install/compatibleTemplates`;
                    }
                    else if (operation === 'start') {
                        method = 'POST';
                        const templateName = this.getNodeParameter('templateName', i);
                        if (!templateName || templateName.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Template name is required', {
                                itemIndex: i,
                            });
                        }
                        const partitionSchemeName = this.getNodeParameter('partitionSchemeName', i);
                        const installationOptions = this.getNodeParameter('installationOptions', i);
                        path = `/dedicated/server/${serverNameTrimmed}/install/start`;
                        body = {
                            templateName: templateName.trim(),
                            partitionSchemeName: partitionSchemeName || 'default',
                        };
                        if (installationOptions.sshKeyName) {
                            body.sshKeyName = installationOptions.sshKeyName;
                        }
                        if (installationOptions.hostname) {
                            body.hostname = installationOptions.hostname;
                        }
                        if (installationOptions.postInstallationScriptLink) {
                            body.postInstallationScriptLink = installationOptions.postInstallationScriptLink;
                        }
                        if (installationOptions.language) {
                            body.language = installationOptions.language;
                        }
                        if (installationOptions.useDistribKernel !== undefined) {
                            body.useDistribKernel = installationOptions.useDistribKernel;
                        }
                        if (installationOptions.noRaid !== undefined) {
                            body.noRaid = installationOptions.noRaid;
                        }
                        if (installationOptions.customHostname) {
                            body.customHostname = installationOptions.customHostname;
                        }
                        if (installationOptions.resetHwRaid !== undefined) {
                            body.resetHwRaid = installationOptions.resetHwRaid;
                        }
                    }
                }
                else if (resource === 'network') {
                    const serverName = this.getNodeParameter('serverName', i);
                    if (!serverName || serverName.trim() === '') {
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                            itemIndex: i,
                        });
                    }
                    const serverNameTrimmed = serverName.trim();
                    if (operation === 'getVirtualMacs') {
                        path = `/dedicated/server/${serverNameTrimmed}/virtualMac`;
                    }
                    else if (operation === 'createVirtualMac') {
                        method = 'POST';
                        const ipAddress = this.getNodeParameter('ipAddress', i);
                        const virtualMacType = this.getNodeParameter('virtualMacType', i);
                        if (!ipAddress || ipAddress.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'IP address is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/virtualMac`;
                        body = {
                            ipAddress: ipAddress.trim(),
                            type: virtualMacType,
                        };
                    }
                    else if (operation === 'deleteVirtualMac') {
                        method = 'DELETE';
                        const virtualMac = this.getNodeParameter('virtualMac', i);
                        if (!virtualMac || virtualMac.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Virtual MAC address is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/virtualMac/${encodeURIComponent(virtualMac.trim())}`;
                    }
                    else if (operation === 'getSecondaryDns') {
                        path = `/dedicated/server/${serverNameTrimmed}/secondaryDnsDomains`;
                    }
                    else if (operation === 'addSecondaryDns') {
                        method = 'POST';
                        const domain = this.getNodeParameter('domain', i);
                        if (!domain || domain.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Domain is required', { itemIndex: i });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/secondaryDnsDomains`;
                        body = { domain: domain.trim() };
                    }
                    else if (operation === 'deleteSecondaryDns') {
                        method = 'DELETE';
                        const secondaryDnsDomain = this.getNodeParameter('secondaryDnsDomain', i);
                        if (!secondaryDnsDomain || secondaryDnsDomain.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Secondary DNS domain is required', { itemIndex: i });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/secondaryDnsDomains/${encodeURIComponent(secondaryDnsDomain.trim())}`;
                    }
                    else if (operation === 'ipBlockMerge') {
                        const ipBlock = this.getNodeParameter('ipBlock', i);
                        if (!ipBlock || ipBlock.trim() === '') {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'IP block is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/ipBlockMerge?block=${encodeURIComponent(ipBlock.trim())}`;
                    }
                }
                else if (resource === 'security') {
                    const serverName = this.getNodeParameter('serverName', i);
                    if (!serverName || serverName.trim() === '') {
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                            itemIndex: i,
                        });
                    }
                    const serverNameTrimmed = serverName.trim();
                    if (operation === 'getFirewall') {
                        path = `/dedicated/server/${serverNameTrimmed}/firewall`;
                    }
                    else if (operation === 'updateFirewall') {
                        method = 'PUT';
                        const firewallEnabled = this.getNodeParameter('firewallEnabled', i);
                        const firewallMode = this.getNodeParameter('firewallMode', i);
                        path = `/dedicated/server/${serverNameTrimmed}/firewall`;
                        body = {
                            enabled: firewallEnabled,
                            mode: firewallMode,
                        };
                    }
                    else if (operation === 'getIpSpoof') {
                        path = `/dedicated/server/${serverNameTrimmed}/ips`;
                    }
                }
                else if (resource === 'options') {
                    const serverName = this.getNodeParameter('serverName', i);
                    if (!serverName || serverName.trim() === '') {
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                            itemIndex: i,
                        });
                    }
                    const serverNameTrimmed = serverName.trim();
                    if (operation === 'getAvailable') {
                        path = `/dedicated/server/${serverNameTrimmed}/option`;
                    }
                }
                else if (resource === 'intervention') {
                    const serverName = this.getNodeParameter('serverName', i);
                    if (!serverName || serverName.trim() === '') {
                        throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Server name is required', {
                            itemIndex: i,
                        });
                    }
                    const serverNameTrimmed = serverName.trim();
                    if (operation === 'get') {
                        const interventionId = this.getNodeParameter('interventionId', i);
                        if (!interventionId && interventionId !== 0) {
                            throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Intervention ID is required', {
                                itemIndex: i,
                            });
                        }
                        path = `/dedicated/server/${serverNameTrimmed}/intervention/${interventionId}`;
                    }
                    else if (operation === 'getAll') {
                        path = `/dedicated/server/${serverNameTrimmed}/intervention`;
                    }
                }
                const timestamp = Math.round(Date.now() / 1000);
                const fullUrl = `${endpoint}${path}`;
                let bodyForSignature = '';
                if (method === 'POST' || method === 'PUT') {
                    if (Object.keys(body).length > 0) {
                        bodyForSignature = JSON.stringify(body).replace(/[\u0080-\uFFFF]/g, (m) => {
                            return '\\u' + ('0000' + m.charCodeAt(0).toString(16)).slice(-4);
                        });
                    }
                }
                const signatureElements = [
                    applicationSecret,
                    consumerKey,
                    method,
                    fullUrl,
                    bodyForSignature,
                    timestamp,
                ];
                const signature = '$1$' + (0, crypto_1.createHash)('sha1').update(signatureElements.join('+')).digest('hex');
                const headers = {
                    'X-Ovh-Application': applicationKey,
                    'X-Ovh-Consumer': consumerKey,
                    'X-Ovh-Signature': signature,
                    'X-Ovh-Timestamp': timestamp.toString(),
                };
                const options = {
                    method,
                    url: fullUrl,
                    headers,
                    json: true,
                };
                if (method === 'POST' || method === 'PUT') {
                    if (Object.keys(body).length > 0) {
                        options.body = body;
                        headers['Content-Type'] = 'application/json';
                    }
                }
                responseData = await this.helpers.request(options);
                if (method === 'GET' && typeof responseData === 'string') {
                    try {
                        responseData = JSON.parse(responseData);
                    }
                    catch (error) {
                    }
                }
                if (Array.isArray(responseData)) {
                    responseData.forEach((item) => {
                        if (typeof item === 'string' || typeof item === 'number') {
                            if (resource === 'intervention' && operation === 'getAll') {
                                returnData.push({ json: { interventionId: item, id: item } });
                            }
                            else if (resource === 'task' && operation === 'getAll') {
                                returnData.push({ json: { taskId: item, id: item } });
                            }
                            else if (resource === 'network' && operation === 'getVirtualMacs') {
                                returnData.push({ json: { macAddress: item, mac: item } });
                            }
                            else if (resource === 'network' && operation === 'getSecondaryDns') {
                                returnData.push({ json: { domain: item, domainName: item } });
                            }
                            else {
                                returnData.push({ json: { value: item } });
                            }
                        }
                        else {
                            returnData.push({ json: item });
                        }
                    });
                }
                else {
                    returnData.push(responseData);
                }
            }
            catch (error) {
                if (resource === 'installation' && operation === 'getStatus' && error.statusCode === 404) {
                    returnData.push({
                        json: {
                            status: 'no_installation',
                            message: 'No installation or reinstallation in progress',
                        },
                    });
                }
                else if (resource === 'security' && error.statusCode === 404) {
                    if (operation === 'getFirewall') {
                        returnData.push({
                            json: {
                                available: false,
                                message: 'Firewall feature is not available for this server',
                            },
                        });
                    }
                    else if (operation === 'getIpSpoof') {
                        returnData.push({
                            json: {
                                available: false,
                                message: 'IP spoof protection information is not available for this server',
                            },
                        });
                    }
                    else {
                        returnData.push({
                            json: {
                                available: false,
                                message: 'This security feature is not available for this server',
                            },
                        });
                    }
                }
                else if (this.continueOnFail()) {
                    returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
                }
                else {
                    throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
                        itemIndex: i,
                    });
                }
            }
        }
        return [this.helpers.returnJsonArray(returnData)];
    }
}
exports.OvhDedicatedServer = OvhDedicatedServer;
//# sourceMappingURL=OvhDedicatedServer.node.js.map