import { CorrelationRulesActionRecord } from 'types/default';

export function makeNewCorrelationRuleAction(
  type: CorrelationRulesActionRecord['type'],
): CorrelationRulesActionRecord {
  if (type === 'http') {
    return {
      type: 'http',
      url: '',
      content_type: 'text/plain',
      template: '',
    };
  } else if (type === 'bash') {
    return {
      type: 'bash',
      body: '',
    };
  } else if (type === 'syslog') {
    return {
      type: 'syslog',
      host: '',
      port: 80,
      protocol: 'tcp',
      name: '',
      template: '',
    };
  } else if (type === 'asset') {
    return {
      type: 'asset',
      name: '',
      asset_type: null,
      group: null,
      description: '',
      manufacturer: null,
      model: '',
      os: null,
      ip: '',
      ports: '[]',
    };
  } else if (type === 'incident') {
    return {
      type: 'incident',
      title: '',
      category: null,
      importance: '',
      assigned_to: '',
      description: '',
      comment: '',
      close_recommendations: [],
      effects: [],
    };
  } else if (type === 'exec') {
    return {
      type: 'exec',
      path: '',
      args: '',
      env: '',
      cwd: '',
    };
  } else if (type === 'firewall') {
    return {
      type: 'firewall',
      armaif: null,
      sensor: {
        ip: '',
        scheme: 'https',
        key: '',
        secret: '',
      },
      enabled: false,
      quick: false,
      log: false,
      interface: [],
      direction: '',
      sequence: '',
      action: '',
      ipprotocol: '',
      protocol: '',
      source_net: '',
      source_port: '',
      source_not: false,
      destination_net: '',
      destination_port: '',
      destination_not: false,
      description: '',
      gateway: '',
    };
  } else {
    throw new Error('Unknown action type');
  }
}
