Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion common/src/main/java/com/skyflow/errors/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ public enum ErrorMessage {
ConnectionIdAlreadyInConfigList("%s0 Validation error. ConnectionId is present in an existing config. Specify a connectionId in config."),
ConnectionIdNotInConfigList("%s0 Validation error. ConnectionId is missing from the config. Specify the connectionIds from configs."),
EmptyCredentials("%s0 Validation error. Invalid credentials. Credentials must not be empty."),

TableSpecifiedInRequestAndRecordObject("%s0 Validation error. Table name cannot be specified at both the request and record levels. Please specify the table name in only one place."),
UpsertTableRequestAtRecordLevel("%s0 Validation error. Table name should be present at each record level when upsert is present at record level."),
UpsertTableRequestAtRequestLevel("%s0 Validation error. Upsert should be present at each record level when table name is present at record level."),
TableNotSpecifiedInRequestAndRecordObject("%s0 Validation error. Table name is missing. Table name should be specified at one place either at the request level or record level. Please specify the table name at one place."),
// Vault config
InvalidVaultId("%s0 Initialization failed. Invalid vault ID. Specify a valid vault ID."),
EmptyVaultId("%s0 Initialization failed. Invalid vault ID. Vault ID must not be empty."),
Expand Down Expand Up @@ -60,6 +63,10 @@ public enum ErrorMessage {
TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."),
EmptyTable("%s0 Validation error. 'table' can't be empty. Specify a table."),
ValuesKeyError("%s0 Validation error. 'values' key is missing from the payload. Specify a 'values' key."),
EmptyRecords("%s0 Validation error. 'records' can't be empty. Specify records."),
EmptyKeyInRecords("%s0 Validation error. Invalid key in data in records. Specify a valid key."),
EmptyValueInRecords("%s0 Validation error. Invalid value in records. Specify a valid value."),
RecordsKeyError("%s0 Validation error. 'records' key is missing from the payload. Specify a 'records' key."),
EmptyValues("%s0 Validation error. 'values' can't be empty. Specify values."),
EmptyKeyInValues("%s0 Validation error. Invalid key in values. Specify a valid key."),
EmptyValueInValues("%s0 Validation error. Invalid value in values. Specify a valid value."),
Expand Down Expand Up @@ -164,6 +171,7 @@ public enum ErrorMessage {
NullRedactionInTokenGroup("%s0 Validation error. Redaction in TokenGroupRedactions is null or empty. Specify a valid redaction."),

NullTokenGroupNameInTokenGroup("%s0 Validation error. TokenGroupName in TokenGroupRedactions is null or empty. Specify a valid tokenGroupName."),
InvalidRecord("%s0 Validation error. InsertRecord object in the list is invalid. Specify a valid InsertRecord object."),
;
;
private final String message;
Expand Down
10 changes: 8 additions & 2 deletions common/src/main/java/com/skyflow/logs/ErrorLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public enum ErrorLogs {
EMPTY_TABLE_NAME("Invalid %s1 request. Table name can not be empty."),
VALUES_IS_REQUIRED("Invalid %s1 request. Values are required."),
EMPTY_VALUES("Invalid %s1 request. Values can not be empty."),
RECORDS_IS_REQUIRED("Invalid %s1 request. Records are required."),
EMPTY_RECORDS("Invalid %s1 request. Records can not be empty."),
INVALID_RECORD("Invalid %s1 request. Invalid record. Specify a valid record."),
RECORD_SIZE_EXCEED("Maximum number of records exceeded. The limit is 10000."),
TOKENS_SIZE_EXCEED("Maximum number of tokens exceeded. The limit is 10000."),
EMPTY_OR_NULL_VALUE_IN_VALUES("Invalid %s1 request. Value can not be null or empty in values for key \"%s2\"."),
Expand Down Expand Up @@ -143,8 +146,11 @@ public enum ErrorLogs {

UNEXPECTED_ERROR_DURING_BATCH_PROCESSING("Unexpected error occurred during batch processing. Error: %s1"),

PROCESSING_ERROR_RESPONSE("Processing error response.");

PROCESSING_ERROR_RESPONSE("Processing error response."),
TABLE_SPECIFIED_AT_BOTH_PLACE("Invalid %s1 request. Table name cannot be specified at both the request and record levels. Please specify the table name at only one place."),
TABLE_NOT_SPECIFIED_AT_BOTH_PLACE("Invalid %s1 request. Table name is missing. Table name should be specified at one place either at the request level or record level. Please specify the table name at one place."),
UPSERT_TABLE_REQUEST_AT_RECORD_LEVEL("Invalid %s1 request. Table name should be present at each record level when upsert is present at record level."),
UPSERT_TABLE_REQUEST_AT_REQUEST_LEVEL("Invalid %s1 request. Upsert should be present at each record level when table name is present at record level.");
private final String log;

ErrorLogs(String log) {
Expand Down
11 changes: 0 additions & 11 deletions common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ public String getTable() {
return this.builder.table;
}

public ArrayList<HashMap<String, Object>> getValues() {
return this.builder.values;
}

static class BaseInsertRequestBuilder {
protected String table;
protected ArrayList<HashMap<String, Object>> values;
protected String upsert;

protected BaseInsertRequestBuilder() {
}

Expand All @@ -31,11 +25,6 @@ public BaseInsertRequestBuilder table(String table) {
return this;
}

public BaseInsertRequestBuilder values(ArrayList<HashMap<String, Object>> values) {
this.values = values;
return this;
}

}
}

9 changes: 6 additions & 3 deletions v2/src/main/java/com/skyflow/vault/data/InsertRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public String getUpsert() {
public Boolean getReturnTokens() {
return this.builder.returnTokens;
}

public ArrayList<HashMap<String, Object>> getValues() {
return this.builder.values;
}

public ArrayList<HashMap<String, Object>> getTokens() {
return this.builder.tokens;
}
Expand All @@ -43,6 +46,7 @@ public static final class InsertRequestBuilder extends BaseInsertRequestBuilder
private Boolean homogeneous;
private Boolean continueOnError;
private TokenMode tokenMode;
private ArrayList<HashMap<String, Object>> values;

private ArrayList<HashMap<String, Object>> tokens;
private Boolean returnTokens;
Expand All @@ -60,9 +64,8 @@ public InsertRequestBuilder table(String table) {
return this;
}

@Override
public InsertRequestBuilder values(ArrayList<HashMap<String, Object>> values) {
super.values(values);
this.values = values;
return this;
}

Expand Down
47 changes: 36 additions & 11 deletions v3/src/main/java/com/skyflow/VaultClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.skyflow;

import java.util.ArrayList;
import java.util.List;

import com.skyflow.config.Credentials;
import com.skyflow.config.VaultConfig;
import com.skyflow.enums.UpdateType;
Expand All @@ -20,15 +23,13 @@
import com.skyflow.utils.logger.LogUtil;
import com.skyflow.utils.validations.Validations;
import com.skyflow.vault.data.DetokenizeRequest;
import com.skyflow.vault.data.InsertRecord;

import io.github.cdimascio.dotenv.Dotenv;
import io.github.cdimascio.dotenv.DotenvException;
import okhttp3.OkHttpClient;
import okhttp3.Request;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class VaultClient {
private final VaultConfig vaultConfig;
Expand Down Expand Up @@ -132,17 +133,41 @@ protected void updateExecutorInHTTP() {
apiClientBuilder.httpClient(httpClient);
}

protected InsertRequest getBulkInsertRequestBody(com.skyflow.vault.data.InsertRequest request, VaultConfig config) throws SkyflowException {
List<HashMap<String, Object>> values = request.getValues();
protected InsertRequest getBulkInsertRequestBody(com.skyflow.vault.data.InsertRequest request, VaultConfig config) {
ArrayList<InsertRecord> records = request.getRecords();
List<InsertRecordData> insertRecordDataList = new ArrayList<>();
for (HashMap<String, Object> value : values) {
InsertRecordData data = InsertRecordData.builder().data(value).build();
insertRecordDataList.add(data);
for (InsertRecord record : records) {
InsertRecordData.Builder data = InsertRecordData.builder();
data.data(record.getData());
if (record.getTable() != null && !record.getTable().isEmpty()){
data.tableName(record.getTable());
}
if (record.getUpsert() != null && !record.getUpsert().isEmpty()){
if (record.getUpsertType() != null) {
EnumUpdateType updateType = null;
if (record.getUpsertType() == UpdateType.REPLACE) {
updateType = EnumUpdateType.REPLACE;
} else if (record.getUpsertType() == UpdateType.UPDATE) {
updateType = EnumUpdateType.UPDATE;
}
Upsert upsert = Upsert.builder().uniqueColumns(record.getUpsert()).updateType(updateType).build();
data.upsert(upsert);
} else {
Upsert upsert = Upsert.builder().uniqueColumns(record.getUpsert()).build();
data.upsert(upsert);
}
}
insertRecordDataList.add(data.build());
}

InsertRequest.Builder builder = InsertRequest.builder()
.vaultId(config.getVaultId())
.records(insertRecordDataList)
.tableName(request.getTable());
.records(insertRecordDataList);

if (request.getTable() != null && !request.getTable().isEmpty()){
builder.tableName(request.getTable());
}

if (request.getUpsert() != null && !request.getUpsert().isEmpty()) {
if (request.getUpsertType() != null) {
EnumUpdateType updateType = null;
Expand Down
2 changes: 0 additions & 2 deletions v3/src/main/java/com/skyflow/enums/UpdateType.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.skyflow.enums;

import com.fasterxml.jackson.annotation.JsonValue;

public enum UpdateType {
UPDATE("UPDATE"),

Expand Down
9 changes: 8 additions & 1 deletion v3/src/main/java/com/skyflow/generated/rest/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@

import com.skyflow.generated.rest.core.ClientOptions;
import com.skyflow.generated.rest.core.Suppliers;
import com.skyflow.generated.rest.resources.records.RecordsClient;
import com.skyflow.generated.rest.resources.recordservice.RecordserviceClient;

import java.util.function.Supplier;

public class ApiClient {
protected final ClientOptions clientOptions;

protected final Supplier<RecordsClient> recordsClient;

protected final Supplier<RecordserviceClient> recordserviceClient;

public ApiClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.recordsClient = Suppliers.memoize(() -> new RecordsClient(clientOptions));
this.recordserviceClient = Suppliers.memoize(() -> new RecordserviceClient(clientOptions));
}

public RecordsClient records() {
return this.recordsClient.get();
}

public RecordserviceClient recordservice() {
return this.recordserviceClient.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@

import com.skyflow.generated.rest.core.ClientOptions;
import com.skyflow.generated.rest.core.Suppliers;
import com.skyflow.generated.rest.resources.records.AsyncRecordsClient;
import com.skyflow.generated.rest.resources.recordservice.AsyncRecordserviceClient;

import java.util.function.Supplier;

public class AsyncApiClient {
protected final ClientOptions clientOptions;

protected final Supplier<AsyncRecordsClient> recordsClient;

protected final Supplier<AsyncRecordserviceClient> recordserviceClient;

public AsyncApiClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.recordsClient = Suppliers.memoize(() -> new AsyncRecordsClient(clientOptions));
this.recordserviceClient = Suppliers.memoize(() -> new AsyncRecordserviceClient(clientOptions));
}

public AsyncRecordsClient records() {
return this.recordsClient.get();
}

public AsyncRecordserviceClient recordservice() {
return this.recordserviceClient.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
*/
package com.skyflow.generated.rest.core;

import okhttp3.Response;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Response;

/**
* This exception type will be thrown for any non-2XX API responses.
Expand Down Expand Up @@ -66,7 +65,7 @@ public Map<String, List<String>> headers() {
return this.headers;
}

@Override
@java.lang.Override
public String toString() {
return "ApiClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body
+ "}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
*/
package com.skyflow.generated.rest.core;

import okhttp3.Response;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Response;

public final class ApiClientHttpResponse<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
*/
package com.skyflow.generated.rest.core;

import okhttp3.OkHttpClient;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import okhttp3.OkHttpClient;

public final class ClientOptions {
private final Environment environment;
Expand All @@ -35,7 +34,7 @@ private ClientOptions(
{
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.skyflow.fern:api-sdk");
put("X-Fern-SDK-Version", "0.0.275");
put("X-Fern-SDK-Version", "0.0.352");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;

import java.io.IOException;
import java.time.Instant;
import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
*/
package com.skyflow.generated.rest.core;

import java.io.InputStream;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.jetbrains.annotations.Nullable;

import java.io.InputStream;
import java.util.Objects;

/**
* Represents a file stream with associated metadata for file uploads.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*/
package com.skyflow.generated.rest.core;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.internal.Util;
Expand All @@ -11,10 +14,6 @@
import okio.Source;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;

/**
* A custom implementation of OkHttp's RequestBody that wraps an InputStream.
* This class allows streaming of data from an InputStream directly to an HTTP request body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import java.io.IOException;

public final class ObjectMappers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.HttpUrl;
import okhttp3.MultipartBody;

import java.util.*;

public class QueryStringMapper {

private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
*/
package com.skyflow.generated.rest.core;

import okhttp3.Response;

import java.io.FilterInputStream;
import java.io.IOException;
import okhttp3.Response;

/**
* A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the
Expand Down
Loading
Loading