/**
 * Copyright IBM Corp. 2024, 2025
 */
import { ruleSetInfo } from '../../../apim/apim-governance-info.interface.js';
import {
  ApimCatalog,
  ApimConsumerOrg,
  ApimGateway,
  ApimOrg,
  ApimSpace,
} from '../models/apim.model.js';

import JSZip from 'jszip';

export interface IApimHandler {
  getCatalogsByOrg(
    url: string,
    accessToken: string,
    orgId: string,
  ): Promise<ApimCatalog[]>;
  getRulesetsByOrg(
    url: string,
    accessToken: string,
    orgId: string,
  ): Promise<ruleSetInfo[]>;
  getGatewayServices(
    orgName: string,
    catalogId: string,
    url: string,
    accessToken: string,
    spaceId?: string | null,
  ): Promise<ApimGateway[]>;
  getOrgs(url: string, accessToken: string): Promise<ApimOrg[]>;
  getConsumerOrgs(
    orgName: string,
    catalogId: string,
    url: string,
    accessToken: string,
  ): Promise<ApimConsumerOrg[]>;
  getConsumerGroups(
    orgName: string,
    catalogId: string,
    url: string,
    accessToken: string,
  ): Promise<ApimConsumerOrg[]>;
  isSpacesEnabled(
    url: string,
    accessToken: string,
    orgId: string,
    catalogId: string,
  ): Promise<any>;
  getSpacesForCatalog(
    url: string,
    accessToken: string,
    orgId: string,
    catalogId: string,
  ): Promise<ApimSpace[]>;
  getOAuthClientInfo(
    connectionName: string,
    connectionUrl: string,
  ): Promise<string | null>;
  getOAuthToken(connectionName: string): Promise<string | null>;
  setOAuthToken(connectionName: string, token: string): Promise<void>;
  deleteOAuthToken(connectionName: string): Promise<void>;
  validateApimUrl(connectionUrl: string): Promise<boolean>;
  formatApiName(apiName: string, namespace: string): string;
  publishApim(
    zip: JSZip,
    connectionName: string,
    connectionUrl: string,
    token: string,
    namespace: string,
    org: string,
    catalog: string,
    gatewayServices: Array<{ name: string; gateway_service_type: string }>,
    space?: string | null,
    providerOrgs?: ApimOrg[],
    spaceGateways?: ApimGateway[],
    catalogs?: ApimCatalog[],
    skip_portal_services?: boolean,
    preserveSubscription?: boolean

  ): Promise<any>;
}
