Commit 28969573 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added method to get interface instance with default values

parent adf701b9
......@@ -9,8 +9,6 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.client;
......@@ -23,12 +21,15 @@ import java.util.List;
* @param <T> The return type
*/
public interface ApiCallback<T> {
/**
* This is called when the API call fails.
*
* @param e The exception causing the failure
* @param statusCode Status code of the response if available, otherwise it would be 0
* @param responseHeaders Headers of the response if available, otherwise it would be null
* @param statusCode Status code of the response if available, otherwise it
* would be 0
* @param responseHeaders Headers of the response if available, otherwise it
* would be null
*/
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
......
......@@ -9,20 +9,20 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.client;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-25T13:58:54.535Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-28T19:11:27.492Z")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
private String responseBody = null;
public ApiException() {}
public ApiException() {
}
public ApiException(Throwable throwable) {
super(throwable);
......
......@@ -9,8 +9,6 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.client;
import java.util.List;
......@@ -22,6 +20,7 @@ import java.util.Map;
* @param <T> The type of data that is deserialized from response body
*/
public class ApiResponse<T> {
final private int statusCode;
final private Map<String, List<String>> headers;
final private T data;
......
......@@ -9,12 +9,11 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-25T13:58:54.535Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-28T19:11:27.492Z")
public class Configuration {
private static ApiClient defaultApiClient = new ApiClient();
/**
......
......@@ -478,6 +478,326 @@ public class DefaultApi {
return call;
}
/**
* Build call for getDefaultInterface
*
* @param id ID of topolog template uplodaed (required)
* @param interfaceType type to instantiate (required)
* @param instanceName the name of the instance to retrun (required)
* @param operationName the name of operation (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 getDefaultInterfaceCall(String id, String interfaceType, String instanceName, String operationName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/tosca_template/{id}/interface/{interface_type}/default"
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
.replaceAll("\\{" + "interface_type" + "\\}", apiClient.escapeString(interfaceType.toString()));
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (instanceName != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("instance_name", instanceName));
}
if (operationName != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("operation_name", operationName));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {};
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, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getDefaultInterfaceValidateBeforeCall(String id, String interfaceType, String instanceName, String operationName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling getDefaultInterface(Async)");
}
// verify the required parameter 'interfaceType' is set
if (interfaceType == null) {
throw new ApiException("Missing the required parameter 'interfaceType' when calling getDefaultInterface(Async)");
}
// verify the required parameter 'instanceName' is set
if (instanceName == null) {
throw new ApiException("Missing the required parameter 'instanceName' when calling getDefaultInterface(Async)");
}
// verify the required parameter 'operationName' is set
if (operationName == null) {
throw new ApiException("Missing the required parameter 'operationName' when calling getDefaultInterface(Async)");
}
com.squareup.okhttp.Call call = getDefaultInterfaceCall(id, interfaceType, instanceName, operationName, progressListener, progressRequestListener);
return call;
}
/**
*
* returns an interface instance with the default required values.
*
* @param id ID of topolog template uplodaed (required)
* @param interfaceType type to instantiate (required)
* @param instanceName the name of the instance to retrun (required)
* @param operationName the name of operation (required)
* @return Map&lt;String, Object&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public Map<String, Object> getDefaultInterface(String id, String interfaceType, String instanceName, String operationName) throws ApiException {
ApiResponse<Map<String, Object>> resp = getDefaultInterfaceWithHttpInfo(id, interfaceType, instanceName, operationName);
return resp.getData();
}
/**
*
* returns an interface instance with the default required values.
*
* @param id ID of topolog template uplodaed (required)
* @param interfaceType type to instantiate (required)
* @param instanceName the name of the instance to retrun (required)
* @param operationName the name of operation (required)
* @return ApiResponse&lt;Map&lt;String, Object&gt;&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public ApiResponse<Map<String, Object>> getDefaultInterfaceWithHttpInfo(String id, String interfaceType, String instanceName, String operationName) throws ApiException {
com.squareup.okhttp.Call call = getDefaultInterfaceValidateBeforeCall(id, interfaceType, instanceName, operationName, null, null);
Type localVarReturnType = new TypeToken<Map<String, Object>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* (asynchronously) returns an interface instance with the default required
* values.
*
* @param id ID of topolog template uplodaed (required)
* @param interfaceType type to instantiate (required)
* @param instanceName the name of the instance to retrun (required)
* @param operationName the name of operation (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 getDefaultInterfaceAsync(String id, String interfaceType, String instanceName, String operationName, final ApiCallback<Map<String, Object>> 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 = getDefaultInterfaceValidateBeforeCall(id, interfaceType, instanceName, operationName, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<Map<String, Object>>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getDefaultNodeType
*
* @param id ID of topolog template uplodaed (required)
* @param nodeType type to instantiate (required)
* @param instanceName the name of tghe instance to retrun (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 getDefaultNodeTypeCall(String id, String nodeType, String instanceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/tosca_template/{id}/node_types/{node_type}/default"
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
.replaceAll("\\{" + "node_type" + "\\}", apiClient.escapeString(nodeType.toString()));
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (instanceName != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("instance_name", instanceName));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {};
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, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getDefaultNodeTypeValidateBeforeCall(String id, String nodeType, String instanceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling getDefaultNodeType(Async)");
}
// verify the required parameter 'nodeType' is set
if (nodeType == null) {
throw new ApiException("Missing the required parameter 'nodeType' when calling getDefaultNodeType(Async)");
}
// verify the required parameter 'instanceName' is set
if (instanceName == null) {
throw new ApiException("Missing the required parameter 'instanceName' when calling getDefaultNodeType(Async)");
}
com.squareup.okhttp.Call call = getDefaultNodeTypeCall(id, nodeType, instanceName, progressListener, progressRequestListener);
return call;
}
/**
*
* returns an node templaye instance with the default required values.
*
* @param id ID of topolog template uplodaed (required)
* @param nodeType type to instantiate (required)
* @param instanceName the name of tghe instance to retrun (required)
* @return NodeTemplateMap
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public NodeTemplateMap getDefaultNodeType(String id, String nodeType, String instanceName) throws ApiException {
ApiResponse<NodeTemplateMap> resp = getDefaultNodeTypeWithHttpInfo(id, nodeType, instanceName);
return resp.getData();
}
/**
*
* returns an node templaye instance with the default required values.
*
* @param id ID of topolog template uplodaed (required)
* @param nodeType type to instantiate (required)
* @param instanceName the name of tghe instance to retrun (required)
* @return ApiResponse&lt;NodeTemplateMap&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public ApiResponse<NodeTemplateMap> getDefaultNodeTypeWithHttpInfo(String id, String nodeType, String instanceName) throws ApiException {
com.squareup.okhttp.Call call = getDefaultNodeTypeValidateBeforeCall(id, nodeType, instanceName, null, null);
Type localVarReturnType = new TypeToken<NodeTemplateMap>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* (asynchronously) returns an node templaye instance with the default
* required values.
*
* @param id ID of topolog template uplodaed (required)
* @param nodeType type to instantiate (required)
* @param instanceName the name of tghe instance to retrun (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 getDefaultNodeTypeAsync(String id, String nodeType, String instanceName, final ApiCallback<NodeTemplateMap> 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 = getDefaultNodeTypeValidateBeforeCall(id, nodeType, instanceName, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<NodeTemplateMap>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getDslDefinitions
*
......
......@@ -9,6 +9,8 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package nl.uva.sne.drip.sure.tosca.client;
import com.google.gson.Gson;
......@@ -23,7 +25,7 @@ import io.gsonfire.GsonFireBuilder;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
;
import okio.ByteString;
import java.io.IOException;
......@@ -35,10 +37,7 @@ import java.text.ParsePosition;
import java.util.Date;
import java.util.Map;
public class JSON {
private Gson gson;
private boolean isLenientOnJson = false;
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
......@@ -48,14 +47,15 @@ public class JSON {
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder();
GsonFireBuilder fireBuilder = new GsonFireBuilder()
;
GsonBuilder builder = fireBuilder.createGsonBuilder();
return builder;
}
private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) {
JsonElement element = readElement.getAsJsonObject().get(discriminatorField);
if (null == element) {
if(null == element) {
throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">");
}
return element.getAsString();
......@@ -63,7 +63,7 @@ public class JSON {
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase());
if (null == clazz) {
if(null == clazz) {
throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
}
return clazz;
......@@ -71,12 +71,12 @@ public class JSON {
public JSON() {
gson = createGson()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.registerTypeAdapter(byte[].class, byteArrayAdapter)
.create();
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.registerTypeAdapter(byte[].class, byteArrayAdapter)
.create();
}
/**
......@@ -117,8 +117,8 @@ public class JSON {
/**
* Deserialize the given JSON string to Java object.
*
* @param <T> Type
* @param body The JSON string
* @param <T> Type
* @param body The JSON string
* @param returnType The type to deserialize into
* @return The deserialized Java object
*/
......@@ -136,11 +136,9 @@ public class JSON {
} catch (JsonParseException e) {
// Fallback processing when failed to parse JSON form response body:
// return the response body string directly for the String return type;
if (returnType.equals(String.class)) {
if (returnType.equals(String.class))
return (T) body;
} else {
throw (e);
}
else throw (e);
}
}
......@@ -209,7 +207,7 @@ public class JSON {
default:
String date = in.nextString();
if (date.endsWith("+0000")) {
date = date.substring(0, date.length() - 5) + "Z";
date = date.substring(0, date.length()-5) + "Z";
}
return OffsetDateTime.parse(date, formatter);
}
......@@ -268,9 +266,9 @@ public class JSON {
}
/**
* Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a
* simple "yyyy-MM-dd" format will be used (more efficient than
* SimpleDateFormat).
* Gson TypeAdapter for java.sql.Date type
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
* (more efficient than SimpleDateFormat).
*/
public static class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> {
......@@ -323,8 +321,8 @@ public class JSON {
}
/**
* Gson TypeAdapter for java.util.Date type If the dateFormat is null,
* ISO8601Utils will be used.
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, ISO8601Utils will be used.
*/
public static class DateTypeAdapter extends TypeAdapter<Date> {
......
......@@ -13,7 +13,7 @@
package nl.uva.sne.drip.sure.tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-25T13:58:54.535Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-28T19:11:27.492Z")
public class Pair {
private String name = "";
private String value = "";
......
......@@ -13,7 +13,7 @@
package nl.uva.sne.drip.sure.tosca.client;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-25T13:58:54.535Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-12-28T19:11:27.492Z")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment