io.proximax.xpx.service.remote.RemoteNodeApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xpx-java-sdk Show documentation
Show all versions of xpx-java-sdk Show documentation
Proximax P2P File Storage Java SDK (NIS1 Compatible)
/*
* Copyright 2018 ProximaX Limited
*
* 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.
*/
/*
* Proximax P2P Storage REST API
* Proximax P2P Storage REST API
*
* OpenAPI spec version: v0.0.1
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.proximax.xpx.service.remote;
import io.proximax.ApiCallback;
import io.proximax.ApiClient;
import io.proximax.ApiResponse;
import io.proximax.Pair;
import io.proximax.ProgressRequestBody;
import io.proximax.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import io.proximax.xpx.exceptions.ApiException;
import io.proximax.xpx.model.GenericResponseMessage;
import io.proximax.xpx.model.NodeInfo;
import io.proximax.xpx.service.intf.NodeApi;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The Class RemoteNodeApi.
*/
public class RemoteNodeApi implements NodeApi {
/** The api client. */
private final ApiClient apiClient;
/**
* Instantiates a new remote node api.
*
* @param apiClient the api client
*/
public RemoteNodeApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Gets the api client.
*
* @return the api client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Build call for checkNodeUsingGET.
*
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call checkNodeUsingGETCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/node/check";
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
/**
* Check node using GET validate before call.
*
* @param progressListener the progress listener
* @param progressRequestListener the progress request listener
* @return the com.squareup.okhttp. call
* @throws ApiException the api exception
*/
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call checkNodeUsingGETValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
com.squareup.okhttp.Call call = checkNodeUsingGETCall(progressListener, progressRequestListener);
return call;
}
/**
* Check if the Storage Node is up and running.
* This endpoint is used to check if the P2P Storage Node instance is either alive or down.
* @return GenericResponseMessage
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GenericResponseMessage checkNodeUsingGET() throws ApiException {
ApiResponse resp = checkNodeUsingGETWithHttpInfo();
return resp.getData();
}
/**
* Check if the Storage Node is up and running.
* This endpoint is used to check if the P2P Storage Node instance is either alive or down.
* @return ApiResponse<GenericResponseMessage>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse checkNodeUsingGETWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = checkNodeUsingGETValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Check if the Storage Node is up and running. (asynchronously)
* This endpoint is used to check if the P2P Storage Node instance is either alive or down.
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call checkNodeUsingGETAsync(final ApiCallback callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = checkNodeUsingGETValidateBeforeCall(progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getNodeInfoPeersUsingGET.
*
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call getNodeInfoPeersUsingGETCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/node/info/peers";
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
/**
* Gets the node info peers using GET validate before call.
*
* @param progressListener the progress listener
* @param progressRequestListener the progress request listener
* @return the node info peers using GET validate before call
* @throws ApiException the api exception
*/
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getNodeInfoPeersUsingGETValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
com.squareup.okhttp.Call call = getNodeInfoPeersUsingGETCall(progressListener, progressRequestListener);
return call;
}
/**
* Get Storage Node Information
* This endpoint returns the information of the P2P Storage Node.
*
* @return NodeInfo
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public NodeInfo getNodeInfoPeersUsingGET() throws ApiException {
ApiResponse resp = getNodeInfoPeersUsingGETWithHttpInfo();
return resp.getData();
}
/**
* Get Storage Node Information
* This endpoint returns the information of the P2P Storage Node.
*
* @return ApiResponse<NodeInfo>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getNodeInfoPeersUsingGETWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = getNodeInfoPeersUsingGETValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get Storage Node Information (asynchronously)
* This endpoint returns the information of the P2P Storage Node.
*
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call getNodeInfoPeersUsingGETAsync(final ApiCallback callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getNodeInfoPeersUsingGETValidateBeforeCall(progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getNodeInfoUsingGET.
*
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call getNodeInfoUsingGETCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/node/info";
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
/**
* Gets the node info using GET validate before call.
*
* @param progressListener the progress listener
* @param progressRequestListener the progress request listener
* @return the node info using GET validate before call
* @throws ApiException the api exception
*/
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getNodeInfoUsingGETValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
com.squareup.okhttp.Call call = getNodeInfoUsingGETCall(progressListener, progressRequestListener);
return call;
}
/**
* Get Storage Node Information
* This endpoint returns the information of the P2P Storage Node.
*
* @return NodeInfo
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public NodeInfo getNodeInfoUsingGET() throws ApiException {
ApiResponse resp = getNodeInfoUsingGETWithHttpInfo();
return resp.getData();
}
/**
* Get Storage Node Information
* This endpoint returns the information of the P2P Storage Node.
*
* @return ApiResponse<NodeInfo>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getNodeInfoUsingGETWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = getNodeInfoUsingGETValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get Storage Node Information (asynchronously)
* This endpoint returns the information of the P2P Storage Node.
*
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call getNodeInfoUsingGETAsync(final ApiCallback callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getNodeInfoUsingGETValidateBeforeCall(progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for setBlockchainNodeConnectionUsingPOST.
*
* @param network Blockchain Network (required)
* @param domain Blockchain Network Domain (xxx.xxx.xxx) (required)
* @param port Blockchain Network Port (xxx.xxx.xxx) (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call setBlockchainNodeConnectionUsingPOSTCall(String network, String domain, String port, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/node/set/blockchain/connection";
List localVarQueryParams = new ArrayList();
if (network != null)
localVarQueryParams.addAll(apiClient.parameterToPairs("", "network", network));
if (domain != null)
localVarQueryParams.addAll(apiClient.parameterToPairs("", "domain", domain));
if (port != null)
localVarQueryParams.addAll(apiClient.parameterToPairs("", "port", port));
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
/**
* Sets the blockchain node connection using POST validate before call.
*
* @param network the network
* @param domain the domain
* @param port the port
* @param progressListener the progress listener
* @param progressRequestListener the progress request listener
* @return the com.squareup.okhttp. call
* @throws ApiException the api exception
*/
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call setBlockchainNodeConnectionUsingPOSTValidateBeforeCall(String network, String domain, String port, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'network' is set
if (network == null) {
throw new ApiException("Missing the required parameter 'network' when calling setBlockchainNodeConnectionUsingPOST(Async)");
}
// verify the required parameter 'domain' is set
if (domain == null) {
throw new ApiException("Missing the required parameter 'domain' when calling setBlockchainNodeConnectionUsingPOST(Async)");
}
// verify the required parameter 'port' is set
if (port == null) {
throw new ApiException("Missing the required parameter 'port' when calling setBlockchainNodeConnectionUsingPOST(Async)");
}
com.squareup.okhttp.Call call = setBlockchainNodeConnectionUsingPOSTCall(network, domain, port, progressListener, progressRequestListener);
return call;
}
/**
* Get Storage Node Information
* This endpoint returns the information of the P2P Storage Node.
*
* @param network Blockchain Network (required)
* @param domain Blockchain Network Domain (xxx.xxx.xxx) (required)
* @param port Blockchain Network Port (xxx.xxx.xxx) (required)
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public String setBlockchainNodeConnectionUsingPOST(String network, String domain, String port) throws ApiException {
ApiResponse resp = setBlockchainNodeConnectionUsingPOSTWithHttpInfo(network, domain, port);
return resp.getData();
}
/**
* Get Storage Node Information
* This endpoint returns the information of the P2P Storage Node.
*
* @param network Blockchain Network (required)
* @param domain Blockchain Network Domain (xxx.xxx.xxx) (required)
* @param port Blockchain Network Port (xxx.xxx.xxx) (required)
* @return ApiResponse<String>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse setBlockchainNodeConnectionUsingPOSTWithHttpInfo(String network, String domain, String port) throws ApiException {
com.squareup.okhttp.Call call = setBlockchainNodeConnectionUsingPOSTValidateBeforeCall(network, domain, port, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get Storage Node Information (asynchronously)
* This endpoint returns the information of the P2P Storage Node.
*
* @param network Blockchain Network (required)
* @param domain Blockchain Network Domain (xxx.xxx.xxx) (required)
* @param port Blockchain Network Port (xxx.xxx.xxx) (required)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call setBlockchainNodeConnectionUsingPOSTAsync(String network, String domain, String port, final ApiCallback callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = setBlockchainNodeConnectionUsingPOSTValidateBeforeCall(network, domain, port, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}