serverVariables) {
+ this.serverVariables = serverVariables;
return this;
}
@@ -350,10 +392,10 @@ public DateFormat getDateFormat() {
* Setter for the field dateFormat.
*
* @param dateFormat a {@link java.text.DateFormat} object
- * @return a {@link ApiClient} object
+ * @return a {@link io.tiledb.cloud.rest_api.ApiClient} object
*/
public ApiClient setDateFormat(DateFormat dateFormat) {
- this.json.setDateFormat(dateFormat);
+ JSON.setDateFormat(dateFormat);
return this;
}
@@ -361,10 +403,10 @@ public ApiClient setDateFormat(DateFormat dateFormat) {
* Set SqlDateFormat.
*
* @param dateFormat a {@link java.text.DateFormat} object
- * @return a {@link ApiClient} object
+ * @return a {@link io.tiledb.cloud.rest_api.ApiClient} object
*/
public ApiClient setSqlDateFormat(DateFormat dateFormat) {
- this.json.setSqlDateFormat(dateFormat);
+ JSON.setSqlDateFormat(dateFormat);
return this;
}
@@ -372,10 +414,10 @@ public ApiClient setSqlDateFormat(DateFormat dateFormat) {
* Set OffsetDateTimeFormat.
*
* @param dateFormat a {@link java.time.format.DateTimeFormatter} object
- * @return a {@link ApiClient} object
+ * @return a {@link io.tiledb.cloud.rest_api.ApiClient} object
*/
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
- this.json.setOffsetDateTimeFormat(dateFormat);
+ JSON.setOffsetDateTimeFormat(dateFormat);
return this;
}
@@ -383,10 +425,10 @@ public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
* Set LocalDateFormat.
*
* @param dateFormat a {@link java.time.format.DateTimeFormatter} object
- * @return a {@link ApiClient} object
+ * @return a {@link io.tiledb.cloud.rest_api.ApiClient} object
*/
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
- this.json.setLocalDateFormat(dateFormat);
+ JSON.setLocalDateFormat(dateFormat);
return this;
}
@@ -394,10 +436,10 @@ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
* Set LenientOnJson.
*
* @param lenientOnJson a boolean
- * @return a {@link ApiClient} object
+ * @return a {@link io.tiledb.cloud.rest_api.ApiClient} object
*/
public ApiClient setLenientOnJson(boolean lenientOnJson) {
- this.json.setLenientOnJson(lenientOnJson);
+ JSON.setLenientOnJson(lenientOnJson);
return this;
}
@@ -496,6 +538,31 @@ public void setAccessToken(String accessToken) {
throw new RuntimeException("No OAuth2 authentication configured!");
}
+ /**
+ * Helper method to set credentials for AWSV4 Signature
+ *
+ * @param accessKey Access Key
+ * @param secretKey Secret Key
+ * @param region Region
+ * @param service Service to access to
+ */
+ public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) {
+ throw new RuntimeException("No AWS4 authentication configured!");
+ }
+
+ /**
+ * Helper method to set credentials for AWSV4 Signature
+ *
+ * @param accessKey Access Key
+ * @param secretKey Secret Key
+ * @param sessionToken Session Token
+ * @param region Region
+ * @param service Service to access to
+ */
+ public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
+ throw new RuntimeException("No AWS4 authentication configured!");
+ }
+
/**
* Set the User-Agent header's value (by adding to the default header map).
*
@@ -678,7 +745,7 @@ public String parameterToString(Object param) {
return "";
} else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) {
//Serialize to json string and remove the " enclosing characters
- String jsonStr = json.serialize(param);
+ String jsonStr = JSON.serialize(param);
return jsonStr.substring(1, jsonStr.length() - 1);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
@@ -686,7 +753,7 @@ public String parameterToString(Object param) {
if (b.length() > 0) {
b.append(",");
}
- b.append(String.valueOf(o));
+ b.append(o);
}
return b.toString();
} else {
@@ -896,7 +963,7 @@ public String escapeString(String str) {
* @param response HTTP response
* @param returnType The type of the Java object
* @return The deserialized Java object
- * @throws ApiException If fail to deserialize response body, i.e. cannot read response body
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported.
*/
@SuppressWarnings("unchecked")
@@ -937,7 +1004,7 @@ public T deserialize(Response response, Type returnType) throws ApiException
contentType = "application/json";
}
if (isJsonMime(contentType)) {
- return json.deserialize(respBody, returnType);
+ return JSON.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
// Expecting string, return the raw response body.
return (T) respBody;
@@ -957,7 +1024,7 @@ public T deserialize(Response response, Type returnType) throws ApiException
* @param obj The Java object
* @param contentType The request Content-Type
* @return The serialized request body
- * @throws ApiException If fail to serialize the given object
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to serialize the given object
*/
public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) {
@@ -971,13 +1038,13 @@ public RequestBody serialize(Object obj, String contentType) throws ApiException
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {
- content = json.serialize(obj);
+ content = JSON.serialize(obj);
} else {
content = null;
}
return RequestBody.create(content, MediaType.parse(contentType));
} else if (obj instanceof String) {
- return RequestBody.create(MediaType.parse(contentType), (String) obj);
+ return RequestBody.create((String) obj, MediaType.parse(contentType));
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
@@ -987,7 +1054,7 @@ public RequestBody serialize(Object obj, String contentType) throws ApiException
* Download file from the given response.
*
* @param response An instance of the Response object
- * @throws ApiException If fail to read file content from response and write to disk
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to read file content from response and write to disk
* @return Downloaded file
*/
public File downloadFileFromResponse(Response response) throws ApiException {
@@ -1051,7 +1118,7 @@ public File prepareDownloadFile(Response response) throws IOException {
* @param Type
* @param call An instance of the Call object
* @return ApiResponse<T>
- * @throws ApiException If fail to execute the call
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to execute the call
*/
public ApiResponse execute(Call call) throws ApiException {
return execute(call, null);
@@ -1066,7 +1133,7 @@ public ApiResponse execute(Call call) throws ApiException {
* @return ApiResponse object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null
* when returnType is null.
- * @throws ApiException If fail to execute the call
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to execute the call
*/
public ApiResponse execute(Call call, Type returnType) throws ApiException {
try {
@@ -1130,7 +1197,7 @@ public void onResponse(Call call, Response response) throws IOException {
* @param response Response
* @param returnType Return type
* @return Type
- * @throws ApiException If the response has an unsuccessful status code or
+ * @throws io.tiledb.cloud.rest_api.ApiException If the response has an unsuccessful status code or
* fail to deserialize the response body
*/
public T handleResponse(Response response, Type returnType) throws ApiException {
@@ -1177,7 +1244,7 @@ public T handleResponse(Response response, Type returnType) throws ApiExcept
* @param authNames The authentications to apply
* @param callback Callback for upload/download progress
* @return The HTTP call
- * @throws ApiException If fail to serialize the request body object
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to serialize the request body object
*/
public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
@@ -1200,7 +1267,7 @@ public Call buildCall(String baseUrl, String path, String method, List que
* @param authNames The authentications to apply
* @param callback Callback for upload/download progress
* @return The HTTP request
- * @throws ApiException If fail to serialize the request body object
+ * @throws io.tiledb.cloud.rest_api.ApiException If fail to serialize the request body object
*/
public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
// aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams
@@ -1212,12 +1279,15 @@ public Request buildRequest(String baseUrl, String path, String method, List queryParams, List
if (baseUrl != null) {
url.append(baseUrl).append(path);
} else {
- url.append(basePath).append(path);
+ String baseURL;
+ if (serverIndex != null) {
+ if (serverIndex < 0 || serverIndex >= servers.size()) {
+ throw new ArrayIndexOutOfBoundsException(String.format(
+ "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
+ ));
+ }
+ baseURL = servers.get(serverIndex).URL(serverVariables);
+ } else {
+ baseURL = basePath;
+ }
+ url.append(baseURL).append(path);
}
if (queryParams != null && !queryParams.isEmpty()) {
@@ -1352,7 +1433,7 @@ public void processCookieParams(Map cookieParams, Request.Builde
* @param payload HTTP request body
* @param method HTTP method
* @param uri URI
- * @throws ApiException If fails to update the parameters
+ * @throws io.tiledb.cloud.rest_api.ApiException If fails to update the parameters
*/
public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams,
Map