Skip to content

Commit 655c612

Browse files
SK-1817: Public release Java SDK V2 (#222)
* SK-1817: public release for v2
1 parent fbc045e commit 655c612

File tree

104 files changed

+3599
-5610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+3599
-5610
lines changed

.github/workflows/beta-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
uses: ./.github/workflows/shared-build-and-deploy.yml
88
with:
99
ref: ${{ github.ref_name }}
10-
server-id: ossrh
10+
server-id: central
1111
profile: maven-central
1212
tag: 'beta'
1313
secrets:

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v1
2323
- uses: actions/setup-java@v1
2424
with:
25-
java-version: "1.8"
25+
java-version: "11"
2626

2727
- name: create-json
2828
id: create-json

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
uses: ./.github/workflows/shared-build-and-deploy.yml
88
with:
99
ref: ${{ github.ref_name }}
10-
server-id: ossrh
10+
server-id: central
1111
profile: maven-central
1212
tag: 'public'
1313
secrets:

.github/workflows/shared-build-and-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ jobs:
5252
fetch-depth: 0
5353

5454
- name: Set up maven or jfrog repository
55-
uses: actions/setup-java@v1
55+
uses: actions/setup-java@v4
5656
with:
57-
java-version: "1.8"
57+
java-version: "11"
5858
distribution: "adopt"
5959
server-id: ${{ inputs.server-id }}
6060
server-username: SERVER_USERNAME

pom.xml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.skyflow</groupId>
88
<artifactId>skyflow-java</artifactId>
9-
<version>2.0.0-beta.2</version>
9+
<version>2.0.0-beta.4</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
@@ -45,12 +45,6 @@
4545
</properties>
4646

4747
<dependencies>
48-
<dependency>
49-
<groupId>com.squareup.okhttp3</groupId>
50-
<artifactId>okhttp</artifactId>
51-
<version>4.12.0</version>
52-
<scope>compile</scope>
53-
</dependency>
5448
<dependency>
5549
<groupId>com.fasterxml.jackson.core</groupId>
5650
<artifactId>jackson-databind</artifactId>
@@ -126,9 +120,10 @@
126120
<dependency>
127121
<groupId>junit</groupId>
128122
<artifactId>junit</artifactId>
129-
<version>${junit-version}</version>
123+
<version>4.13.2</version>
130124
<scope>test</scope>
131125
</dependency>
126+
132127
<dependency>
133128
<groupId>org.powermock</groupId>
134129
<artifactId>powermock-module-junit4</artifactId>
@@ -141,12 +136,6 @@
141136
<version>2.0.9</version>
142137
<scope>test</scope>
143138
</dependency>
144-
<dependency>
145-
<groupId>org.junit.jupiter</groupId>
146-
<artifactId>junit-jupiter</artifactId>
147-
<version>5.13.2</version>
148-
<scope>compile</scope>
149-
</dependency>
150139
</dependencies>
151140

152141
<build>
@@ -185,7 +174,14 @@
185174
<plugin>
186175
<groupId>org.apache.maven.plugins</groupId>
187176
<artifactId>maven-surefire-plugin</artifactId>
188-
<version>2.22.2</version>
177+
<version>3.2.5</version>
178+
<configuration>
179+
<useModulePath>false</useModulePath>
180+
<includes>
181+
<include>**/*Test.java</include>
182+
<include>**/*Tests.java</include>
183+
</includes>
184+
</configuration>
189185
</plugin>
190186
<plugin>
191187
<groupId>org.jacoco</groupId>

src/main/java/com/skyflow/VaultClient.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody;
1818
import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody;
1919
import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody;
20+
import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request;
2021
import com.skyflow.generated.rest.resources.strings.StringsClient;
2122
import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest;
2223
import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest;
@@ -32,6 +33,7 @@
3233
import com.skyflow.utils.Utils;
3334
import com.skyflow.utils.logger.LogUtil;
3435
import com.skyflow.utils.validations.Validations;
36+
import com.skyflow.vault.data.FileUploadRequest;
3537
import com.skyflow.vault.data.InsertRequest;
3638
import com.skyflow.vault.data.UpdateRequest;
3739
import com.skyflow.vault.detect.*;
@@ -44,6 +46,10 @@
4446
import io.github.cdimascio.dotenv.Dotenv;
4547
import io.github.cdimascio.dotenv.DotenvException;
4648

49+
import java.io.File;
50+
import java.io.IOException;
51+
import java.nio.file.Files;
52+
import java.nio.file.Paths;
4753
import java.util.*;
4854
import java.util.stream.Collectors;
4955

@@ -209,6 +215,22 @@ protected V1TokenizePayload getTokenizePayload(TokenizeRequest request) {
209215
return payloadBuilder.build();
210216
}
211217

218+
protected File getFileForFileUpload(FileUploadRequest fileUploadRequest) throws IOException {
219+
if (fileUploadRequest.getFilePath() != null) {
220+
return new File(fileUploadRequest.getFilePath());
221+
}
222+
else if (fileUploadRequest.getBase64() != null) {
223+
byte[] decodedBytes = Base64.getDecoder().decode(fileUploadRequest.getBase64());
224+
File file = new File(fileUploadRequest.getFileName());
225+
Files.write(file.toPath(), decodedBytes);
226+
return file;
227+
}
228+
else if (fileUploadRequest.getFileObject() != null) {
229+
return fileUploadRequest.getFileObject();
230+
}
231+
return null;
232+
}
233+
212234
protected void setBearerToken() throws SkyflowException {
213235
prioritiseCredentials();
214236
Validations.validateCredentials(this.finalCredentials);
@@ -512,7 +534,6 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req
512534
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
513535
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
514536
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
515-
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));
516537

