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

export interface RasterDataProperties extends JSONSupportMixinProperties, Partial<Pick<RasterData, "itemId" | "url">> {}

export type RasterDataType = "image-service";

/**
 * A geoprocessing data type representing raster data file or service.
 *
 * @since 4.20
 * @see [Geoprocessing Data Types | GPRasterDataLayer](https://developers.arcgis.com/rest/services-reference/enterprise/gp-data-types/#gprasterdatalayer)
 * @example
 * // Create a new RasterData object representing a tif image.
 * const rasterData = new RasterData({
 *   url: "https://myserver/lake.tif"
 * });
 */
export default class RasterData extends JSONSupport {
  constructor(properties?: RasterDataProperties);
  /**
   * The image type (e.g. "jpg" or "tif") when this data type references an image.
   *
   * @example
   * const parameterValue = await jobInfo.fetchResultData("Output_TIF_GDB");
   * console.log(parameterValue.dataType); // "raster-data-layer"
   *
   * const rasterData = parameterValue.value;
   * console.log(rasterData.url);    // "https://machine.domain.com/webadaptor/rest/directories/arcgisoutput/GPServer/_ags_africa_150m.tif"
   * console.log(rasterData.format); // "tif"
   */
  get format(): string | null | undefined;
  /**
   * The ID of the portal item containing the raster data file or service.
   *
   * @example
   * const rasterData = new RasterData({
   *   itemId: "my-portal-item-id"
   * });
   */
  accessor itemId: string | null | undefined;
  /**
   * When the output data type is an image service, this property will return `image-service`.
   *
   * @example
   * const rasterData = parameterValue.value;
   * const { url, format, type } = rasterData;
   * if (url) {
   *   if (type === "image-service") {
   *     console.log(`The url to the image service is: ${url}`);
   *   else {
   *     console.log(`The url to the raster data file is: ${url}`);
   *     console.log(`The raster data file is a ${format} image`);
   *   }
   * }
   */
  get type(): RasterDataType | null | undefined;
  /** The URL to the raster data file or image service. */
  accessor url: string | null | undefined;
}