001/* 002 * MIT License 003 * 004 * Copyright (c) 2023 IntellectualSites 005 * 006 * Permission is hereby granted, free of charge, to any person obtaining a copy 007 * of this software and associated documentation files (the "Software"), to deal 008 * in the Software without restriction, including without limitation the rights 009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 010 * copies of the Software, and to permit persons to whom the Software is 011 * furnished to do so, subject to the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be included in all 014 * copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 022 * SOFTWARE. 023 */ 024package com.intellectualsites.arkitektonika; 025 026import org.jetbrains.annotations.NotNull; 027 028import java.io.File; 029import java.util.concurrent.CompletableFuture; 030import java.util.concurrent.ExecutorService; 031 032/** 033 * Arkitektonika REST client 034 */ 035public interface ApiClient { 036 037 /** 038 * Get the API version supported by this client 039 * 040 * @return API version 041 */ 042 @NotNull ApiVersion getApiVersion(); 043 044 /** 045 * Check if the specified API address is 046 * compatible with the client 047 * 048 * @param executorService Executor service used to complete the request 049 * @return Future that completes with the result of the query 050 */ 051 @NotNull CompletableFuture<Boolean> checkCompatibility( 052 @NotNull final ExecutorService executorService); 053 054 /** 055 * Upload a schematic via an input stream 056 * 057 * @param file File to upload 058 * @param executorService Executor service used to complete the request 059 * @return Future that completes with the access and deletion keys of the 060 * uploaded resource, or fails with an exception 061 */ 062 @NotNull CompletableFuture<SchematicKeys> upload(@NotNull final File file, 063 @NotNull final ExecutorService executorService); 064 065 /** 066 * Check the status of a remote schematic 067 * 068 * @param key Schematic access key 069 * @param executorService Executor service used to complete the request 070 * @return Future that completes with the resource status 071 */ 072 @NotNull CompletableFuture<ResourceStatus> checkStatus(@NotNull final String key, 073 @NotNull final ExecutorService executorService); 074 075 /** 076 * Attempt to delete a schematic from the remote service 077 * 078 * @param key Deletion key 079 * @param executorService Executor service used to complete the request 080 * @return Future that completes with the result 081 */ 082 @NotNull CompletableFuture<Boolean> delete(@NotNull final String key, 083 @NotNull final ExecutorService executorService); 084 085 /** 086 * Attempt to download a schematic from the remote service 087 * 088 * @param key Download key 089 * @param executorService Executor service used to complete the request 090 * @return Future that completes with the result 091 */ 092 @NotNull CompletableFuture<Schematic> download(@NotNull final String key, 093 @NotNull final ExecutorService executorService); 094 095}