Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016-2018 The Sponge authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openksavi.sponge.remoteapi.client;
import java.io.Closeable;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import org.openksavi.sponge.action.ProvideArgsParameters;
import org.openksavi.sponge.remoteapi.client.listener.OnRequestSerializedListener;
import org.openksavi.sponge.remoteapi.client.listener.OnResponseDeserializedListener;
import org.openksavi.sponge.remoteapi.feature.converter.FeatureConverter;
import org.openksavi.sponge.remoteapi.model.RemoteActionMeta;
import org.openksavi.sponge.remoteapi.model.RemoteKnowledgeBaseMeta;
import org.openksavi.sponge.remoteapi.model.request.ActionCallRequest;
import org.openksavi.sponge.remoteapi.model.request.GetActionsRequest;
import org.openksavi.sponge.remoteapi.model.request.GetEventTypesRequest;
import org.openksavi.sponge.remoteapi.model.request.GetFeaturesRequest;
import org.openksavi.sponge.remoteapi.model.request.GetKnowledgeBasesRequest;
import org.openksavi.sponge.remoteapi.model.request.GetVersionRequest;
import org.openksavi.sponge.remoteapi.model.request.IsActionActiveRequest;
import org.openksavi.sponge.remoteapi.model.request.IsActionActiveRequest.IsActionActiveEntry;
import org.openksavi.sponge.remoteapi.model.request.LoginRequest;
import org.openksavi.sponge.remoteapi.model.request.LogoutRequest;
import org.openksavi.sponge.remoteapi.model.request.ProvideActionArgsRequest;
import org.openksavi.sponge.remoteapi.model.request.ReloadRequest;
import org.openksavi.sponge.remoteapi.model.request.SendEventRequest;
import org.openksavi.sponge.remoteapi.model.request.SpongeRequest;
import org.openksavi.sponge.remoteapi.model.response.ActionCallResponse;
import org.openksavi.sponge.remoteapi.model.response.GetActionsResponse;
import org.openksavi.sponge.remoteapi.model.response.GetEventTypesResponse;
import org.openksavi.sponge.remoteapi.model.response.GetFeaturesResponse;
import org.openksavi.sponge.remoteapi.model.response.GetKnowledgeBasesResponse;
import org.openksavi.sponge.remoteapi.model.response.GetVersionResponse;
import org.openksavi.sponge.remoteapi.model.response.IsActionActiveResponse;
import org.openksavi.sponge.remoteapi.model.response.LoginResponse;
import org.openksavi.sponge.remoteapi.model.response.LogoutResponse;
import org.openksavi.sponge.remoteapi.model.response.ProvideActionArgsResponse;
import org.openksavi.sponge.remoteapi.model.response.ReloadResponse;
import org.openksavi.sponge.remoteapi.model.response.ResponseError;
import org.openksavi.sponge.remoteapi.model.response.SendEventResponse;
import org.openksavi.sponge.remoteapi.model.response.SpongeResponse;
import org.openksavi.sponge.remoteapi.type.converter.TypeConverter;
import org.openksavi.sponge.type.RecordType;
import org.openksavi.sponge.type.provided.ProvidedValue;
/**
* A Sponge Remote API client.
*/
@SuppressWarnings("rawtypes")
public interface SpongeClient extends Closeable {
/**
* Returns the client configuration.
*
* @return the client configuration.
*/
SpongeClientConfiguration getConfiguration();
void addOnRequestSerializedListener(OnRequestSerializedListener listener);
boolean removeOnRequestSerializedListener(OnRequestSerializedListener listener);
void addOnResponseDeserializedListener(OnResponseDeserializedListener listener);
boolean removeOnResponseDeserializedListener(OnResponseDeserializedListener listener);
/**
* Returns the Sponge API features by sending the {@code features} request to the server and returning the features or using the cache.
*
* @return the API features.
*/
Map getFeatures();
/**
* Sends the {@code features} request to the server.
*
* @param request the request.
* @param context the context.
* @return the {@code features} response.
*/
GetFeaturesResponse getFeatures(GetFeaturesRequest request, SpongeRequestContext context);
/**
* Sends the {@code features} request to the server.
*
* @param request the request.
* @return the {@code features} response.
*/
GetFeaturesResponse getFeatures(GetFeaturesRequest request);
/**
* Sends the {@code version} request to the server.
*
* @param request the request.
* @param context the context.
* @return the {@code version} response.
*/
GetVersionResponse getVersion(GetVersionRequest request, SpongeRequestContext context);
/**
* Sends the {@code version} request to the server.
*
* @param request the request.
* @return the {@code version} response.
*/
GetVersionResponse getVersion(GetVersionRequest request);
/**
* Sends the {@code version} request to the server.
*
* @return the Sponge version.
*/
String getVersion();
/**
* Sends the {@code login} request to the server. Sets the auth token in the client for further requests.
*
* @param request the request.
* @param context the context.
* @return the {@code login} response.
*/
LoginResponse login(LoginRequest request, SpongeRequestContext context);
/**
* Sends the {@code login} request to the server. See {@link #login(LoginRequest,SpongeRequestContext)}.
*
* @param request the request.
* @return the {@code login} response.
*/
LoginResponse login(LoginRequest request);
/**
* Sends the {@code login} request to the server. See {@link #login(LoginRequest,SpongeRequestContext)}.
*
* @return the optional auth token.
*/
String login();
/**
* Sends the {@code logout} request to the server. Clears the auth token in the client.
*
* @param request the request.
* @param context the context.
* @return the {@code logout} response.
*/
LogoutResponse logout(LogoutRequest request, SpongeRequestContext context);
/**
* Sends the {@code logout} request to the server. See {@link #logout(LogoutRequest,SpongeRequestContext)}.
*
* @param request the request.
* @return the {@code logout} response.
*/
LogoutResponse logout(LogoutRequest request);
/**
* Sends the {@code logout} request to the server. See {@link #logout(LogoutRequest,SpongeRequestContext)}.
*/
void logout();
/**
* Sends the {@code knowledgeBases} request to the server.
*
* @param request the request.
* @param context the context.
* @return the {@code knowledgeBases} response.
*/
GetKnowledgeBasesResponse getKnowledgeBases(GetKnowledgeBasesRequest request, SpongeRequestContext context);
/**
* Sends the {@code knowledgeBases} request to the server.
*
* @param request the request.
* @return the {@code knowledgeBases} response.
*/
GetKnowledgeBasesResponse getKnowledgeBases(GetKnowledgeBasesRequest request);
/**
* Sends the {@code knowledgeBases} request to the server.
*
* @return the list of available knowledge bases metadata.
*/
List getKnowledgeBases();
/**
* Sends the {@code actions} request to the server. This method may populate the action metadata cache.
*
* @param request the request.
* @param context the context.
* @return the {@code actions} response.
*/
GetActionsResponse getActions(GetActionsRequest request, SpongeRequestContext context);
/**
* Sends the {@code actions} request to the server. See {@link #getActions(GetActionsRequest,SpongeRequestContext)}.
*
* @param request the request.
* @return the {@code actions} response.
*/
GetActionsResponse getActions(GetActionsRequest request);
/**
* Sends the {@code actions} request to the server. See {@link #getActions(GetActionsRequest,SpongeRequestContext)}.
*
* @param name the action name or the regular expression or {@code null} to return results for all actions.
* @param metadataRequired if {@code true} only actions that have arguments and result metadata will be returned.
* @return the list of available actions metadata..
*/
List getActions(String name, Boolean metadataRequired);
/**
* Sends the {@code actions} request to the server. See {@link #getActions(GetActionsRequest,SpongeRequestContext)}.
*
* @param name the action name or the regular expression or {@code null} to return results for all actions.
* @return the list of available actions metadata..
*/
List getActions(String name);
/**
* Sends the {@code actions} request to the server. See {@link #getActions(GetActionsRequest,SpongeRequestContext)}.
*
* @return the list of available actions metadata.
*/
List getActions();
/**
* Returns the metadata for the specified action. This method may fetch the metadata from the server or use the action metadata cache if
* configured.
*
* @param actionName the action name.
* @param allowFetchMetadata if {@code true} (the default value), the action metadata may be fetched from the server.
* @param context the context.
*
* @return the action metadata or {@code null} if there is no such action or that action has no metadata.
*/
RemoteActionMeta getActionMeta(String actionName, boolean allowFetchMetadata, SpongeRequestContext context);
/**
* Returns the metadata for the specified action. See {@link #getActionMeta(String,boolean,SpongeRequestContext)}.
*
* @param actionName the action name.
* @param allowFetchMetadata if {@code true} (the default value), the action metadata may be fetched from the server.
*
* @return the action metadata or {@code null} if there is no such action or that action has no metadata.
*/
RemoteActionMeta getActionMeta(String actionName, boolean allowFetchMetadata);
/**
* Returns the metadata for the specified action. See {@link #getActionMeta(String,boolean,SpongeRequestContext)}.
*
* @param actionName the action name.
*
* @return the action metadata or {@code null} if there is no such action or that action has no metadata.
*/
RemoteActionMeta getActionMeta(String actionName);
/**
* Validates the action call arguments. This method is invoked internally by the {@code call} methods. Throws exception on validation
* failure.
*
* @param actionMeta the action metadata.
* @param args the action arguments.
*/
void validateCallArgs(RemoteActionMeta actionMeta, List