517538
if (tokenFormat != null) {
518539
if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) {
@@ -540,13 +561,12 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req
540561
return DeidentifyPdfRequest.builder()
541562
.vaultId(vaultId)
542563
.file(file)
543-
.density(request.getPixelDensity() != null ? request.getPixelDensity().intValue() : null)
544-
.maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().intValue() : null)
564+
.density(request.getPixelDensity() != null ? request.getPixelDensity().doubleValue() : null)
565+
.maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().doubleValue() : null)
545566
.entityTypes(mappedEntityTypes)
546567
.tokenType(tokenType)
547568
.allowRegex(allowRegex)
548569
.restrictRegex(restrictRegex)
549-
.transformations(transformations)
550570
.build();
551571
}
552572

@@ -558,7 +578,6 @@ protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest
558578
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
559579
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
560580
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
561-
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));
562581

563582
TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);
564583

@@ -580,7 +599,6 @@ protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest
580599
.tokenType(tokenType)
581600
.allowRegex(allowRegex)
582601
.restrictRegex(restrictRegex)
583-
.transformations(transformations)
584602
.outputProcessedImage(request.getOutputProcessedImage())
585603
.outputOcrText(request.getOutputOcrText())
586604
.build();
@@ -594,7 +612,6 @@ protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(Deident
594612
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
595613
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
596614
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
597-
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));
598615

599616
TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);
600617

@@ -610,7 +627,6 @@ protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(Deident
610627
.tokenType(tokenType)
611628
.allowRegex(allowRegex)
612629
.restrictRegex(restrictRegex)
613-
.transformations(transformations)
614630
.build();
615631
}
616632

@@ -622,7 +638,6 @@ protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(Deidentif
622638
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
623639
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
624640
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
625-
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));
626641

627642
TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);
628643

@@ -638,7 +653,6 @@ protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(Deidentif
638653
.tokenType(tokenType)
639654
.allowRegex(allowRegex)
640655
.restrictRegex(restrictRegex)
641-
.transformations(transformations)
642656
.build();
643657
}
644658

