import type { Application } from '../application/application.model'; import type { ITask } from '../domain'; import type { IMoniker } from '../naming/IMoniker'; import type { IJob } from '../task/taskExecutor'; import { TaskExecutor } from '../task/taskExecutor'; export interface ILoadBalancerUpsertCommand extends IJob { name: string; cloudProvider: string; credentials: string; detail?: string; healthCheckProtocol?: string; healthCheck?: string; healthCheckPort?: number; healthCheckPath?: string; moniker?: IMoniker; region: string; stack?: string; } export interface ILoadBalancerDeleteCommand extends IJob { cloudProvider: string; loadBalancerName: string; credentials: string; regions?: string[]; vpcId?: string; } export class LoadBalancerWriter { public static deleteLoadBalancer(command: ILoadBalancerDeleteCommand, application: Application): PromiseLike { command.type = 'deleteLoadBalancer'; return TaskExecutor.executeTask({ job: [command], application, description: `Delete load balancer: ${command.loadBalancerName}`, }); } public static upsertLoadBalancer( command: ILoadBalancerUpsertCommand, application: Application, descriptor: string, params: any = {}, ): PromiseLike { Object.assign(command, params); command.type = 'upsertLoadBalancer'; return TaskExecutor.executeTask({ job: [command], application, description: `${descriptor} Load Balancer: ${command['name']}`, }); } }