import type { JSONSupport } from "../core/JSONSupport.js";

export interface ServerInfoProperties extends Partial<Pick<ServerInfo, "adminTokenServiceUrl" | "currentVersion" | "hasPortal" | "hasServer" | "server" | "shortLivedTokenValidity" | "tokenServiceUrl" | "webTierAuth">> {}

/**
 * This class contains information about an ArcGIS Server and its token endpoint.
 *
 * @since 4.0
 * @see [IdentityManager](https://developers.arcgis.com/javascript/latest/references/core/identity/IdentityManager/)
 * @see [Access Secure Services](https://developers.arcgis.com/javascript/latest/secure-resources/)
 * @see [Authentication and OAuth 2](https://developers.arcgis.com/authentication/)
 * @see [Guide topic - Proxy pages](https://developers.arcgis.com/javascript/latest/proxies/)
 * @see [Guide topic - CORS](https://developers.arcgis.com/javascript/latest/cors/)
 */
export default class ServerInfo extends JSONSupport {
  constructor(properties?: ServerInfoProperties);
  /** The token service URL used to generate tokens for ArcGIS Server Admin resources. */
  accessor adminTokenServiceUrl: string | null | undefined;
  /**
   * Version of the ArcGIS Server or Portal deployed on the server.
   *
   * > [!WARNING]
   * >
   * > Note: This value will be `8.4` for ArcGIS Online.
   *
   * @see [hasPortal](https://developers.arcgis.com/javascript/latest/references/core/identity/ServerInfo/#hasPortal)
   * @see [hasServer](https://developers.arcgis.com/javascript/latest/references/core/identity/ServerInfo/#hasServer)
   */
  accessor currentVersion: number | null | undefined;
  /**
   * Indicates whether the [server](https://developers.arcgis.com/javascript/latest/references/core/identity/ServerInfo/#server) is a [Portal](https://developers.arcgis.com/javascript/latest/references/core/portal/Portal/) instance.
   *
   * @see [IdentityManagerBase.registerServers()](https://developers.arcgis.com/javascript/latest/references/core/identity/IdentityManagerBase/#registerServers)
   * @see [currentVersion](https://developers.arcgis.com/javascript/latest/references/core/identity/ServerInfo/#currentVersion)
   */
  accessor hasPortal: boolean | null | undefined;
  /**
   * Indicates whether the [server](https://developers.arcgis.com/javascript/latest/references/core/identity/ServerInfo/#server) is an [ArcGIS Server](https://enterprise.arcgis.com/en/server/latest/get-started/windows/what-is-arcgis-for-server-.htm) instance.
   *
   * @see [IdentityManagerBase.registerServers()](https://developers.arcgis.com/javascript/latest/references/core/identity/IdentityManagerBase/#registerServers)
   * @example
   * // Register the serverInfo with the IdentityManager
   * esriId.registerServers([{
   *   hasServer: true,
   *   server: "https://<server domain>/arcgis",
   *   tokenServiceUrl: "https://<server domain>/arcgis/tokens/"
   * }]);
   */
  accessor hasServer: boolean | null | undefined;
  /** The server URL. This value includes the path to the web adapter for Servers (e.g. https://sampleserver6.arcgisonline.com/arcgis) and Portals (e.g. https://portal.esri.com/gis). */
  accessor server: string | null | undefined;
  /** Validity of short-lived token in minutes. */
  accessor shortLivedTokenValidity: number | null | undefined;
  /** The token service URL used to generate tokens for the secured resources on the server. */
  accessor tokenServiceUrl: string | null | undefined;
  /**
   * Indicates whether the server is configured to work with web tier authentication.
   *
   * @see [ArcGIS Server authentication tier](https://enterprise.arcgis.com/en/server/latest/administer/windows/configuring-arcgis-server-s-authentication-tier.htm)
   */
  accessor webTierAuth: boolean | null | undefined;
}