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

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

import { PageParams, Page } from 'app/commons/model';
import { Domain } from '@overflow/commons-typescript/model/domain';
import { Probe } from '@overflow/commons-typescript/model/probe';

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

  ReadAllByProbe = '[Infra.list] ReadAllByProbe',
  ReadAllByProbeSuccess = '[Infra.list] ReadAllByProbeSuccess',
  ReadAllByProbeFailure = '[Infra.list] ReadAllByProbeFailure',
}

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

  constructor(public payload: { domain: Domain, pageParams: PageParams }) { }
}

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

  constructor(public payload: Page) { }
}

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

  constructor(public payload: RPCClientError) { }
}

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

  constructor(public payload: { probe: Probe, pageParams: PageParams }) { }
}

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

  constructor(public payload: Page) { }
}

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

  constructor(public payload: RPCClientError) { }
}


export type Actions =
  | ReadAllByDomain
  | ReadAllByDomainSuccess
  | ReadAllByDomainFailure
  | ReadAllByProbe
  | ReadAllByProbeSuccess
  | ReadAllByProbeFailure
  ;
