/**
 * Copyright IBM Corp. 2024, 2025
 */

/**
 * Represents the possible actions for SQL injection filters
 */
export type SqlInjectionFilterAction = 'block' | 'log' | 'allow';

/**
 * Interface for custom SQL injection filters
 * This is a record of string keys to SqlInjectionFilterAction values
 */
export interface CustomSqlInjectionFilters {
  [filterName: string]: SqlInjectionFilterAction;
}

/**
 * Interface for SQL injection filters configuration
 * This represents the structure stored under dp-nano-gateway.spec.sqlInjectionFilters
 */
export interface SqlInjectionFilters {
  // Standard filter types
  commands?: SqlInjectionFilterAction;
  escapeSequence?: SqlInjectionFilterAction;
  keywordInjection?: SqlInjectionFilterAction;
  likeMatch?: SqlInjectionFilterAction;
  metacharacters?: SqlInjectionFilterAction;
  msSqlCommands?: SqlInjectionFilterAction;
  andOrAttack?: SqlInjectionFilterAction;
  oracleBufferOverflow?: SqlInjectionFilterAction;
  simpleMetacharacters?: SqlInjectionFilterAction;

  // Custom filters container
  custom?: CustomSqlInjectionFilters;
}

/**
 * Interface for the dp-nano-gateway extension in a product
 */
export interface DpNanoGatewayExtension {
  apiVersion: string;
  spec: {
    sqlInjectionFilters?: SqlInjectionFilters;
    // Other dp-nano-gateway spec properties can be added here as needed
  };
}

/**
 * Interface for product extensions
 */
export interface ProductExtensions {
  'dp-nano-gateway'?: DpNanoGatewayExtension;
}

export type DpNanoGatewayConfig = {
  logLevel?: string;
  quotaService?: {
    cache?: {
      capacity?: string;
      maxAgeMilliseconds?: string;
      maxPercent?: string;
      fallback?: string;
    };
    responseHeaders?: string;
    updateInterval?: string;
  };
  replicas?: string;
  resources?: {
    limits?: {
      cpu?: string;
      memory?: string;
    };
    requests?: {
      cpu?: string;
      memory?: string;
    };
  };
};

/**
 * Interface for a property in dp-nano-gateway.spec.properties
 */
export interface Property {
  key: string;
  value: string;
  description: string;
  encoded: boolean;
}

/**
 * Interface for a host alias in dp-nano-gateway.spec.hostAliases
 */
export interface HostAlias {
  ip: string;
  hostnames: string[];
}

/**
 * Interface for an environment variable in dp-nano-gateway.spec.env
 */

export interface configMapKeyRef {
  name: string;
  key: string;
}
export interface secretKeyRef {
  name: string;
  key: string;
}
export interface fieldRef {
  fieldPath: string;
}
export interface resourceFieldRef {
  resource: string;
}
export interface valueFrom {
  configMapKeyRef?: configMapKeyRef;
  secretKeyRef?: secretKeyRef;
  fieldRef?: fieldRef;
  resourceFieldRef?: resourceFieldRef;
}
export interface DpNanoEnvironmentFormatted {
  name: string;
  value?: string;
  valueFrom?: valueFrom;
}

export interface DpNanoEnvironment {
  name: string;
  value?: string;
  valueFrom?: string;
  configName?: string;
  configKey?: string;
  secretName?: string;
  secretKey?: string;
  fieldPath?: string;
  resourceType?: string;
}

/**
 * Interface for a count limit definition in dp-nano-gateway.spec.withAssemblyCountLimit
 */
export interface CountLimitDefs {
  name: string;
  version?: string;
  aliasName?: string;
  max?: number;
  autoDecrement?: boolean;
  weightExpression?: string;
  dynamicValue?: string;
  nameSpace?: string;
}
