import type Accessor from "../../core/Accessor.js";
import type EsriError from "../../core/Error.js";

export interface UnregisterReplicaResponseProperties extends Partial<Pick<UnregisterReplicaResponse, "decoderError" | "unregisterReplicaResults">> {}

/**
 * The response for [executeUnregisterReplica()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeUnregisterReplica).
 *
 * @since 5.0
 */
export default class UnregisterReplicaResponse extends Accessor {
  constructor(properties?: UnregisterReplicaResponseProperties);
  /** Any errors encountered while decoding the results. */
  accessor decoderError: EsriError | null;
  /** The unregister results returned for each requested replica id. */
  accessor unregisterReplicaResults: UnregisterReplicaResult[];
}

/** Per-replica unregister result. */
export interface UnregisterReplicaResult {
  /** The replica id that was processed by the unregister operation. */
  replicaId: string;
  /** Any error returned for this replica id. */
  error?: EsriError;
}

/** Additional options for unregistering replicas. */
export type UnregisterReplicaOptions = UnregisterAllReplicaOptions | UnregisterReplicaIdsOptions;

/** Additional options for unregistering all replicas. */
export interface UnregisterAllReplicaOptions {
  /** If `true`, unregisters all replicas. */
  unregisterAll: true;
  /** Cannot be set when `unregisterAll` is `true`. */
  replicaIds?: never;
}

/** Additional options for unregistering explicit replica ids. */
export interface UnregisterReplicaIdsOptions {
  /** If `false` or omitted, `replicaIds` must contain one or more values. */
  unregisterAll?: false;
  /** The replica ids to unregister. */
  replicaIds: string[];
}