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

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

import { Domain } from 'packages/domain/model';
import { ProbeHost } from '../../model';


export enum ActionType {
  ReadAllByDomain = '[probeHost.list] ReadAllByDomain',
  ReadAllByDomainSuccess = '[probeHost.list] ReadAllByDomainSuccess',
  ReadAllByDomainFailure = '[probeHost.list] ReadAllByDomainFailure',
}

export class ReadAllByDomain implements Action {
  readonly type = ActionType.ReadAllByDomain;

  constructor(public payload: Domain) {}
}

export class ReadAllByDomainSuccess implements Action {
  readonly type = ActionType.ReadAllByDomainSuccess;

  constructor(public payload: ProbeHost[]) {}
}

export class ReadAllByDomainFailure implements Action {
  readonly type = ActionType.ReadAllByDomainFailure;

  constructor(public payload: RPCClientError) {}
}


export type Actions =
  | ReadAllByDomain
  | ReadAllByDomainSuccess
  | ReadAllByDomainFailure
;
