import { Action } from '@ngrx/store';

import { RPCClientError } from '@loafer/ng-rpc/protocol';

import {
  Zone,
  Host,
  Port,
  Service,
  DiscoverZone as MDDiscoverZone,
  DiscoverHost as MDDiscoverHost,
  DiscoverPort as MDDiscoverPort,
  DiscoverService as MDiscoverService,
} from '@overflow/commons-typescript/model/discovery';
import { Probe } from '@overflow/commons-typescript/model/probe';

 export enum ActionType {
  SaveAllTarget = '[@@REGIST] TargetDiscoveryService.saveAllTarget',
  SaveAllTargetSuccess = '[@@REGIST] TargetDiscoveryService.SaveAllTargetSuccess',
  SaveAllTargetFailure = '[@@REGIST] TargetDiscoveryService.SaveAllTargetFailure',
}

export class DiscoverySaveAllTarget implements Action {
  readonly type = ActionType.SaveAllTarget;

  constructor(public payload: {hosts: Host[], probe: Probe}) {}
}

export class DiscoverySaveAllTargetSuccess implements Action {
  readonly type = ActionType.SaveAllTargetSuccess;

  constructor(public payload: Boolean) {}
}

export class DiscoverySaveAllTargetFailure implements Action {
  readonly type = ActionType.SaveAllTargetFailure;

  constructor(public payload: RPCClientError) {}
}

export type Actions =
  | DiscoverySaveAllTarget
  | DiscoverySaveAllTargetSuccess
  | DiscoverySaveAllTargetFailure
;
