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

export interface IReq_GetServices extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServices
> {
  method: 'getServices';
  request: {
    identity: data.IIdentity;
  };
  response: {
    services: data.IService[];
  };
}

export interface IReq_GetService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetService
> {
  method: 'getService';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    service: data.IService;
  };
}

export interface IReq_CreateService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_CreateService
> {
  method: 'createService';
  request: {
    identity: data.IIdentity;
    serviceConfig: data.IServiceCreate;
  };
  response: {
    service: data.IService;
  };
}

export interface IReq_UpdateService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_UpdateService
> {
  method: 'updateService';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    updates: data.IServiceUpdate;
  };
  response: {
    service: data.IService;
  };
}

export interface IReq_DeleteService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_DeleteService
> {
  method: 'deleteService';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    ok: boolean;
  };
}

export interface IReq_StartService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_StartService
> {
  method: 'startService';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    service: data.IService;
  };
}

export interface IReq_StopService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_StopService
> {
  method: 'stopService';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    service: data.IService;
  };
}

export interface IReq_RestartService extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_RestartService
> {
  method: 'restartService';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    service: data.IService;
  };
}

export interface IReq_GetServiceLogs extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServiceLogs
> {
  method: 'getServiceLogs';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    tail?: number;
  };
  response: {
    logs: string;
  };
}

export interface IReq_GetServiceStats extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServiceStats
> {
  method: 'getServiceStats';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    stats: data.IContainerStats;
  };
}

export interface IReq_GetServiceMetrics extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServiceMetrics
> {
  method: 'getServiceMetrics';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    limit?: number;
  };
  response: {
    metrics: data.IMetric[];
  };
}

export interface IReq_GetServicePlatformResources extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServicePlatformResources
> {
  method: 'getServicePlatformResources';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    resources: data.IPlatformResource[];
  };
}

export interface IReq_GetServiceBackups extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServiceBackups
> {
  method: 'getServiceBackups';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    backups: data.IBackup[];
  };
}

export interface IReq_CreateServiceBackup extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_CreateServiceBackup
> {
  method: 'createServiceBackup';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    backup: data.IBackup;
  };
}

export interface IReq_GetServiceBackupSchedules extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetServiceBackupSchedules
> {
  method: 'getServiceBackupSchedules';
  request: {
    identity: data.IIdentity;
    serviceName: string;
  };
  response: {
    schedules: data.IBackupSchedule[];
  };
}

export interface IReq_PushServiceLog extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PushServiceLog
> {
  method: 'pushServiceLog';
  request: {
    serviceName: string;
    entry: {
      timestamp: string;
      level: string;
      message: string;
    };
  };
  response: {};
}

export interface IReq_PushServiceUpdate extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PushServiceUpdate
> {
  method: 'pushServiceUpdate';
  request: {
    action: 'created' | 'updated' | 'deleted' | 'started' | 'stopped';
    serviceName: string;
    service?: data.IService;
  };
  response: {};
}
