import { INodeProperties } from 'n8n-workflow';

export const pollerGroupsOperations: INodeProperties[] = [
	{
		displayName: 'Operation',
		name: 'operation',
		type: 'options',
		noDataExpression: true,
		displayOptions: {
			show: {
				resource: ['pollerGroups'],
			},
		},
		options: [
			{
				name: 'Get All',
				value: 'getAll',
				description: 'Get all poller groups',
				action: 'Get all poller groups',
				routing: {
					request: {
						method: 'GET',
						url: '/poller_group',
					},
					output: {
						postReceive: [
							{
								type: 'rootProperty',
								properties: {
									property: 'get_poller_group',
								},
							},
						],
					},
				},
			},
			{
				name: 'Get',
				value: 'get',
				description: 'Get a specific poller group',
				action: 'Get a poller group',
				routing: {
					request: {
						method: 'GET',
						url: '=/poller_group/{{$parameter.pollerGroupId}}',
					},
					output: {
						postReceive: [
							{
								type: 'rootProperty',
								properties: {
									property: 'get_poller_group',
								},
							},
						],
					},
				},
			},
		],
		default: 'getAll',
	},
];

export const pollerGroupsFields: INodeProperties[] = [
	// Poller Group ID for specific operations
	{
		displayName: 'Poller Group',
		name: 'pollerGroupId',
		type: 'string',
		required: true,
		displayOptions: {
			show: {
				resource: ['pollerGroups'],
				operation: ['get'],
			},
		},
		default: '',
		placeholder: 'poller group name or ID',
		description: 'Poller group name or ID',
	},
];
