import { ICredentialType, NodePropertyTypes } from 'n8n-workflow';

// credentials/ArubaCentralOAuth2Api.credentials.ts
export class ArubaCentralOAuth2Api implements ICredentialType {
	name = 'ArubaCentralOAuth2Api';
	displayName = 'Aruba Central OAuth2 API';
	documentationUrl = 'arubacentral';

	// These properties are essential for proper token storage in n8n
	// We're keeping our custom flow but declaring we store tokens like OAuth2
	__defaults = {
		tokenType: 'Bearer',
		tokenExpiredStatusCode: 401,
		tokenPropertyName: 'access_token',
	};

	properties = [
		{
			displayName: 'Base URL',
			name: 'baseUrl',
			type: 'string' as NodePropertyTypes,
			default: '',
			placeholder: 'https://apigw-prod2.central.arubanetworks.com',
			required: true,
			description: 'The domain base URL for HPE Aruba Networking Central API Gateway.',
		},
		{
			displayName: 'Client ID',
			name: 'clientId',
			type: 'string' as NodePropertyTypes,
			default: '',
			required: true,
			description: 'The OAuth client ID from API Gateway.',
		},
		{
			displayName: 'Client Secret',
			name: 'clientSecret',
			type: 'string' as NodePropertyTypes,
			default: '',
			required: true,
			description: 'The OAuth client secret from API Gateway.',
		},
		{
			displayName: 'Username',
			name: 'username',
			type: 'string' as NodePropertyTypes,
			default: '',
			required: true,
			description: 'Username for HPE Aruba Networking Central.',
		},
		{
			displayName: 'Password',
			name: 'password',
			type: 'string' as NodePropertyTypes,
			typeOptions: {
				password: true,
			},
			default: '',
			required: true,
			description: '',
		},
		{
			displayName: 'Customer ID',
			name: 'customerId',
			type: 'string' as NodePropertyTypes,
			default: '',
			required: true,
			description: 'HPE Aruba Networking Central Customer ID.',
		},
	];
}