@@ -678,7 +692,6 @@ protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileR
678692
Optional<List<EntityType>> entityUniqueCounter = Optional.empty();
679693
Optional<List<String>> allowRegex = Optional.ofNullable(request.getAllowRegexList());
680694
Optional<List<String>> restrictRegex = Optional.ofNullable(request.getRestrictRegexList());
681-
Optional<Transformations> transformations = Optional.ofNullable(getTransformations(request.getTransformations()));
682695

683696
TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter);
684697

@@ -694,7 +707,6 @@ protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileR
694707
.tokenType(tokenType)
695708
.allowRegex(allowRegex)
696709
.restrictRegex(restrictRegex)
697-
.transformations(transformations)
698710
.build();
699711
}
700712

src/main/java/com/skyflow/enums/DeidentifyFileStatus.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
public enum DeidentifyFileStatus {
44
IN_PROGRESS("IN_PROGRESS"),
5-
SUCCESS("SUCCESS");
5+
FAILED("FAILED"),
6+
SUCCESS("SUCCESS"),
7+
UNKNOWN("UNKNOWN");
68

79
private final String value;
810

src/main/java/com/skyflow/enums/DetectEntities.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ public enum DetectEntities {
1313
CREDIT_CARD_EXPIRATION("credit_card_expiration"),
1414
CVV("cvv"),
1515
DATE("date"),
16+
DAY("day"),
1617
DATE_INTERVAL("date_interval"),
1718
DOB("dob"),
1819
DOSE("dose"),
1920
DRIVER_LICENSE("driver_license"),
2021
DRUG("drug"),
2122
DURATION("duration"),
23+
EFFECT("effect"),
2224
EMAIL_ADDRESS("email_address"),
2325
EVENT("event"),
2426
FILENAME("filename"),
2527
FINANCIAL_METRIC("financial_metric"),
26-
GENDER_SEXUALITY("gender_sexuality"),
28+
GENDER("gender"),
2729
HEALTHCARE_NUMBER("healthcare_number"),
2830
INJURY("injury"),
2931
IP_ADDRESS("ip_address"),
@@ -40,30 +42,35 @@ public enum DetectEntities {
4042
MEDICAL_CODE("medical_code"),
4143
MEDICAL_PROCESS("medical_process"),
4244
MONEY("money"),
45+
MONTH("month"),
4346
NAME("name"),
4447
NAME_FAMILY("name_family"),
4548
NAME_GIVEN("name_given"),
4649
NAME_MEDICAL_PROFESSIONAL("name_medical_professional"),
4750
NUMERICAL_PII("numerical_pii"),
4851
OCCUPATION("occupation"),
4952
ORGANIZATION("organization"),
53+
ORGANIZATION_ID("organization_id"),
5054
ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"),
5155
ORIGIN("origin"),
5256
PASSPORT_NUMBER("passport_number"),
5357
PASSWORD("password"),
5458
PHONE_NUMBER("phone_number"),
59+
PROJECT("project"),
5560
PHYSICAL_ATTRIBUTE("physical_attribute"),
5661
POLITICAL_AFFILIATION("political_affiliation"),
5762
PRODUCT("product"),
5863
RELIGION("religion"),
5964
ROUTING_NUMBER("routing_number"),
65+
SEXUALITY("sexuality"),
6066
SSN("ssn"),
6167
STATISTICS("statistics"),
6268
TIME("time"),
6369
TREND("trend"),
6470
URL("url"),
6571
USERNAME("username"),
6672
VEHICLE_ID("vehicle_id"),
73+
YEAR("year"),
6774
ZODIAC_SIGN("zodiac_sign");
6875

6976
private final String detectEntities;

src/main/java/com/skyflow/errors/ErrorMessage.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ public enum ErrorMessage {
124124
InvalidRequestBody("%s0 Validation error. Invalid request body. Specify the request body as an object."),
125125
EmptyRequestBody("%s0 Validation error. Request body can't be empty. Specify a valid request body."),
126126

127+
// File upload
128+
ColumnNameKeyErrorFileUpload("%s0 Validation error. columnName is missing from the payload. Specify a columnName key."),
129+
MissingFileSourceInUploadFileRequest("%s0 Validation error. Provide exactly one of filePath, base64, or fileObject."),
130+
FileNameMustBeProvidedWithFileObject("%s0 Validation error. fileName must be provided when using fileObject."),
131+
InvalidFileObject("%s0 Validation error. Invalid file object in file upload request. Specify a valid file object."),
132+
InvalidBase64("%s0 Validation error. Invalid base64 string in file upload request. Specify a valid base64 string."),
133+
127134
// detect
128135
InvalidTextInDeIdentify("%s0 Validation error. The text field is required and must be a non-empty string. Specify a valid text."),
129136
InvalidTextInReIdentify("%s0 Validation error. The text field is required and must be a non-empty string. Specify a valid text."),
@@ -144,6 +151,7 @@ public enum ErrorMessage {
144151
FailedToEncodeFile("%s0 Validation error. Failed to encode the file. Ensure the file is in a supported format and try again."),
145152
FailedToDecodeFileFromResponse("%s0 Failed to decode the file from the response. Ensure the response is valid and try again."),
146153
EmptyFileAndFilePathInDeIdentifyFile("%s0 Validation error. Both file and filePath are empty. Specify either file object or filePath, not both."),
154+
VaultTokenFormatIsNotAllowedForFiles("%s0 Validation error. Vault token format is not allowed for deidentify file request."),
147155
PollingForResultsFailed("%s0 API error. Polling for results failed. Unable to retrieve the deidentified file"),
148156
FailedtoSaveProcessedFile("%s0 Validation error. Failed to save the processed file. Ensure the output directory is valid and writable."),
149157
InvalidAudioFileType("%s0 Validation error. The file type is not supported. Specify a valid file type mp3 or wav."),

src/main/java/com/skyflow/generated/rest/ApiClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import com.skyflow.generated.rest.resources.audit.AuditClient;
99
import com.skyflow.generated.rest.resources.authentication.AuthenticationClient;
1010
import com.skyflow.generated.rest.resources.binlookup.BinLookupClient;
11-
import com.skyflow.generated.rest.resources.deprecated.DeprecatedClient;
1211
import com.skyflow.generated.rest.resources.files.FilesClient;
12+
import com.skyflow.generated.rest.resources.guardrails.GuardrailsClient;
1313
import com.skyflow.generated.rest.resources.query.QueryClient;
1414
import com.skyflow.generated.rest.resources.records.RecordsClient;
1515
import com.skyflow.generated.rest.resources.strings.StringsClient;
@@ -31,7 +31,7 @@ public class ApiClient {
3131

3232
protected final Supplier<AuthenticationClient> authenticationClient;
3333

34-
protected final Supplier<DeprecatedClient> deprecatedClient;
34+
protected final Supplier<GuardrailsClient> guardrailsClient;
3535

3636
protected final Supplier<StringsClient> stringsClient;
3737

@@ -45,7 +45,7 @@ public ApiClient(ClientOptions clientOptions) {
4545
this.tokensClient = Suppliers.memoize(() -> new TokensClient(clientOptions));
4646
this.queryClient = Suppliers.memoize(() -> new QueryClient(clientOptions));
4747
this.authenticationClient = Suppliers.memoize(() -> new AuthenticationClient(clientOptions));
48-
this.deprecatedClient = Suppliers.memoize(() -> new DeprecatedClient(clientOptions));
48+
this.guardrailsClient = Suppliers.memoize(() -> new GuardrailsClient(clientOptions));
4949
this.stringsClient = Suppliers.memoize(() -> new StringsClient(clientOptions));
5050
this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions));
5151
}
@@ -74,8 +74,8 @@ public AuthenticationClient authentication() {
7474
return this.authenticationClient.get();
7575
}
7676

77-
public DeprecatedClient deprecated() {
78-
return this.deprecatedClient.get();
77+
public GuardrailsClient guardrails() {
78+
return this.guardrailsClient.get();
7979
}
8080

8181
public StringsClient strings() {

0 commit comments

Comments
 (0)