import * as plugins from '../plugins.js';
import * as data from '../data/index.js';

export interface IReq_GetPlatformServices extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetPlatformServices
> {
  method: 'getPlatformServices';
  request: {
    identity: data.IIdentity;
  };
  response: {
    platformServices: data.IPlatformService[];
  };
}

export interface IReq_GetPlatformService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetPlatformService
> {
  method: 'getPlatformService';
  request: {
    identity: data.IIdentity;
    serviceType: data.TPlatformServiceType;
  };
  response: {
    platformService: data.IPlatformService;
  };
}

export interface IReq_StartPlatformService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_StartPlatformService
> {
  method: 'startPlatformService';
  request: {
    identity: data.IIdentity;
    serviceType: data.TPlatformServiceType;
  };
  response: {
    platformService: data.IPlatformService;
  };
}

export interface IReq_StopPlatformService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_StopPlatformService
> {
  method: 'stopPlatformService';
  request: {
    identity: data.IIdentity;
    serviceType: data.TPlatformServiceType;
  };
  response: {
    platformService: data.IPlatformService;
  };
}

/**
 * One-time migration of every MinIO-backed bucket resource onto
 * smartstorage (corestore): provisions scoped buckets, copies all objects,
 * swaps service env vars and resource records. MinIO keeps running as
 * rollback until decommissioned explicitly.
 */
export interface IReq_MigrateS3ToSmartstorage extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_MigrateS3ToSmartstorage
> {
  method: 'migrateS3ToSmartstorage';
  request: {
    identity: data.IIdentity;
  };
  response: {
    migrated: Array<{
      serviceName: string;
      oldBucket: string;
      newBucket: string;
      objectsCopied: number;
    }>;
    errors: string[];
  };
}

export interface IReq_GetPlatformServiceStats extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetPlatformServiceStats
> {
  method: 'getPlatformServiceStats';
  request: {
    identity: data.IIdentity;
    serviceType: data.TPlatformServiceType;
  };
  response: {
    stats: data.IContainerStats;
  };
}

export interface IReq_GetPlatformServiceLogs extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetPlatformServiceLogs
> {
  method: 'getPlatformServiceLogs';
  request: {
    identity: data.IIdentity;
    serviceType: data.TPlatformServiceType;
    tail?: number;
  };
  response: {
    logs: data.ILogEntry[];
  };
}

export interface IReq_PushPlatformServiceLog extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PushPlatformServiceLog
> {
  method: 'pushPlatformServiceLog';
  request: {
    serviceType: data.TPlatformServiceType;
    entry: {
      timestamp: string;
      level: string;
      message: string;
    };
  };
  response: {};
}
