/**
 * Interface of the server (auto-generated code)
 */
import {
	HTTPMimeType,
	HTTPRequestModel,
	RESTConfig,
	RESTRequestJson,
	RESTRequestVoid,
} from "../rest-tools";

import {
	ObjectId,
} from "../model";

export namespace DataResource {

	/**
	 * Get back some data from the data environment (with a beautiful name (permit download with basic name)
	 */
	export function retrieveDataFull({
			restConfig,
			queries,
			params,
			data,
		}: {
		restConfig: RESTConfig,
		queries: {
			Authorization?: string,
		},
		params: {
			name: string,
			oid: ObjectId,
		},
		data: string,
	}): Promise<object> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/data/{oid}/{name}",
				requestType: HTTPRequestModel.GET,
			},
			restConfig,
			params,
			queries,
			data,
		});
	};
	/**
	 * Get back some data from the data environment
	 */
	export function retrieveDataId({
			restConfig,
			queries,
			params,
			data,
		}: {
		restConfig: RESTConfig,
		queries: {
			Authorization?: string,
		},
		params: {
			oid: ObjectId,
		},
		data: string,
	}): Promise<object> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/data/{oid}",
				requestType: HTTPRequestModel.GET,
			},
			restConfig,
			params,
			queries,
			data,
		});
	};
	/**
	 * Get a thumbnail of from the data environment (if resize is possible)
	 */
	export function retrieveDataThumbnailId({
			restConfig,
			queries,
			params,
			data,
		}: {
		restConfig: RESTConfig,
		queries: {
			Authorization?: string,
		},
		params: {
			oid: ObjectId,
		},
		data: string,
	}): Promise<object> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/data/thumbnail/{oid}",
				requestType: HTTPRequestModel.GET,
			},
			restConfig,
			params,
			queries,
			data,
		});
	};
	/**
	 * Insert a new data in the data environment
	 */
	export function uploadFile({
			restConfig,
			data,
		}: {
		restConfig: RESTConfig,
		data: {
			file: File,
		},
	}): Promise<void> {
		return RESTRequestVoid({
			restModel: {
				endPoint: "/data//upload/",
				requestType: HTTPRequestModel.POST,
				contentType: HTTPMimeType.MULTIPART,
			},
			restConfig,
			data,
		});
	};
}
