import { INodeProperties } from 'n8n-workflow';

export const arpOperations: INodeProperties[] = [
	{
		displayName: 'Operation',
		name: 'operation',
		type: 'options',
		noDataExpression: true,
		displayOptions: {
			show: {
				resource: ['arp'],
			},
		},
		options: [
			{
				name: 'Get ARP Entry',
				value: 'getArpEntry',
				description: 'Retrieve ARP entry by IP, MAC, or network',
				action: 'Get ARP entry',
				routing: {
					request: {
						method: 'GET',
						url: '=/resources/ip/arp/{{$parameter.query}}',
					},
					output: {
						postReceive: [
							{
								type: 'rootProperty',
								properties: {
									property: 'arp',
								},
							},
						],
					},
				},
			},
			{
				name: 'Get Device ARP',
				value: 'getDeviceArp',
				description: 'Get all ARP entries for a device',
				action: 'Get device ARP entries',
				routing: {
					request: {
						method: 'GET',
						url: '/resources/ip/arp/all',
						qs: {
							device: '={{$parameter.deviceId}}',
						},
					},
					output: {
						postReceive: [
							{
								type: 'rootProperty',
								properties: {
									property: 'arp',
								},
							},
						],
					},
				},
			},
		],
		default: 'getArpEntry',
	},
];

export const arpFields: INodeProperties[] = [
	// Query field for IP/MAC/Network lookup
	{
		displayName: 'Query',
		name: 'query',
		type: 'string',
		required: true,
		displayOptions: {
			show: {
				resource: ['arp'],
				operation: ['getArpEntry'],
			},
		},
		default: '',
		placeholder: '192.168.1.1 or 00:11:22:33:44:55 or 192.168.1.0/24',
		description: 'IP address, MAC address, or CIDR network to search for',
	},

	// Device ID for device-specific ARP lookup
	{
		displayName: 'Device',
		name: 'deviceId',
		type: 'string',
		required: true,
		displayOptions: {
			show: {
				resource: ['arp'],
				operation: ['getDeviceArp'],
			},
		},
		default: '',
		placeholder: 'hostname or device ID',
		description: 'Device hostname or ID',
	},
];
