diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index c723914a..13fcf623 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -7,12 +7,12 @@ jobs: uses: ./.github/workflows/shared-build-and-deploy.yml with: ref: ${{ github.ref_name }} - server-id: ossrh + server-id: central profile: maven-central tag: 'beta' secrets: - server-username: ${{ secrets.OSSRH_USERNAME }} - server-password: ${{ secrets.OSSRH_PASSWORD }} + server-username: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_USERNAME }} + server-password: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_PASSWORD }} gpg-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }} >> .env diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3883a1a9..2b2945f0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-java@v1 with: - java-version: "1.8" + java-version: "11" - name: create-json id: create-json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 855b7b4c..1cc20ca1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,12 +7,12 @@ jobs: uses: ./.github/workflows/shared-build-and-deploy.yml with: ref: ${{ github.ref_name }} - server-id: ossrh + server-id: central profile: maven-central tag: 'public' secrets: - server-username: ${{ secrets.OSSRH_USERNAME }} - server-password: ${{ secrets.OSSRH_PASSWORD }} + server-username: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_USERNAME }} + server-password: ${{ secrets.CENTRAL_PUBLISHER_PORTAL_PASSWORD }} gpg-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }} >> .env diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index c9cadd2c..13fd1b5b 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -52,9 +52,9 @@ jobs: fetch-depth: 0 - name: Set up maven or jfrog repository - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: "1.8" + java-version: "11" distribution: "adopt" server-id: ${{ inputs.server-id }} server-username: SERVER_USERNAME diff --git a/pom.xml b/pom.xml index 832fd901..fb6a5d0e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow-java - 2.0.0-beta.2 + 2.0.0-beta.4 jar ${project.groupId}:${project.artifactId} @@ -45,12 +45,6 @@ - - com.squareup.okhttp3 - okhttp - 4.12.0 - compile - com.fasterxml.jackson.core jackson-databind @@ -126,9 +120,10 @@ junit junit - ${junit-version} + 4.13.2 test + org.powermock powermock-module-junit4 @@ -141,12 +136,6 @@ 2.0.9 test - - org.junit.jupiter - junit-jupiter - 5.13.2 - compile - @@ -185,7 +174,14 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.2.5 + + false + + **/*Test.java + **/*Tests.java + + org.jacoco @@ -263,25 +259,25 @@ maven-central - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 + central + https://central.sonatype.com/api/v1/publisher/upload - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots + central-snapshots + https://central.sonatype.com/api/v1/publisher/upload - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 + org.sonatype.central + central-publishing-maven-plugin + 0.4.0 true - ossrh - https://s01.oss.sonatype.org/ - true + central + true + true diff --git a/src/main/java/com/skyflow/VaultClient.java b/src/main/java/com/skyflow/VaultClient.java index 7536a2c1..edb8ee47 100644 --- a/src/main/java/com/skyflow/VaultClient.java +++ b/src/main/java/com/skyflow/VaultClient.java @@ -17,6 +17,7 @@ import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody; +import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request; import com.skyflow.generated.rest.resources.strings.StringsClient; import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; @@ -32,6 +33,7 @@ import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.data.FileUploadRequest; import com.skyflow.vault.data.InsertRequest; import com.skyflow.vault.data.UpdateRequest; import com.skyflow.vault.detect.*; @@ -44,6 +46,10 @@ import io.github.cdimascio.dotenv.Dotenv; import io.github.cdimascio.dotenv.DotenvException; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; @@ -209,6 +215,22 @@ protected V1TokenizePayload getTokenizePayload(TokenizeRequest request) { return payloadBuilder.build(); } + protected File getFileForFileUpload(FileUploadRequest fileUploadRequest) throws IOException { + if (fileUploadRequest.getFilePath() != null) { + return new File(fileUploadRequest.getFilePath()); + } + else if (fileUploadRequest.getBase64() != null) { + byte[] decodedBytes = Base64.getDecoder().decode(fileUploadRequest.getBase64()); + File file = new File(fileUploadRequest.getFileName()); + Files.write(file.toPath(), decodedBytes); + return file; + } + else if (fileUploadRequest.getFileObject() != null) { + return fileUploadRequest.getFileObject(); + } + return null; + } + protected void setBearerToken() throws SkyflowException { prioritiseCredentials(); Validations.validateCredentials(this.finalCredentials); @@ -512,7 +534,6 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req Optional> entityUniqueCounter = Optional.empty(); Optional> allowRegex = Optional.ofNullable(request.getAllowRegexList()); Optional> restrictRegex = Optional.ofNullable(request.getRestrictRegexList()); - Optional transformations = Optional.ofNullable(getTransformations(request.getTransformations())); if (tokenFormat != null) { if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) { @@ -540,13 +561,12 @@ protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest req return DeidentifyPdfRequest.builder() .vaultId(vaultId) .file(file) - .density(request.getPixelDensity() != null ? request.getPixelDensity().intValue() : null) - .maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().intValue() : null) + .density(request.getPixelDensity() != null ? request.getPixelDensity().doubleValue() : null) + .maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().doubleValue() : null) .entityTypes(mappedEntityTypes) .tokenType(tokenType) .allowRegex(allowRegex) .restrictRegex(restrictRegex) - .transformations(transformations) .build(); } @@ -558,7 +578,6 @@ protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest Optional> entityUniqueCounter = Optional.empty(); Optional> allowRegex = Optional.ofNullable(request.getAllowRegexList()); Optional> restrictRegex = Optional.ofNullable(request.getRestrictRegexList()); - Optional transformations = Optional.ofNullable(getTransformations(request.getTransformations())); TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter); @@ -580,7 +599,6 @@ protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest .tokenType(tokenType) .allowRegex(allowRegex) .restrictRegex(restrictRegex) - .transformations(transformations) .outputProcessedImage(request.getOutputProcessedImage()) .outputOcrText(request.getOutputOcrText()) .build(); @@ -594,7 +612,6 @@ protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(Deident Optional> entityUniqueCounter = Optional.empty(); Optional> allowRegex = Optional.ofNullable(request.getAllowRegexList()); Optional> restrictRegex = Optional.ofNullable(request.getRestrictRegexList()); - Optional transformations = Optional.ofNullable(getTransformations(request.getTransformations())); TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter); @@ -610,7 +627,6 @@ protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(Deident .tokenType(tokenType) .allowRegex(allowRegex) .restrictRegex(restrictRegex) - .transformations(transformations) .build(); } @@ -622,7 +638,6 @@ protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(Deidentif Optional> entityUniqueCounter = Optional.empty(); Optional> allowRegex = Optional.ofNullable(request.getAllowRegexList()); Optional> restrictRegex = Optional.ofNullable(request.getRestrictRegexList()); - Optional transformations = Optional.ofNullable(getTransformations(request.getTransformations())); TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter); @@ -638,7 +653,6 @@ protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(Deidentif .tokenType(tokenType) .allowRegex(allowRegex) .restrictRegex(restrictRegex) - .transformations(transformations) .build(); } @@ -678,7 +692,6 @@ protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileR Optional> entityUniqueCounter = Optional.empty(); Optional> allowRegex = Optional.ofNullable(request.getAllowRegexList()); Optional> restrictRegex = Optional.ofNullable(request.getRestrictRegexList()); - Optional transformations = Optional.ofNullable(getTransformations(request.getTransformations())); TokenTypeWithoutVault tokenType = buildTokenType(tokenFormat, entityTypes, entityUniqueCounter); @@ -694,7 +707,6 @@ protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileR .tokenType(tokenType) .allowRegex(allowRegex) .restrictRegex(restrictRegex) - .transformations(transformations) .build(); } diff --git a/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java b/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java index e17c6d0c..87ffc109 100644 --- a/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java +++ b/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java @@ -2,7 +2,9 @@ public enum DeidentifyFileStatus { IN_PROGRESS("IN_PROGRESS"), - SUCCESS("SUCCESS"); + FAILED("FAILED"), + SUCCESS("SUCCESS"), + UNKNOWN("UNKNOWN"); private final String value; diff --git a/src/main/java/com/skyflow/enums/DetectEntities.java b/src/main/java/com/skyflow/enums/DetectEntities.java index f2c21eff..3fd15a67 100644 --- a/src/main/java/com/skyflow/enums/DetectEntities.java +++ b/src/main/java/com/skyflow/enums/DetectEntities.java @@ -13,17 +13,19 @@ public enum DetectEntities { CREDIT_CARD_EXPIRATION("credit_card_expiration"), CVV("cvv"), DATE("date"), + DAY("day"), DATE_INTERVAL("date_interval"), DOB("dob"), DOSE("dose"), DRIVER_LICENSE("driver_license"), DRUG("drug"), DURATION("duration"), + EFFECT("effect"), EMAIL_ADDRESS("email_address"), EVENT("event"), FILENAME("filename"), FINANCIAL_METRIC("financial_metric"), - GENDER_SEXUALITY("gender_sexuality"), + GENDER("gender"), HEALTHCARE_NUMBER("healthcare_number"), INJURY("injury"), IP_ADDRESS("ip_address"), @@ -40,6 +42,7 @@ public enum DetectEntities { MEDICAL_CODE("medical_code"), MEDICAL_PROCESS("medical_process"), MONEY("money"), + MONTH("month"), NAME("name"), NAME_FAMILY("name_family"), NAME_GIVEN("name_given"), @@ -47,16 +50,19 @@ public enum DetectEntities { NUMERICAL_PII("numerical_pii"), OCCUPATION("occupation"), ORGANIZATION("organization"), + ORGANIZATION_ID("organization_id"), ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), ORIGIN("origin"), PASSPORT_NUMBER("passport_number"), PASSWORD("password"), PHONE_NUMBER("phone_number"), + PROJECT("project"), PHYSICAL_ATTRIBUTE("physical_attribute"), POLITICAL_AFFILIATION("political_affiliation"), PRODUCT("product"), RELIGION("religion"), ROUTING_NUMBER("routing_number"), + SEXUALITY("sexuality"), SSN("ssn"), STATISTICS("statistics"), TIME("time"), @@ -64,6 +70,7 @@ public enum DetectEntities { URL("url"), USERNAME("username"), VEHICLE_ID("vehicle_id"), + YEAR("year"), ZODIAC_SIGN("zodiac_sign"); private final String detectEntities; diff --git a/src/main/java/com/skyflow/errors/ErrorMessage.java b/src/main/java/com/skyflow/errors/ErrorMessage.java index df075bca..ac6adfd0 100644 --- a/src/main/java/com/skyflow/errors/ErrorMessage.java +++ b/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -124,6 +124,13 @@ public enum ErrorMessage { InvalidRequestBody("%s0 Validation error. Invalid request body. Specify the request body as an object."), EmptyRequestBody("%s0 Validation error. Request body can't be empty. Specify a valid request body."), + // File upload + ColumnNameKeyErrorFileUpload("%s0 Validation error. columnName is missing from the payload. Specify a columnName key."), + MissingFileSourceInUploadFileRequest("%s0 Validation error. Provide exactly one of filePath, base64, or fileObject."), + FileNameMustBeProvidedWithFileObject("%s0 Validation error. fileName must be provided when using fileObject."), + InvalidFileObject("%s0 Validation error. Invalid file object in file upload request. Specify a valid file object."), + InvalidBase64("%s0 Validation error. Invalid base64 string in file upload request. Specify a valid base64 string."), + // detect InvalidTextInDeIdentify("%s0 Validation error. The text field is required and must be a non-empty string. Specify a valid text."), 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 { FailedToEncodeFile("%s0 Validation error. Failed to encode the file. Ensure the file is in a supported format and try again."), FailedToDecodeFileFromResponse("%s0 Failed to decode the file from the response. Ensure the response is valid and try again."), EmptyFileAndFilePathInDeIdentifyFile("%s0 Validation error. Both file and filePath are empty. Specify either file object or filePath, not both."), + VaultTokenFormatIsNotAllowedForFiles("%s0 Validation error. Vault token format is not allowed for deidentify file request."), PollingForResultsFailed("%s0 API error. Polling for results failed. Unable to retrieve the deidentified file"), FailedtoSaveProcessedFile("%s0 Validation error. Failed to save the processed file. Ensure the output directory is valid and writable."), InvalidAudioFileType("%s0 Validation error. The file type is not supported. Specify a valid file type mp3 or wav."), diff --git a/src/main/java/com/skyflow/generated/rest/ApiClient.java b/src/main/java/com/skyflow/generated/rest/ApiClient.java index 296a553f..7c5ae554 100644 --- a/src/main/java/com/skyflow/generated/rest/ApiClient.java +++ b/src/main/java/com/skyflow/generated/rest/ApiClient.java @@ -8,8 +8,8 @@ import com.skyflow.generated.rest.resources.audit.AuditClient; import com.skyflow.generated.rest.resources.authentication.AuthenticationClient; import com.skyflow.generated.rest.resources.binlookup.BinLookupClient; -import com.skyflow.generated.rest.resources.deprecated.DeprecatedClient; import com.skyflow.generated.rest.resources.files.FilesClient; +import com.skyflow.generated.rest.resources.guardrails.GuardrailsClient; import com.skyflow.generated.rest.resources.query.QueryClient; import com.skyflow.generated.rest.resources.records.RecordsClient; import com.skyflow.generated.rest.resources.strings.StringsClient; @@ -31,7 +31,7 @@ public class ApiClient { protected final Supplier authenticationClient; - protected final Supplier deprecatedClient; + protected final Supplier guardrailsClient; protected final Supplier stringsClient; @@ -45,7 +45,7 @@ public ApiClient(ClientOptions clientOptions) { this.tokensClient = Suppliers.memoize(() -> new TokensClient(clientOptions)); this.queryClient = Suppliers.memoize(() -> new QueryClient(clientOptions)); this.authenticationClient = Suppliers.memoize(() -> new AuthenticationClient(clientOptions)); - this.deprecatedClient = Suppliers.memoize(() -> new DeprecatedClient(clientOptions)); + this.guardrailsClient = Suppliers.memoize(() -> new GuardrailsClient(clientOptions)); this.stringsClient = Suppliers.memoize(() -> new StringsClient(clientOptions)); this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions)); } @@ -74,8 +74,8 @@ public AuthenticationClient authentication() { return this.authenticationClient.get(); } - public DeprecatedClient deprecated() { - return this.deprecatedClient.get(); + public GuardrailsClient guardrails() { + return this.guardrailsClient.get(); } public StringsClient strings() { diff --git a/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java b/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java index d36c8141..1fb7b844 100644 --- a/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java +++ b/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java @@ -8,8 +8,8 @@ import com.skyflow.generated.rest.resources.audit.AsyncAuditClient; import com.skyflow.generated.rest.resources.authentication.AsyncAuthenticationClient; import com.skyflow.generated.rest.resources.binlookup.AsyncBinLookupClient; -import com.skyflow.generated.rest.resources.deprecated.AsyncDeprecatedClient; import com.skyflow.generated.rest.resources.files.AsyncFilesClient; +import com.skyflow.generated.rest.resources.guardrails.AsyncGuardrailsClient; import com.skyflow.generated.rest.resources.query.AsyncQueryClient; import com.skyflow.generated.rest.resources.records.AsyncRecordsClient; import com.skyflow.generated.rest.resources.strings.AsyncStringsClient; @@ -31,7 +31,7 @@ public class AsyncApiClient { protected final Supplier authenticationClient; - protected final Supplier deprecatedClient; + protected final Supplier guardrailsClient; protected final Supplier stringsClient; @@ -45,7 +45,7 @@ public AsyncApiClient(ClientOptions clientOptions) { this.tokensClient = Suppliers.memoize(() -> new AsyncTokensClient(clientOptions)); this.queryClient = Suppliers.memoize(() -> new AsyncQueryClient(clientOptions)); this.authenticationClient = Suppliers.memoize(() -> new AsyncAuthenticationClient(clientOptions)); - this.deprecatedClient = Suppliers.memoize(() -> new AsyncDeprecatedClient(clientOptions)); + this.guardrailsClient = Suppliers.memoize(() -> new AsyncGuardrailsClient(clientOptions)); this.stringsClient = Suppliers.memoize(() -> new AsyncStringsClient(clientOptions)); this.filesClient = Suppliers.memoize(() -> new AsyncFilesClient(clientOptions)); } @@ -74,8 +74,8 @@ public AsyncAuthenticationClient authentication() { return this.authenticationClient.get(); } - public AsyncDeprecatedClient deprecated() { - return this.deprecatedClient.get(); + public AsyncGuardrailsClient guardrails() { + return this.guardrailsClient.get(); } public AsyncStringsClient strings() { diff --git a/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java b/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java index badaddd3..fe635bf1 100644 --- a/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java +++ b/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java @@ -34,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.219"); + put("X-Fern-SDK-Version", "0.0.322"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java b/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java deleted file mode 100644 index c5728721..00000000 --- a/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java +++ /dev/null @@ -1,339 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.core; - -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import okhttp3.HttpUrl; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public final class QueryStringMapperTest { - @Test - public void testObjectWithQuotedString_indexedArrays() { - Map map = new HashMap() { - { - put("hello", "\"world\""); - } - }; - - String expectedQueryString = "withquoted%5Bhello%5D=%22world%22"; - - String actualQueryString = queryString( - new HashMap() { - { - put("withquoted", map); - } - }, - false); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObjectWithQuotedString_arraysAsRepeats() { - Map map = new HashMap() { - { - put("hello", "\"world\""); - } - }; - - String expectedQueryString = "withquoted%5Bhello%5D=%22world%22"; - - String actualQueryString = queryString( - new HashMap() { - { - put("withquoted", map); - } - }, - true); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObject_indexedArrays() { - Map map = new HashMap() { - { - put("foo", "bar"); - put("baz", "qux"); - } - }; - - String expectedQueryString = "metadata%5Bfoo%5D=bar&metadata%5Bbaz%5D=qux"; - - String actualQueryString = queryString( - new HashMap() { - { - put("metadata", map); - } - }, - false); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObject_arraysAsRepeats() { - Map map = new HashMap() { - { - put("foo", "bar"); - put("baz", "qux"); - } - }; - - String expectedQueryString = "metadata%5Bfoo%5D=bar&metadata%5Bbaz%5D=qux"; - - String actualQueryString = queryString( - new HashMap() { - { - put("metadata", map); - } - }, - true); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testNestedObject_indexedArrays() { - Map> nestedMap = new HashMap>() { - { - put("mapkey1", new HashMap() { - { - put("mapkey1mapkey1", "mapkey1mapkey1value"); - put("mapkey1mapkey2", "mapkey1mapkey2value"); - } - }); - put("mapkey2", new HashMap() { - { - put("mapkey2mapkey1", "mapkey2mapkey1value"); - } - }); - } - }; - - String expectedQueryString = - "nested%5Bmapkey2%5D%5Bmapkey2mapkey1%5D=mapkey2mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey1" - + "%5D=mapkey1mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey2%5D=mapkey1mapkey2value"; - - String actualQueryString = queryString( - new HashMap() { - { - put("nested", nestedMap); - } - }, - false); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testNestedObject_arraysAsRepeats() { - Map> nestedMap = new HashMap>() { - { - put("mapkey1", new HashMap() { - { - put("mapkey1mapkey1", "mapkey1mapkey1value"); - put("mapkey1mapkey2", "mapkey1mapkey2value"); - } - }); - put("mapkey2", new HashMap() { - { - put("mapkey2mapkey1", "mapkey2mapkey1value"); - } - }); - } - }; - - String expectedQueryString = - "nested%5Bmapkey2%5D%5Bmapkey2mapkey1%5D=mapkey2mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey1" - + "%5D=mapkey1mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey2%5D=mapkey1mapkey2value"; - - String actualQueryString = queryString( - new HashMap() { - { - put("nested", nestedMap); - } - }, - true); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testDateTime_indexedArrays() { - OffsetDateTime dateTime = - OffsetDateTime.ofInstant(Instant.ofEpochSecond(1740412107L), ZoneId.of("America/New_York")); - - String expectedQueryString = "datetime=2025-02-24T10%3A48%3A27-05%3A00"; - - String actualQueryString = queryString( - new HashMap() { - { - put("datetime", dateTime); - } - }, - false); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testDateTime_arraysAsRepeats() { - OffsetDateTime dateTime = - OffsetDateTime.ofInstant(Instant.ofEpochSecond(1740412107L), ZoneId.of("America/New_York")); - - String expectedQueryString = "datetime=2025-02-24T10%3A48%3A27-05%3A00"; - - String actualQueryString = queryString( - new HashMap() { - { - put("datetime", dateTime); - } - }, - true); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObjectArray_indexedArrays() { - List> mapArray = new ArrayList>() { - { - add(new HashMap() { - { - put("key", "hello"); - put("value", "world"); - } - }); - add(new HashMap() { - { - put("key", "foo"); - put("value", "bar"); - } - }); - add(new HashMap<>()); - } - }; - - String expectedQueryString = "objects%5B0%5D%5Bvalue%5D=world&objects%5B0%5D%5Bkey%5D=hello&objects%5B1%5D" - + "%5Bvalue%5D=bar&objects%5B1%5D%5Bkey%5D=foo"; - - String actualQueryString = queryString( - new HashMap() { - { - put("objects", mapArray); - } - }, - false); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObjectArray_arraysAsRepeats() { - List> mapArray = new ArrayList>() { - { - add(new HashMap() { - { - put("key", "hello"); - put("value", "world"); - } - }); - add(new HashMap() { - { - put("key", "foo"); - put("value", "bar"); - } - }); - add(new HashMap<>()); - } - }; - - String expectedQueryString = - "objects%5Bvalue%5D=world&objects%5Bkey%5D=hello&objects%5Bvalue" + "%5D=bar&objects%5Bkey%5D=foo"; - - String actualQueryString = queryString( - new HashMap() { - { - put("objects", mapArray); - } - }, - true); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObjectWithArray_indexedArrays() { - Map objectWithArray = new HashMap() { - { - put("id", "abc123"); - put("contactIds", new ArrayList() { - { - add("id1"); - add("id2"); - add("id3"); - } - }); - } - }; - - String expectedQueryString = - "objectwitharray%5Bid%5D=abc123&objectwitharray%5BcontactIds%5D%5B0%5D=id1&objectwitharray" - + "%5BcontactIds%5D%5B1%5D=id2&objectwitharray%5BcontactIds%5D%5B2%5D=id3"; - - String actualQueryString = queryString( - new HashMap() { - { - put("objectwitharray", objectWithArray); - } - }, - false); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - @Test - public void testObjectWithArray_arraysAsRepeats() { - Map objectWithArray = new HashMap() { - { - put("id", "abc123"); - put("contactIds", new ArrayList() { - { - add("id1"); - add("id2"); - add("id3"); - } - }); - } - }; - - String expectedQueryString = "objectwitharray%5Bid%5D=abc123&objectwitharray%5BcontactIds" - + "%5D=id1&objectwitharray%5BcontactIds%5D=id2&objectwitharray%5BcontactIds%5D=id3"; - - String actualQueryString = queryString( - new HashMap() { - { - put("objectwitharray", objectWithArray); - } - }, - true); - - Assertions.assertEquals(expectedQueryString, actualQueryString); - } - - private static String queryString(Map params, boolean arraysAsRepeats) { - HttpUrl.Builder httpUrl = HttpUrl.parse("http://www.fakewebsite.com/").newBuilder(); - params.forEach((paramName, paramValue) -> - QueryStringMapper.addQueryParameter(httpUrl, paramName, paramValue, arraysAsRepeats)); - return httpUrl.build().encodedQuery(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java deleted file mode 100644 index c1709f7f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectStatusRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectTextRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.V1DetectFileRequest; -import com.skyflow.generated.rest.types.V1DetectFileResponse; -import com.skyflow.generated.rest.types.V1DetectStatusResponse; -import com.skyflow.generated.rest.types.V1DetectTextResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncDeprecatedClient { - protected final ClientOptions clientOptions; - - private final AsyncRawDeprecatedClient rawClient; - - public AsyncDeprecatedClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawDeprecatedClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawDeprecatedClient withRawResponse() { - return this.rawClient; - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public CompletableFuture detectServiceDetectFileInput(V1DetectFileRequest request) { - return this.rawClient.detectServiceDetectFileInput(request).thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public CompletableFuture detectServiceDetectFileInput( - V1DetectFileRequest request, RequestOptions requestOptions) { - return this.rawClient - .detectServiceDetectFileInput(request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public CompletableFuture detectServiceDetectStatus(String id) { - return this.rawClient.detectServiceDetectStatus(id).thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public CompletableFuture detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request) { - return this.rawClient.detectServiceDetectStatus(id, request).thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public CompletableFuture detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request, RequestOptions requestOptions) { - return this.rawClient - .detectServiceDetectStatus(id, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public CompletableFuture detectServiceDetectText(DetectServiceDetectTextRequest request) { - return this.rawClient.detectServiceDetectText(request).thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public CompletableFuture detectServiceDetectText( - DetectServiceDetectTextRequest request, RequestOptions requestOptions) { - return this.rawClient.detectServiceDetectText(request, requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java deleted file mode 100644 index 9c9ec79a..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java +++ /dev/null @@ -1,271 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.rest.core.ApiClientApiException; -import com.skyflow.generated.rest.core.ApiClientException; -import com.skyflow.generated.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.MediaTypes; -import com.skyflow.generated.rest.core.ObjectMappers; -import com.skyflow.generated.rest.core.QueryStringMapper; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.errors.NotFoundError; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectStatusRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectTextRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.V1DetectFileRequest; -import com.skyflow.generated.rest.types.V1DetectFileResponse; -import com.skyflow.generated.rest.types.V1DetectStatusResponse; -import com.skyflow.generated.rest.types.V1DetectTextResponse; -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; -import org.jetbrains.annotations.NotNull; - -public class AsyncRawDeprecatedClient { - protected final ClientOptions clientOptions; - - public AsyncRawDeprecatedClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public CompletableFuture> detectServiceDetectFileInput( - V1DetectFileRequest request) { - return detectServiceDetectFileInput(request, null); - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public CompletableFuture> detectServiceDetectFileInput( - V1DetectFileRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/file") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new ApiClientException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - CompletableFuture> future = new CompletableFuture<>(); - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - future.complete(new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), V1DetectFileResponse.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); - return; - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - future.completeExceptionally(new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); - } - }); - return future; - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public CompletableFuture> detectServiceDetectStatus(String id) { - return detectServiceDetectStatus( - id, DetectServiceDetectStatusRequest.builder().build()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public CompletableFuture> detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request) { - return detectServiceDetectStatus(id, request, null); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public CompletableFuture> detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/status") - .addPathSegment(id); - if (request.getVaultId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "vault_id", request.getVaultId().get(), false); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - CompletableFuture> future = new CompletableFuture<>(); - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - future.complete(new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), V1DetectStatusResponse.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); - return; - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - future.completeExceptionally(new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); - } - }); - return future; - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public CompletableFuture> detectServiceDetectText( - DetectServiceDetectTextRequest request) { - return detectServiceDetectText(request, null); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public CompletableFuture> detectServiceDetectText( - DetectServiceDetectTextRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/text") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new ApiClientException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - CompletableFuture> future = new CompletableFuture<>(); - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - future.complete(new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), V1DetectTextResponse.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); - return; - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - future.completeExceptionally(new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); - } - }); - return future; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java deleted file mode 100644 index 820a349b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectStatusRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectTextRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.V1DetectFileRequest; -import com.skyflow.generated.rest.types.V1DetectFileResponse; -import com.skyflow.generated.rest.types.V1DetectStatusResponse; -import com.skyflow.generated.rest.types.V1DetectTextResponse; - -public class DeprecatedClient { - protected final ClientOptions clientOptions; - - private final RawDeprecatedClient rawClient; - - public DeprecatedClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawDeprecatedClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawDeprecatedClient withRawResponse() { - return this.rawClient; - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public V1DetectFileResponse detectServiceDetectFileInput(V1DetectFileRequest request) { - return this.rawClient.detectServiceDetectFileInput(request).body(); - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public V1DetectFileResponse detectServiceDetectFileInput( - V1DetectFileRequest request, RequestOptions requestOptions) { - return this.rawClient - .detectServiceDetectFileInput(request, requestOptions) - .body(); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public V1DetectStatusResponse detectServiceDetectStatus(String id) { - return this.rawClient.detectServiceDetectStatus(id).body(); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public V1DetectStatusResponse detectServiceDetectStatus(String id, DetectServiceDetectStatusRequest request) { - return this.rawClient.detectServiceDetectStatus(id, request).body(); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public V1DetectStatusResponse detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request, RequestOptions requestOptions) { - return this.rawClient - .detectServiceDetectStatus(id, request, requestOptions) - .body(); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public V1DetectTextResponse detectServiceDetectText(DetectServiceDetectTextRequest request) { - return this.rawClient.detectServiceDetectText(request).body(); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public V1DetectTextResponse detectServiceDetectText( - DetectServiceDetectTextRequest request, RequestOptions requestOptions) { - return this.rawClient.detectServiceDetectText(request, requestOptions).body(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java deleted file mode 100644 index 4472487f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java +++ /dev/null @@ -1,222 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.rest.core.ApiClientApiException; -import com.skyflow.generated.rest.core.ApiClientException; -import com.skyflow.generated.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.MediaTypes; -import com.skyflow.generated.rest.core.ObjectMappers; -import com.skyflow.generated.rest.core.QueryStringMapper; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.errors.NotFoundError; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectStatusRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.DetectServiceDetectTextRequest; -import com.skyflow.generated.rest.resources.deprecated.requests.V1DetectFileRequest; -import com.skyflow.generated.rest.types.V1DetectFileResponse; -import com.skyflow.generated.rest.types.V1DetectStatusResponse; -import com.skyflow.generated.rest.types.V1DetectTextResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawDeprecatedClient { - protected final ClientOptions clientOptions; - - public RawDeprecatedClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public ApiClientHttpResponse detectServiceDetectFileInput(V1DetectFileRequest request) { - return detectServiceDetectFileInput(request, null); - } - - /** - * <b>Note</b>: This operation is deprecated. Use one of the <a href=#De-identify%20File>De-identify File</a> operations.<br/><br/>Detects and deidentifies sensitive data from image, audio, and video files. - */ - public ApiClientHttpResponse detectServiceDetectFileInput( - V1DetectFileRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/file") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new ApiClientException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), V1DetectFileResponse.class), - response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new ApiClientException("Network error executing HTTP request", e); - } - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public ApiClientHttpResponse detectServiceDetectStatus(String id) { - return detectServiceDetectStatus( - id, DetectServiceDetectStatusRequest.builder().build()); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public ApiClientHttpResponse detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request) { - return detectServiceDetectStatus(id, request, null); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#get_detect_run>Get Detect Run</a>.<br/><br/>Returns the status of a file deidentification request. - */ - public ApiClientHttpResponse detectServiceDetectStatus( - String id, DetectServiceDetectStatusRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/status") - .addPathSegment(id); - if (request.getVaultId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "vault_id", request.getVaultId().get(), false); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), V1DetectStatusResponse.class), - response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new ApiClientException("Network error executing HTTP request", e); - } - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public ApiClientHttpResponse detectServiceDetectText(DetectServiceDetectTextRequest request) { - return detectServiceDetectText(request, null); - } - - /** - * <b>Note</b>: This operation is deprecated. Use <a href=#deidentify_string>De-identify String</a>.<br/><br/>Detects and deidentifies sensitive data from text. - */ - public ApiClientHttpResponse detectServiceDetectText( - DetectServiceDetectTextRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/text") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new ApiClientException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), V1DetectTextResponse.class), - response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new ApiClientException("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java deleted file mode 100644 index 45997db3..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DetectServiceDetectStatusRequest.Builder.class) -public final class DetectServiceDetectStatusRequest { - private final Optional vaultId; - - private final Map additionalProperties; - - private DetectServiceDetectStatusRequest(Optional vaultId, Map additionalProperties) { - this.vaultId = vaultId; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the vault. - */ - @JsonProperty("vault_id") - public Optional getVaultId() { - return vaultId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectServiceDetectStatusRequest && equalTo((DetectServiceDetectStatusRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectServiceDetectStatusRequest other) { - return vaultId.equals(other.vaultId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.vaultId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional vaultId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DetectServiceDetectStatusRequest other) { - vaultId(other.getVaultId()); - return this; - } - - /** - *

ID of the vault.

- */ - @JsonSetter(value = "vault_id", nulls = Nulls.SKIP) - public Builder vaultId(Optional vaultId) { - this.vaultId = vaultId; - return this; - } - - public Builder vaultId(String vaultId) { - this.vaultId = Optional.ofNullable(vaultId); - return this; - } - - public DetectServiceDetectStatusRequest build() { - return new DetectServiceDetectStatusRequest(vaultId, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java deleted file mode 100644 index 3c4b4ea2..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java +++ /dev/null @@ -1,526 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import com.skyflow.generated.rest.types.DetectDataAccuracy; -import com.skyflow.generated.rest.types.DetectDataEntities; -import com.skyflow.generated.rest.types.DetectRequestDeidentifyOption; -import com.skyflow.generated.rest.types.V1AdvancedOptions; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DetectServiceDetectTextRequest.Builder.class) -public final class DetectServiceDetectTextRequest { - private final String text; - - private final String vaultId; - - private final Optional sessionId; - - private final Optional> restrictEntityTypes; - - private final Optional deidentifyTokenFormat; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional returnEntities; - - private final Optional accuracy; - - private final Optional advancedOptions; - - private final Optional storeEntities; - - private final Map additionalProperties; - - private DetectServiceDetectTextRequest( - String text, - String vaultId, - Optional sessionId, - Optional> restrictEntityTypes, - Optional deidentifyTokenFormat, - Optional> allowRegex, - Optional> restrictRegex, - Optional returnEntities, - Optional accuracy, - Optional advancedOptions, - Optional storeEntities, - Map additionalProperties) { - this.text = text; - this.vaultId = vaultId; - this.sessionId = sessionId; - this.restrictEntityTypes = restrictEntityTypes; - this.deidentifyTokenFormat = deidentifyTokenFormat; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.returnEntities = returnEntities; - this.accuracy = accuracy; - this.advancedOptions = advancedOptions; - this.storeEntities = storeEntities; - this.additionalProperties = additionalProperties; - } - - /** - * @return Data to deidentify. - */ - @JsonProperty("text") - public String getText() { - return text; - } - - /** - * @return ID of the vault. - */ - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return Will give a handle to delete the tokens generated during a specific interaction. - */ - @JsonProperty("session_id") - public Optional getSessionId() { - return sessionId; - } - - /** - * @return Entities to detect and deidentify. - */ - @JsonProperty("restrict_entity_types") - public Optional> getRestrictEntityTypes() { - return restrictEntityTypes; - } - - @JsonProperty("deidentify_token_format") - public Optional getDeidentifyTokenFormat() { - return deidentifyTokenFormat; - } - - /** - * @return Regular expressions to ignore when detecting entities. - */ - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - /** - * @return Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'. - */ - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - /** - * @return If true, returns the details for the detected entities. - */ - @JsonProperty("return_entities") - public Optional getReturnEntities() { - return returnEntities; - } - - @JsonProperty("accuracy") - public Optional getAccuracy() { - return accuracy; - } - - @JsonProperty("advanced_options") - public Optional getAdvancedOptions() { - return advancedOptions; - } - - /** - * @return Indicates whether entities should be stored in the vault. - */ - @JsonProperty("store_entities") - public Optional getStoreEntities() { - return storeEntities; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectServiceDetectTextRequest && equalTo((DetectServiceDetectTextRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectServiceDetectTextRequest other) { - return text.equals(other.text) - && vaultId.equals(other.vaultId) - && sessionId.equals(other.sessionId) - && restrictEntityTypes.equals(other.restrictEntityTypes) - && deidentifyTokenFormat.equals(other.deidentifyTokenFormat) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && returnEntities.equals(other.returnEntities) - && accuracy.equals(other.accuracy) - && advancedOptions.equals(other.advancedOptions) - && storeEntities.equals(other.storeEntities); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.text, - this.vaultId, - this.sessionId, - this.restrictEntityTypes, - this.deidentifyTokenFormat, - this.allowRegex, - this.restrictRegex, - this.returnEntities, - this.accuracy, - this.advancedOptions, - this.storeEntities); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TextStage builder() { - return new Builder(); - } - - public interface TextStage { - /** - * Data to deidentify. - */ - VaultIdStage text(@NotNull String text); - - Builder from(DetectServiceDetectTextRequest other); - } - - public interface VaultIdStage { - /** - * ID of the vault. - */ - _FinalStage vaultId(@NotNull String vaultId); - } - - public interface _FinalStage { - DetectServiceDetectTextRequest build(); - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- */ - _FinalStage sessionId(Optional sessionId); - - _FinalStage sessionId(String sessionId); - - /** - *

Entities to detect and deidentify.

- */ - _FinalStage restrictEntityTypes(Optional> restrictEntityTypes); - - _FinalStage restrictEntityTypes(List restrictEntityTypes); - - _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat); - - _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat); - - /** - *

Regular expressions to ignore when detecting entities.

- */ - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- */ - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - /** - *

If true, returns the details for the detected entities.

- */ - _FinalStage returnEntities(Optional returnEntities); - - _FinalStage returnEntities(Boolean returnEntities); - - _FinalStage accuracy(Optional accuracy); - - _FinalStage accuracy(DetectDataAccuracy accuracy); - - _FinalStage advancedOptions(Optional advancedOptions); - - _FinalStage advancedOptions(V1AdvancedOptions advancedOptions); - - /** - *

Indicates whether entities should be stored in the vault.

- */ - _FinalStage storeEntities(Optional storeEntities); - - _FinalStage storeEntities(Boolean storeEntities); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TextStage, VaultIdStage, _FinalStage { - private String text; - - private String vaultId; - - private Optional storeEntities = Optional.empty(); - - private Optional advancedOptions = Optional.empty(); - - private Optional accuracy = Optional.empty(); - - private Optional returnEntities = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional deidentifyTokenFormat = Optional.empty(); - - private Optional> restrictEntityTypes = Optional.empty(); - - private Optional sessionId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DetectServiceDetectTextRequest other) { - text(other.getText()); - vaultId(other.getVaultId()); - sessionId(other.getSessionId()); - restrictEntityTypes(other.getRestrictEntityTypes()); - deidentifyTokenFormat(other.getDeidentifyTokenFormat()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - returnEntities(other.getReturnEntities()); - accuracy(other.getAccuracy()); - advancedOptions(other.getAdvancedOptions()); - storeEntities(other.getStoreEntities()); - return this; - } - - /** - * Data to deidentify.

Data to deidentify.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("text") - public VaultIdStage text(@NotNull String text) { - this.text = Objects.requireNonNull(text, "text must not be null"); - return this; - } - - /** - * ID of the vault.

ID of the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("vault_id") - public _FinalStage vaultId(@NotNull String vaultId) { - this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); - return this; - } - - /** - *

Indicates whether entities should be stored in the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage storeEntities(Boolean storeEntities) { - this.storeEntities = Optional.ofNullable(storeEntities); - return this; - } - - /** - *

Indicates whether entities should be stored in the vault.

- */ - @java.lang.Override - @JsonSetter(value = "store_entities", nulls = Nulls.SKIP) - public _FinalStage storeEntities(Optional storeEntities) { - this.storeEntities = storeEntities; - return this; - } - - @java.lang.Override - public _FinalStage advancedOptions(V1AdvancedOptions advancedOptions) { - this.advancedOptions = Optional.ofNullable(advancedOptions); - return this; - } - - @java.lang.Override - @JsonSetter(value = "advanced_options", nulls = Nulls.SKIP) - public _FinalStage advancedOptions(Optional advancedOptions) { - this.advancedOptions = advancedOptions; - return this; - } - - @java.lang.Override - public _FinalStage accuracy(DetectDataAccuracy accuracy) { - this.accuracy = Optional.ofNullable(accuracy); - return this; - } - - @java.lang.Override - @JsonSetter(value = "accuracy", nulls = Nulls.SKIP) - public _FinalStage accuracy(Optional accuracy) { - this.accuracy = accuracy; - return this; - } - - /** - *

If true, returns the details for the detected entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage returnEntities(Boolean returnEntities) { - this.returnEntities = Optional.ofNullable(returnEntities); - return this; - } - - /** - *

If true, returns the details for the detected entities.

- */ - @java.lang.Override - @JsonSetter(value = "return_entities", nulls = Nulls.SKIP) - public _FinalStage returnEntities(Optional returnEntities) { - this.returnEntities = returnEntities; - return this; - } - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- */ - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - /** - *

Regular expressions to ignore when detecting entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - /** - *

Regular expressions to ignore when detecting entities.

- */ - @java.lang.Override - @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) - public _FinalStage allowRegex(Optional> allowRegex) { - this.allowRegex = allowRegex; - return this; - } - - @java.lang.Override - public _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat) { - this.deidentifyTokenFormat = Optional.ofNullable(deidentifyTokenFormat); - return this; - } - - @java.lang.Override - @JsonSetter(value = "deidentify_token_format", nulls = Nulls.SKIP) - public _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat) { - this.deidentifyTokenFormat = deidentifyTokenFormat; - return this; - } - - /** - *

Entities to detect and deidentify.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage restrictEntityTypes(List restrictEntityTypes) { - this.restrictEntityTypes = Optional.ofNullable(restrictEntityTypes); - return this; - } - - /** - *

Entities to detect and deidentify.

- */ - @java.lang.Override - @JsonSetter(value = "restrict_entity_types", nulls = Nulls.SKIP) - public _FinalStage restrictEntityTypes(Optional> restrictEntityTypes) { - this.restrictEntityTypes = restrictEntityTypes; - return this; - } - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sessionId(String sessionId) { - this.sessionId = Optional.ofNullable(sessionId); - return this; - } - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- */ - @java.lang.Override - @JsonSetter(value = "session_id", nulls = Nulls.SKIP) - public _FinalStage sessionId(Optional sessionId) { - this.sessionId = sessionId; - return this; - } - - @java.lang.Override - public DetectServiceDetectTextRequest build() { - return new DetectServiceDetectTextRequest( - text, - vaultId, - sessionId, - restrictEntityTypes, - deidentifyTokenFormat, - allowRegex, - restrictRegex, - returnEntities, - accuracy, - advancedOptions, - storeEntities, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java b/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java deleted file mode 100644 index 8bdee935..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java +++ /dev/null @@ -1,634 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.deprecated.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import com.skyflow.generated.rest.types.DetectDataAccuracy; -import com.skyflow.generated.rest.types.DetectDataEntities; -import com.skyflow.generated.rest.types.DetectFileRequestDataType; -import com.skyflow.generated.rest.types.DetectRequestDeidentifyOption; -import com.skyflow.generated.rest.types.V1AdvancedOptions; -import com.skyflow.generated.rest.types.V1AudioConfig; -import com.skyflow.generated.rest.types.V1FileDataFormat; -import com.skyflow.generated.rest.types.V1ImageOptions; -import com.skyflow.generated.rest.types.V1PdfConfig; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1DetectFileRequest.Builder.class) -public final class V1DetectFileRequest { - private final String file; - - private final V1FileDataFormat dataFormat; - - private final DetectFileRequestDataType inputType; - - private final String vaultId; - - private final Optional sessionId; - - private final Optional> restrictEntityTypes; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional returnEntities; - - private final Optional accuracy; - - private final Optional audio; - - private final Optional image; - - private final Optional pdf; - - private final Optional advancedOptions; - - private final Optional deidentifyTokenFormat; - - private final Map additionalProperties; - - private V1DetectFileRequest( - String file, - V1FileDataFormat dataFormat, - DetectFileRequestDataType inputType, - String vaultId, - Optional sessionId, - Optional> restrictEntityTypes, - Optional> allowRegex, - Optional> restrictRegex, - Optional returnEntities, - Optional accuracy, - Optional audio, - Optional image, - Optional pdf, - Optional advancedOptions, - Optional deidentifyTokenFormat, - Map additionalProperties) { - this.file = file; - this.dataFormat = dataFormat; - this.inputType = inputType; - this.vaultId = vaultId; - this.sessionId = sessionId; - this.restrictEntityTypes = restrictEntityTypes; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.returnEntities = returnEntities; - this.accuracy = accuracy; - this.audio = audio; - this.image = image; - this.pdf = pdf; - this.advancedOptions = advancedOptions; - this.deidentifyTokenFormat = deidentifyTokenFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Path of the file or base64-encoded data that has to be processed. - */ - @JsonProperty("file") - public String getFile() { - return file; - } - - @JsonProperty("data_format") - public V1FileDataFormat getDataFormat() { - return dataFormat; - } - - @JsonProperty("input_type") - public DetectFileRequestDataType getInputType() { - return inputType; - } - - /** - * @return ID of the vault. - */ - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return Will give a handle to delete the tokens generated during a specific interaction. - */ - @JsonProperty("session_id") - public Optional getSessionId() { - return sessionId; - } - - /** - * @return Entities to detect and deidentify. - */ - @JsonProperty("restrict_entity_types") - public Optional> getRestrictEntityTypes() { - return restrictEntityTypes; - } - - /** - * @return Regular expressions to ignore when detecting entities. - */ - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - /** - * @return Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'. - */ - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - /** - * @return If true, returns the details for the detected entities. - */ - @JsonProperty("return_entities") - public Optional getReturnEntities() { - return returnEntities; - } - - @JsonProperty("accuracy") - public Optional getAccuracy() { - return accuracy; - } - - @JsonProperty("audio") - public Optional getAudio() { - return audio; - } - - @JsonProperty("image") - public Optional getImage() { - return image; - } - - @JsonProperty("pdf") - public Optional getPdf() { - return pdf; - } - - @JsonProperty("advanced_options") - public Optional getAdvancedOptions() { - return advancedOptions; - } - - @JsonProperty("deidentify_token_format") - public Optional getDeidentifyTokenFormat() { - return deidentifyTokenFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetectFileRequest && equalTo((V1DetectFileRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetectFileRequest other) { - return file.equals(other.file) - && dataFormat.equals(other.dataFormat) - && inputType.equals(other.inputType) - && vaultId.equals(other.vaultId) - && sessionId.equals(other.sessionId) - && restrictEntityTypes.equals(other.restrictEntityTypes) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && returnEntities.equals(other.returnEntities) - && accuracy.equals(other.accuracy) - && audio.equals(other.audio) - && image.equals(other.image) - && pdf.equals(other.pdf) - && advancedOptions.equals(other.advancedOptions) - && deidentifyTokenFormat.equals(other.deidentifyTokenFormat); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.file, - this.dataFormat, - this.inputType, - this.vaultId, - this.sessionId, - this.restrictEntityTypes, - this.allowRegex, - this.restrictRegex, - this.returnEntities, - this.accuracy, - this.audio, - this.image, - this.pdf, - this.advancedOptions, - this.deidentifyTokenFormat); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static FileStage builder() { - return new Builder(); - } - - public interface FileStage { - /** - * Path of the file or base64-encoded data that has to be processed. - */ - DataFormatStage file(@NotNull String file); - - Builder from(V1DetectFileRequest other); - } - - public interface DataFormatStage { - InputTypeStage dataFormat(@NotNull V1FileDataFormat dataFormat); - } - - public interface InputTypeStage { - VaultIdStage inputType(@NotNull DetectFileRequestDataType inputType); - } - - public interface VaultIdStage { - /** - * ID of the vault. - */ - _FinalStage vaultId(@NotNull String vaultId); - } - - public interface _FinalStage { - V1DetectFileRequest build(); - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- */ - _FinalStage sessionId(Optional sessionId); - - _FinalStage sessionId(String sessionId); - - /** - *

Entities to detect and deidentify.

- */ - _FinalStage restrictEntityTypes(Optional> restrictEntityTypes); - - _FinalStage restrictEntityTypes(List restrictEntityTypes); - - /** - *

Regular expressions to ignore when detecting entities.

- */ - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- */ - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - /** - *

If true, returns the details for the detected entities.

- */ - _FinalStage returnEntities(Optional returnEntities); - - _FinalStage returnEntities(Boolean returnEntities); - - _FinalStage accuracy(Optional accuracy); - - _FinalStage accuracy(DetectDataAccuracy accuracy); - - _FinalStage audio(Optional audio); - - _FinalStage audio(V1AudioConfig audio); - - _FinalStage image(Optional image); - - _FinalStage image(V1ImageOptions image); - - _FinalStage pdf(Optional pdf); - - _FinalStage pdf(V1PdfConfig pdf); - - _FinalStage advancedOptions(Optional advancedOptions); - - _FinalStage advancedOptions(V1AdvancedOptions advancedOptions); - - _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat); - - _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements FileStage, DataFormatStage, InputTypeStage, VaultIdStage, _FinalStage { - private String file; - - private V1FileDataFormat dataFormat; - - private DetectFileRequestDataType inputType; - - private String vaultId; - - private Optional deidentifyTokenFormat = Optional.empty(); - - private Optional advancedOptions = Optional.empty(); - - private Optional pdf = Optional.empty(); - - private Optional image = Optional.empty(); - - private Optional audio = Optional.empty(); - - private Optional accuracy = Optional.empty(); - - private Optional returnEntities = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional> restrictEntityTypes = Optional.empty(); - - private Optional sessionId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(V1DetectFileRequest other) { - file(other.getFile()); - dataFormat(other.getDataFormat()); - inputType(other.getInputType()); - vaultId(other.getVaultId()); - sessionId(other.getSessionId()); - restrictEntityTypes(other.getRestrictEntityTypes()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - returnEntities(other.getReturnEntities()); - accuracy(other.getAccuracy()); - audio(other.getAudio()); - image(other.getImage()); - pdf(other.getPdf()); - advancedOptions(other.getAdvancedOptions()); - deidentifyTokenFormat(other.getDeidentifyTokenFormat()); - return this; - } - - /** - * Path of the file or base64-encoded data that has to be processed.

Path of the file or base64-encoded data that has to be processed.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public DataFormatStage file(@NotNull String file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("data_format") - public InputTypeStage dataFormat(@NotNull V1FileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("input_type") - public VaultIdStage inputType(@NotNull DetectFileRequestDataType inputType) { - this.inputType = Objects.requireNonNull(inputType, "inputType must not be null"); - return this; - } - - /** - * ID of the vault.

ID of the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("vault_id") - public _FinalStage vaultId(@NotNull String vaultId) { - this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat) { - this.deidentifyTokenFormat = Optional.ofNullable(deidentifyTokenFormat); - return this; - } - - @java.lang.Override - @JsonSetter(value = "deidentify_token_format", nulls = Nulls.SKIP) - public _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat) { - this.deidentifyTokenFormat = deidentifyTokenFormat; - return this; - } - - @java.lang.Override - public _FinalStage advancedOptions(V1AdvancedOptions advancedOptions) { - this.advancedOptions = Optional.ofNullable(advancedOptions); - return this; - } - - @java.lang.Override - @JsonSetter(value = "advanced_options", nulls = Nulls.SKIP) - public _FinalStage advancedOptions(Optional advancedOptions) { - this.advancedOptions = advancedOptions; - return this; - } - - @java.lang.Override - public _FinalStage pdf(V1PdfConfig pdf) { - this.pdf = Optional.ofNullable(pdf); - return this; - } - - @java.lang.Override - @JsonSetter(value = "pdf", nulls = Nulls.SKIP) - public _FinalStage pdf(Optional pdf) { - this.pdf = pdf; - return this; - } - - @java.lang.Override - public _FinalStage image(V1ImageOptions image) { - this.image = Optional.ofNullable(image); - return this; - } - - @java.lang.Override - @JsonSetter(value = "image", nulls = Nulls.SKIP) - public _FinalStage image(Optional image) { - this.image = image; - return this; - } - - @java.lang.Override - public _FinalStage audio(V1AudioConfig audio) { - this.audio = Optional.ofNullable(audio); - return this; - } - - @java.lang.Override - @JsonSetter(value = "audio", nulls = Nulls.SKIP) - public _FinalStage audio(Optional audio) { - this.audio = audio; - return this; - } - - @java.lang.Override - public _FinalStage accuracy(DetectDataAccuracy accuracy) { - this.accuracy = Optional.ofNullable(accuracy); - return this; - } - - @java.lang.Override - @JsonSetter(value = "accuracy", nulls = Nulls.SKIP) - public _FinalStage accuracy(Optional accuracy) { - this.accuracy = accuracy; - return this; - } - - /** - *

If true, returns the details for the detected entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage returnEntities(Boolean returnEntities) { - this.returnEntities = Optional.ofNullable(returnEntities); - return this; - } - - /** - *

If true, returns the details for the detected entities.

- */ - @java.lang.Override - @JsonSetter(value = "return_entities", nulls = Nulls.SKIP) - public _FinalStage returnEntities(Optional returnEntities) { - this.returnEntities = returnEntities; - return this; - } - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- */ - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - /** - *

Regular expressions to ignore when detecting entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - /** - *

Regular expressions to ignore when detecting entities.

- */ - @java.lang.Override - @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) - public _FinalStage allowRegex(Optional> allowRegex) { - this.allowRegex = allowRegex; - return this; - } - - /** - *

Entities to detect and deidentify.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage restrictEntityTypes(List restrictEntityTypes) { - this.restrictEntityTypes = Optional.ofNullable(restrictEntityTypes); - return this; - } - - /** - *

Entities to detect and deidentify.

- */ - @java.lang.Override - @JsonSetter(value = "restrict_entity_types", nulls = Nulls.SKIP) - public _FinalStage restrictEntityTypes(Optional> restrictEntityTypes) { - this.restrictEntityTypes = restrictEntityTypes; - return this; - } - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sessionId(String sessionId) { - this.sessionId = Optional.ofNullable(sessionId); - return this; - } - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- */ - @java.lang.Override - @JsonSetter(value = "session_id", nulls = Nulls.SKIP) - public _FinalStage sessionId(Optional sessionId) { - this.sessionId = sessionId; - return this; - } - - @java.lang.Override - public V1DetectFileRequest build() { - return new V1DetectFileRequest( - file, - dataFormat, - inputType, - vaultId, - sessionId, - restrictEntityTypes, - allowRegex, - restrictRegex, - returnEntities, - accuracy, - audio, - image, - pdf, - advancedOptions, - deidentifyTokenFormat, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java b/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java index 48692d9f..782d2d2b 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java @@ -15,8 +15,10 @@ import com.skyflow.generated.rest.resources.files.requests.DeidentifyStructuredTextRequest; import com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest; import com.skyflow.generated.rest.resources.files.requests.GetRunRequest; +import com.skyflow.generated.rest.resources.files.requests.ReidentifyFileRequest; import com.skyflow.generated.rest.types.DeidentifyFileResponse; import com.skyflow.generated.rest.types.DeidentifyStatusResponse; +import com.skyflow.generated.rest.types.ReidentifyFileResponse; import java.util.concurrent.CompletableFuture; public class AsyncFilesClient { @@ -185,4 +187,19 @@ public CompletableFuture getRun( String runId, GetRunRequest request, RequestOptions requestOptions) { return this.rawClient.getRun(runId, request, requestOptions).thenApply(response -> response.body()); } + + /** + * Re-identifies tokens in a file. + */ + public CompletableFuture reidentifyFile(ReidentifyFileRequest request) { + return this.rawClient.reidentifyFile(request).thenApply(response -> response.body()); + } + + /** + * Re-identifies tokens in a file. + */ + public CompletableFuture reidentifyFile( + ReidentifyFileRequest request, RequestOptions requestOptions) { + return this.rawClient.reidentifyFile(request, requestOptions).thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java b/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java index f400bb2a..4672288a 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java @@ -26,9 +26,11 @@ import com.skyflow.generated.rest.resources.files.requests.DeidentifyStructuredTextRequest; import com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest; import com.skyflow.generated.rest.resources.files.requests.GetRunRequest; +import com.skyflow.generated.rest.resources.files.requests.ReidentifyFileRequest; import com.skyflow.generated.rest.types.DeidentifyFileResponse; import com.skyflow.generated.rest.types.DeidentifyStatusResponse; import com.skyflow.generated.rest.types.ErrorResponse; +import com.skyflow.generated.rest.types.ReidentifyFileResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -926,4 +928,92 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); return future; } + + /** + * Re-identifies tokens in a file. + */ + public CompletableFuture> reidentifyFile( + ReidentifyFileRequest request) { + return reidentifyFile(request, null); + } + + /** + * Re-identifies tokens in a file. + */ + public CompletableFuture> reidentifyFile( + ReidentifyFileRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/reidentify/file") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ReidentifyFileResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new ApiClientApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); + } + }); + return future; + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java b/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java index 89898d41..5eee1560 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java @@ -15,8 +15,10 @@ import com.skyflow.generated.rest.resources.files.requests.DeidentifyStructuredTextRequest; import com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest; import com.skyflow.generated.rest.resources.files.requests.GetRunRequest; +import com.skyflow.generated.rest.resources.files.requests.ReidentifyFileRequest; import com.skyflow.generated.rest.types.DeidentifyFileResponse; import com.skyflow.generated.rest.types.DeidentifyStatusResponse; +import com.skyflow.generated.rest.types.ReidentifyFileResponse; public class FilesClient { protected final ClientOptions clientOptions; @@ -177,4 +179,18 @@ public DeidentifyStatusResponse getRun(String runId, GetRunRequest request) { public DeidentifyStatusResponse getRun(String runId, GetRunRequest request, RequestOptions requestOptions) { return this.rawClient.getRun(runId, request, requestOptions).body(); } + + /** + * Re-identifies tokens in a file. + */ + public ReidentifyFileResponse reidentifyFile(ReidentifyFileRequest request) { + return this.rawClient.reidentifyFile(request).body(); + } + + /** + * Re-identifies tokens in a file. + */ + public ReidentifyFileResponse reidentifyFile(ReidentifyFileRequest request, RequestOptions requestOptions) { + return this.rawClient.reidentifyFile(request, requestOptions).body(); + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java b/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java index 85939625..d0fb0bfc 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java @@ -26,9 +26,11 @@ import com.skyflow.generated.rest.resources.files.requests.DeidentifyStructuredTextRequest; import com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest; import com.skyflow.generated.rest.resources.files.requests.GetRunRequest; +import com.skyflow.generated.rest.resources.files.requests.ReidentifyFileRequest; import com.skyflow.generated.rest.types.DeidentifyFileResponse; import com.skyflow.generated.rest.types.DeidentifyStatusResponse; import com.skyflow.generated.rest.types.ErrorResponse; +import com.skyflow.generated.rest.types.ReidentifyFileResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -711,4 +713,71 @@ public ApiClientHttpResponse getRun( throw new ApiClientException("Network error executing HTTP request", e); } } + + /** + * Re-identifies tokens in a file. + */ + public ApiClientHttpResponse reidentifyFile(ReidentifyFileRequest request) { + return reidentifyFile(request, null); + } + + /** + * Re-identifies tokens in a file. + */ + public ApiClientHttpResponse reidentifyFile( + ReidentifyFileRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/reidentify/file") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReidentifyFileResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new ApiClientApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new ApiClientException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java index 5f4929aa..b9f02d97 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java @@ -31,6 +31,8 @@ public final class DeidentifyAudioRequest { private final DeidentifyAudioRequestFile file; + private final Optional configurationId; + private final Optional outputProcessedAudio; private final Optional outputTranscription; @@ -58,6 +60,7 @@ public final class DeidentifyAudioRequest { private DeidentifyAudioRequest( String vaultId, DeidentifyAudioRequestFile file, + Optional configurationId, Optional outputProcessedAudio, Optional outputTranscription, Optional bleepGain, @@ -72,6 +75,7 @@ private DeidentifyAudioRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.outputProcessedAudio = outputProcessedAudio; this.outputTranscription = outputTranscription; this.bleepGain = bleepGain; @@ -99,6 +103,11 @@ public DeidentifyAudioRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + /** * @return If true, includes processed audio file in the response. */ @@ -186,6 +195,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyAudioRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && outputProcessedAudio.equals(other.outputProcessedAudio) && outputTranscription.equals(other.outputTranscription) && bleepGain.equals(other.bleepGain) @@ -204,6 +214,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.outputProcessedAudio, this.outputTranscription, this.bleepGain, @@ -242,6 +253,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyAudioRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + /** *

If true, includes processed audio file in the response.

*/ @@ -333,6 +348,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional outputProcessedAudio = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -342,6 +359,7 @@ private Builder() {} public Builder from(DeidentifyAudioRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); outputProcessedAudio(other.getOutputProcessedAudio()); outputTranscription(other.getOutputTranscription()); bleepGain(other.getBleepGain()); @@ -560,11 +578,25 @@ public _FinalStage outputProcessedAudio(Optional outputProcessedAudio) return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyAudioRequest build() { return new DeidentifyAudioRequest( vaultId, file, + configurationId, outputProcessedAudio, outputTranscription, bleepGain, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java index bf6f307e..dd2d1548 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java @@ -30,6 +30,8 @@ public final class DeidentifyDocumentRequest { private final DeidentifyDocumentRequestFile file; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -45,6 +47,7 @@ public final class DeidentifyDocumentRequest { private DeidentifyDocumentRequest( String vaultId, DeidentifyDocumentRequestFile file, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -53,6 +56,7 @@ private DeidentifyDocumentRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -74,6 +78,11 @@ public DeidentifyDocumentRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -113,6 +122,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyDocumentRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -125,6 +135,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -157,6 +168,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyDocumentRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -194,6 +209,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -203,6 +220,7 @@ private Builder() {} public Builder from(DeidentifyDocumentRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -294,11 +312,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyDocumentRequest build() { return new DeidentifyDocumentRequest( vaultId, file, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java index 1cbcd8f1..ae21845d 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java @@ -30,6 +30,8 @@ public final class DeidentifyFileRequest { private final DeidentifyFileRequestFile file; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -45,6 +47,7 @@ public final class DeidentifyFileRequest { private DeidentifyFileRequest( String vaultId, DeidentifyFileRequestFile file, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -53,6 +56,7 @@ private DeidentifyFileRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -74,6 +78,11 @@ public DeidentifyFileRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -113,6 +122,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyFileRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -125,6 +135,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -157,6 +168,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyFileRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -194,6 +209,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -203,6 +220,7 @@ private Builder() {} public Builder from(DeidentifyFileRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -294,11 +312,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyFileRequest build() { return new DeidentifyFileRequest( vaultId, file, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java index 41de24b2..92445d02 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java @@ -31,6 +31,8 @@ public final class DeidentifyImageRequest { private final DeidentifyImageRequestFile file; + private final Optional configurationId; + private final Optional outputProcessedImage; private final Optional outputOcrText; @@ -52,6 +54,7 @@ public final class DeidentifyImageRequest { private DeidentifyImageRequest( String vaultId, DeidentifyImageRequestFile file, + Optional configurationId, Optional outputProcessedImage, Optional outputOcrText, Optional maskingMethod, @@ -63,6 +66,7 @@ private DeidentifyImageRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.outputProcessedImage = outputProcessedImage; this.outputOcrText = outputOcrText; this.maskingMethod = maskingMethod; @@ -87,6 +91,11 @@ public DeidentifyImageRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + /** * @return If true, includes processed image in the output. */ @@ -150,6 +159,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyImageRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && outputProcessedImage.equals(other.outputProcessedImage) && outputOcrText.equals(other.outputOcrText) && maskingMethod.equals(other.maskingMethod) @@ -165,6 +175,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.outputProcessedImage, this.outputOcrText, this.maskingMethod, @@ -200,6 +211,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyImageRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + /** *

If true, includes processed image in the output.

*/ @@ -264,6 +279,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional outputProcessedImage = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -273,6 +290,7 @@ private Builder() {} public Builder from(DeidentifyImageRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); outputProcessedImage(other.getOutputProcessedImage()); outputOcrText(other.getOutputOcrText()); maskingMethod(other.getMaskingMethod()); @@ -427,11 +445,25 @@ public _FinalStage outputProcessedImage(Optional outputProcessedImage) return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyImageRequest build() { return new DeidentifyImageRequest( vaultId, file, + configurationId, outputProcessedImage, outputOcrText, maskingMethod, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java index 83fbb14f..4927eff3 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java @@ -30,9 +30,11 @@ public final class DeidentifyPdfRequest { private final DeidentifyPdfRequestFile file; - private final Optional density; + private final Optional configurationId; - private final Optional maxResolution; + private final Optional density; + + private final Optional maxResolution; private final Optional> entityTypes; @@ -49,8 +51,9 @@ public final class DeidentifyPdfRequest { private DeidentifyPdfRequest( String vaultId, DeidentifyPdfRequestFile file, - Optional density, - Optional maxResolution, + Optional configurationId, + Optional density, + Optional maxResolution, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -59,6 +62,7 @@ private DeidentifyPdfRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.density = density; this.maxResolution = maxResolution; this.entityTypes = entityTypes; @@ -82,11 +86,16 @@ public DeidentifyPdfRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + /** * @return Pixel density at which to process the PDF file. */ @JsonProperty("density") - public Optional getDensity() { + public Optional getDensity() { return density; } @@ -94,7 +103,7 @@ public Optional getDensity() { * @return Max resolution at which to process the PDF file. */ @JsonProperty("max_resolution") - public Optional getMaxResolution() { + public Optional getMaxResolution() { return maxResolution; } @@ -137,6 +146,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyPdfRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && density.equals(other.density) && maxResolution.equals(other.maxResolution) && entityTypes.equals(other.entityTypes) @@ -151,6 +161,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.density, this.maxResolution, this.entityTypes, @@ -185,19 +196,23 @@ public interface FileStage { public interface _FinalStage { DeidentifyPdfRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + /** *

Pixel density at which to process the PDF file.

*/ - _FinalStage density(Optional density); + _FinalStage density(Optional density); - _FinalStage density(Integer density); + _FinalStage density(Double density); /** *

Max resolution at which to process the PDF file.

*/ - _FinalStage maxResolution(Optional maxResolution); + _FinalStage maxResolution(Optional maxResolution); - _FinalStage maxResolution(Integer maxResolution); + _FinalStage maxResolution(Double maxResolution); _FinalStage entityTypes(Optional> entityTypes); @@ -236,9 +251,11 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); - private Optional maxResolution = Optional.empty(); + private Optional maxResolution = Optional.empty(); + + private Optional density = Optional.empty(); - private Optional density = Optional.empty(); + private Optional configurationId = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -249,6 +266,7 @@ private Builder() {} public Builder from(DeidentifyPdfRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); density(other.getDensity()); maxResolution(other.getMaxResolution()); entityTypes(other.getEntityTypes()); @@ -347,7 +365,7 @@ public _FinalStage entityTypes(Optional> entityTypes) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage maxResolution(Integer maxResolution) { + public _FinalStage maxResolution(Double maxResolution) { this.maxResolution = Optional.ofNullable(maxResolution); return this; } @@ -357,7 +375,7 @@ public _FinalStage maxResolution(Integer maxResolution) { */ @java.lang.Override @JsonSetter(value = "max_resolution", nulls = Nulls.SKIP) - public _FinalStage maxResolution(Optional maxResolution) { + public _FinalStage maxResolution(Optional maxResolution) { this.maxResolution = maxResolution; return this; } @@ -367,7 +385,7 @@ public _FinalStage maxResolution(Optional maxResolution) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage density(Integer density) { + public _FinalStage density(Double density) { this.density = Optional.ofNullable(density); return this; } @@ -377,16 +395,30 @@ public _FinalStage density(Integer density) { */ @java.lang.Override @JsonSetter(value = "density", nulls = Nulls.SKIP) - public _FinalStage density(Optional density) { + public _FinalStage density(Optional density) { this.density = density; return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyPdfRequest build() { return new DeidentifyPdfRequest( vaultId, file, + configurationId, density, maxResolution, entityTypes, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java index 47a63a5b..95ced625 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java @@ -30,6 +30,8 @@ public final class DeidentifyPresentationRequest { private final DeidentifyPresentationRequestFile file; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -45,6 +47,7 @@ public final class DeidentifyPresentationRequest { private DeidentifyPresentationRequest( String vaultId, DeidentifyPresentationRequestFile file, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -53,6 +56,7 @@ private DeidentifyPresentationRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -74,6 +78,11 @@ public DeidentifyPresentationRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -113,6 +122,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyPresentationRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -125,6 +135,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -157,6 +168,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyPresentationRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -194,6 +209,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -203,6 +220,7 @@ private Builder() {} public Builder from(DeidentifyPresentationRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -294,11 +312,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyPresentationRequest build() { return new DeidentifyPresentationRequest( vaultId, file, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java index b72b412b..283457f8 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java @@ -30,6 +30,8 @@ public final class DeidentifySpreadsheetRequest { private final DeidentifySpreadsheetRequestFile file; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -45,6 +47,7 @@ public final class DeidentifySpreadsheetRequest { private DeidentifySpreadsheetRequest( String vaultId, DeidentifySpreadsheetRequestFile file, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -53,6 +56,7 @@ private DeidentifySpreadsheetRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -74,6 +78,11 @@ public DeidentifySpreadsheetRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -113,6 +122,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifySpreadsheetRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -125,6 +135,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -157,6 +168,10 @@ public interface FileStage { public interface _FinalStage { DeidentifySpreadsheetRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -194,6 +209,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -203,6 +220,7 @@ private Builder() {} public Builder from(DeidentifySpreadsheetRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -294,11 +312,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifySpreadsheetRequest build() { return new DeidentifySpreadsheetRequest( vaultId, file, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java index a61a5ba0..8ff7e195 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java @@ -30,6 +30,8 @@ public final class DeidentifyStructuredTextRequest { private final DeidentifyStructuredTextRequestFile file; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -45,6 +47,7 @@ public final class DeidentifyStructuredTextRequest { private DeidentifyStructuredTextRequest( String vaultId, DeidentifyStructuredTextRequestFile file, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -53,6 +56,7 @@ private DeidentifyStructuredTextRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -74,6 +78,11 @@ public DeidentifyStructuredTextRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -113,6 +122,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyStructuredTextRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -125,6 +135,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -157,6 +168,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyStructuredTextRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -194,6 +209,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -203,6 +220,7 @@ private Builder() {} public Builder from(DeidentifyStructuredTextRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -294,11 +312,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyStructuredTextRequest build() { return new DeidentifyStructuredTextRequest( vaultId, file, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java index 4eb0ac6c..e65d89e8 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java @@ -30,6 +30,8 @@ public final class DeidentifyTextRequest { private final DeidentifyTextRequestFile file; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -45,6 +47,7 @@ public final class DeidentifyTextRequest { private DeidentifyTextRequest( String vaultId, DeidentifyTextRequestFile file, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -53,6 +56,7 @@ private DeidentifyTextRequest( Map additionalProperties) { this.vaultId = vaultId; this.file = file; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -74,6 +78,11 @@ public DeidentifyTextRequestFile getFile() { return file; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -113,6 +122,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyTextRequest other) { return vaultId.equals(other.vaultId) && file.equals(other.file) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -125,6 +135,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.file, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -157,6 +168,10 @@ public interface FileStage { public interface _FinalStage { DeidentifyTextRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -194,6 +209,8 @@ public static final class Builder implements VaultIdStage, FileStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -203,6 +220,7 @@ private Builder() {} public Builder from(DeidentifyTextRequest other) { vaultId(other.getVaultId()); file(other.getFile()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -294,11 +312,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyTextRequest build() { return new DeidentifyTextRequest( vaultId, file, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/ReidentifyFileRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/ReidentifyFileRequest.java new file mode 100644 index 00000000..4afb0146 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/files/requests/ReidentifyFileRequest.java @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.resources.files.types.ReidentifyFileRequestFile; +import com.skyflow.generated.rest.resources.files.types.ReidentifyFileRequestFormat; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReidentifyFileRequest.Builder.class) +public final class ReidentifyFileRequest { + private final String vaultId; + + private final ReidentifyFileRequestFile file; + + private final Optional format; + + private final Map additionalProperties; + + private ReidentifyFileRequest( + String vaultId, + ReidentifyFileRequestFile file, + Optional format, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.format = format; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to re-identify. Files are specified as Base64-encoded data or an EFS path. + */ + @JsonProperty("file") + public ReidentifyFileRequestFile getFile() { + return file; + } + + /** + * @return Mapping of preferred data formatting options to entity types. Returned values are dependent on the configuration of the vault storing the data and the permissions of the user or account making the request. + */ + @JsonProperty("format") + public Optional getFormat() { + return format; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyFileRequest && equalTo((ReidentifyFileRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyFileRequest other) { + return vaultId.equals(other.vaultId) && file.equals(other.file) && format.equals(other.format); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.vaultId, this.file, this.format); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static VaultIdStage builder() { + return new Builder(); + } + + public interface VaultIdStage { + FileStage vaultId(@NotNull String vaultId); + + Builder from(ReidentifyFileRequest other); + } + + public interface FileStage { + /** + * File to re-identify. Files are specified as Base64-encoded data or an EFS path. + */ + _FinalStage file(@NotNull ReidentifyFileRequestFile file); + } + + public interface _FinalStage { + ReidentifyFileRequest build(); + + /** + *

Mapping of preferred data formatting options to entity types. Returned values are dependent on the configuration of the vault storing the data and the permissions of the user or account making the request.

+ */ + _FinalStage format(Optional format); + + _FinalStage format(ReidentifyFileRequestFormat format); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private ReidentifyFileRequestFile file; + + private Optional format = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReidentifyFileRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + format(other.getFormat()); + return this; + } + + @java.lang.Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to re-identify. Files are specified as Base64-encoded data or an EFS path.

File to re-identify. Files are specified as Base64-encoded data or an EFS path.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("file") + public _FinalStage file(@NotNull ReidentifyFileRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + /** + *

Mapping of preferred data formatting options to entity types. Returned values are dependent on the configuration of the vault storing the data and the permissions of the user or account making the request.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage format(ReidentifyFileRequestFormat format) { + this.format = Optional.ofNullable(format); + return this; + } + + /** + *

Mapping of preferred data formatting options to entity types. Returned values are dependent on the configuration of the vault storing the data and the permissions of the user or account making the request.

+ */ + @java.lang.Override + @JsonSetter(value = "format", nulls = Nulls.SKIP) + public _FinalStage format(Optional format) { + this.format = format; + return this; + } + + @java.lang.Override + public ReidentifyFileRequest build() { + return new ReidentifyFileRequest(vaultId, file, format, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java index afc90bc3..b0ab22b9 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java @@ -10,6 +10,8 @@ public enum DeidentifyFileRequestFileDataFormat { CSV("csv"), + DCM("dcm"), + DOC("doc"), DOCX("docx"), diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFile.java new file mode 100644 index 00000000..bea9b303 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFile.java @@ -0,0 +1,145 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReidentifyFileRequestFile.Builder.class) +public final class ReidentifyFileRequestFile { + private final String base64; + + private final ReidentifyFileRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private ReidentifyFileRequestFile( + String base64, ReidentifyFileRequestFileDataFormat dataFormat, Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to re-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public ReidentifyFileRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyFileRequestFile && equalTo((ReidentifyFileRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyFileRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Base64Stage builder() { + return new Builder(); + } + + public interface Base64Stage { + /** + * Base64-encoded data of the file to re-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(ReidentifyFileRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull ReidentifyFileRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + ReidentifyFileRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private ReidentifyFileRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReidentifyFileRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to re-identify.

Base64-encoded data of the file to re-identify.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("base64") + public DataFormatStage base64(@NotNull String base64) { + this.base64 = Objects.requireNonNull(base64, "base64 must not be null"); + return this; + } + + /** + * Data format of the file.

Data format of the file.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull ReidentifyFileRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @java.lang.Override + public ReidentifyFileRequestFile build() { + return new ReidentifyFileRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFileDataFormat.java similarity index 54% rename from src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java rename to src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFileDataFormat.java index a384af7f..3e1555f3 100644 --- a/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java +++ b/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFileDataFormat.java @@ -1,52 +1,30 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.types; +package com.skyflow.generated.rest.resources.files.types; import com.fasterxml.jackson.annotation.JsonValue; -public enum V1FileDataFormat { - BMP("bmp"), - +public enum ReidentifyFileRequestFileDataFormat { CSV("csv"), DOC("doc"), DOCX("docx"), - JPEG("jpeg"), - - JPG("jpg"), - JSON("json"), - MP_3("mp3"), - - PDF("pdf"), - - PNG("png"), - - PPT("ppt"), - - PPTX("pptx"), - - TIF("tif"), - - TIFF("tiff"), - TXT("txt"), - UNKNOWN("unknown"), - - WAV("wav"), - XLS("xls"), - XLSX("xlsx"); + XLSX("xlsx"), + + XML("xml"); private final String value; - V1FileDataFormat(String value) { + ReidentifyFileRequestFileDataFormat(String value) { this.value = value; } diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFormat.java new file mode 100644 index 00000000..232fcd55 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/files/types/ReidentifyFileRequestFormat.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.types.EntityType; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReidentifyFileRequestFormat.Builder.class) +public final class ReidentifyFileRequestFormat { + private final Optional> redacted; + + private final Optional> masked; + + private final Optional> plaintext; + + private final Map additionalProperties; + + private ReidentifyFileRequestFormat( + Optional> redacted, + Optional> masked, + Optional> plaintext, + Map additionalProperties) { + this.redacted = redacted; + this.masked = masked; + this.plaintext = plaintext; + this.additionalProperties = additionalProperties; + } + + /** + * @return Entity types to fully redact. + */ + @JsonProperty("redacted") + public Optional> getRedacted() { + return redacted; + } + + /** + * @return Entity types to mask. + */ + @JsonProperty("masked") + public Optional> getMasked() { + return masked; + } + + /** + * @return Entity types to return in plaintext. + */ + @JsonProperty("plaintext") + public Optional> getPlaintext() { + return plaintext; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyFileRequestFormat && equalTo((ReidentifyFileRequestFormat) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyFileRequestFormat other) { + return redacted.equals(other.redacted) && masked.equals(other.masked) && plaintext.equals(other.plaintext); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.redacted, this.masked, this.plaintext); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> redacted = Optional.empty(); + + private Optional> masked = Optional.empty(); + + private Optional> plaintext = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ReidentifyFileRequestFormat other) { + redacted(other.getRedacted()); + masked(other.getMasked()); + plaintext(other.getPlaintext()); + return this; + } + + /** + *

Entity types to fully redact.

+ */ + @JsonSetter(value = "redacted", nulls = Nulls.SKIP) + public Builder redacted(Optional> redacted) { + this.redacted = redacted; + return this; + } + + public Builder redacted(List redacted) { + this.redacted = Optional.ofNullable(redacted); + return this; + } + + /** + *

Entity types to mask.

+ */ + @JsonSetter(value = "masked", nulls = Nulls.SKIP) + public Builder masked(Optional> masked) { + this.masked = masked; + return this; + } + + public Builder masked(List masked) { + this.masked = Optional.ofNullable(masked); + return this; + } + + /** + *

Entity types to return in plaintext.

+ */ + @JsonSetter(value = "plaintext", nulls = Nulls.SKIP) + public Builder plaintext(Optional> plaintext) { + this.plaintext = plaintext; + return this; + } + + public Builder plaintext(List plaintext) { + this.plaintext = Optional.ofNullable(plaintext); + return this; + } + + public ReidentifyFileRequestFormat build() { + return new ReidentifyFileRequestFormat(redacted, masked, plaintext, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/guardrails/AsyncGuardrailsClient.java b/src/main/java/com/skyflow/generated/rest/resources/guardrails/AsyncGuardrailsClient.java new file mode 100644 index 00000000..1caa38aa --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/guardrails/AsyncGuardrailsClient.java @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.guardrails; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.guardrails.requests.CheckGuardrailsRequest; +import com.skyflow.generated.rest.types.CheckGuardrailsResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncGuardrailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGuardrailsClient rawClient; + + public AsyncGuardrailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGuardrailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGuardrailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Preserve safety and compliance with usage policies. + */ + public CompletableFuture checkGuardrails(CheckGuardrailsRequest request) { + return this.rawClient.checkGuardrails(request).thenApply(response -> response.body()); + } + + /** + * Preserve safety and compliance with usage policies. + */ + public CompletableFuture checkGuardrails( + CheckGuardrailsRequest request, RequestOptions requestOptions) { + return this.rawClient.checkGuardrails(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/guardrails/AsyncRawGuardrailsClient.java b/src/main/java/com/skyflow/generated/rest/resources/guardrails/AsyncRawGuardrailsClient.java new file mode 100644 index 00000000..fcea229b --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/guardrails/AsyncRawGuardrailsClient.java @@ -0,0 +1,127 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.guardrails; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.core.ApiClientException; +import com.skyflow.generated.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.MediaTypes; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.errors.BadRequestError; +import com.skyflow.generated.rest.errors.InternalServerError; +import com.skyflow.generated.rest.errors.UnauthorizedError; +import com.skyflow.generated.rest.resources.guardrails.requests.CheckGuardrailsRequest; +import com.skyflow.generated.rest.types.CheckGuardrailsResponse; +import com.skyflow.generated.rest.types.ErrorResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGuardrailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawGuardrailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Preserve safety and compliance with usage policies. + */ + public CompletableFuture> checkGuardrails( + CheckGuardrailsRequest request) { + return checkGuardrails(request, null); + } + + /** + * Preserve safety and compliance with usage policies. + */ + public CompletableFuture> checkGuardrails( + CheckGuardrailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/guardrails") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CheckGuardrailsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new ApiClientApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/guardrails/GuardrailsClient.java b/src/main/java/com/skyflow/generated/rest/resources/guardrails/GuardrailsClient.java new file mode 100644 index 00000000..fe4ab899 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/guardrails/GuardrailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.guardrails; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.guardrails.requests.CheckGuardrailsRequest; +import com.skyflow.generated.rest.types.CheckGuardrailsResponse; + +public class GuardrailsClient { + protected final ClientOptions clientOptions; + + private final RawGuardrailsClient rawClient; + + public GuardrailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawGuardrailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGuardrailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Preserve safety and compliance with usage policies. + */ + public CheckGuardrailsResponse checkGuardrails(CheckGuardrailsRequest request) { + return this.rawClient.checkGuardrails(request).body(); + } + + /** + * Preserve safety and compliance with usage policies. + */ + public CheckGuardrailsResponse checkGuardrails(CheckGuardrailsRequest request, RequestOptions requestOptions) { + return this.rawClient.checkGuardrails(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/guardrails/RawGuardrailsClient.java b/src/main/java/com/skyflow/generated/rest/resources/guardrails/RawGuardrailsClient.java new file mode 100644 index 00000000..2667b55a --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/guardrails/RawGuardrailsClient.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.guardrails; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.core.ApiClientException; +import com.skyflow.generated.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.MediaTypes; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.errors.BadRequestError; +import com.skyflow.generated.rest.errors.InternalServerError; +import com.skyflow.generated.rest.errors.UnauthorizedError; +import com.skyflow.generated.rest.resources.guardrails.requests.CheckGuardrailsRequest; +import com.skyflow.generated.rest.types.CheckGuardrailsResponse; +import com.skyflow.generated.rest.types.ErrorResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGuardrailsClient { + protected final ClientOptions clientOptions; + + public RawGuardrailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Preserve safety and compliance with usage policies. + */ + public ApiClientHttpResponse checkGuardrails(CheckGuardrailsRequest request) { + return checkGuardrails(request, null); + } + + /** + * Preserve safety and compliance with usage policies. + */ + public ApiClientHttpResponse checkGuardrails( + CheckGuardrailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/guardrails") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckGuardrailsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new ApiClientApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new ApiClientException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/guardrails/requests/CheckGuardrailsRequest.java b/src/main/java/com/skyflow/generated/rest/resources/guardrails/requests/CheckGuardrailsRequest.java new file mode 100644 index 00000000..8fbf90f7 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/guardrails/requests/CheckGuardrailsRequest.java @@ -0,0 +1,227 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.guardrails.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CheckGuardrailsRequest.Builder.class) +public final class CheckGuardrailsRequest { + private final String vaultId; + + private final String text; + + private final Optional checkToxicity; + + private final Optional> denyTopics; + + private final Map additionalProperties; + + private CheckGuardrailsRequest( + String vaultId, + String text, + Optional checkToxicity, + Optional> denyTopics, + Map additionalProperties) { + this.vaultId = vaultId; + this.text = text; + this.checkToxicity = checkToxicity; + this.denyTopics = denyTopics; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return Text to check against guardrails. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return Check for toxicity in the text. + */ + @JsonProperty("check_toxicity") + public Optional getCheckToxicity() { + return checkToxicity; + } + + /** + * @return List of topics to deny. + */ + @JsonProperty("deny_topics") + public Optional> getDenyTopics() { + return denyTopics; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CheckGuardrailsRequest && equalTo((CheckGuardrailsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CheckGuardrailsRequest other) { + return vaultId.equals(other.vaultId) + && text.equals(other.text) + && checkToxicity.equals(other.checkToxicity) + && denyTopics.equals(other.denyTopics); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.vaultId, this.text, this.checkToxicity, this.denyTopics); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static VaultIdStage builder() { + return new Builder(); + } + + public interface VaultIdStage { + TextStage vaultId(@NotNull String vaultId); + + Builder from(CheckGuardrailsRequest other); + } + + public interface TextStage { + /** + * Text to check against guardrails. + */ + _FinalStage text(@NotNull String text); + } + + public interface _FinalStage { + CheckGuardrailsRequest build(); + + /** + *

Check for toxicity in the text.

+ */ + _FinalStage checkToxicity(Optional checkToxicity); + + _FinalStage checkToxicity(Boolean checkToxicity); + + /** + *

List of topics to deny.

+ */ + _FinalStage denyTopics(Optional> denyTopics); + + _FinalStage denyTopics(List denyTopics); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, TextStage, _FinalStage { + private String vaultId; + + private String text; + + private Optional> denyTopics = Optional.empty(); + + private Optional checkToxicity = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CheckGuardrailsRequest other) { + vaultId(other.getVaultId()); + text(other.getText()); + checkToxicity(other.getCheckToxicity()); + denyTopics(other.getDenyTopics()); + return this; + } + + @java.lang.Override + @JsonSetter("vault_id") + public TextStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * Text to check against guardrails.

Text to check against guardrails.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("text") + public _FinalStage text(@NotNull String text) { + this.text = Objects.requireNonNull(text, "text must not be null"); + return this; + } + + /** + *

List of topics to deny.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage denyTopics(List denyTopics) { + this.denyTopics = Optional.ofNullable(denyTopics); + return this; + } + + /** + *

List of topics to deny.

+ */ + @java.lang.Override + @JsonSetter(value = "deny_topics", nulls = Nulls.SKIP) + public _FinalStage denyTopics(Optional> denyTopics) { + this.denyTopics = denyTopics; + return this; + } + + /** + *

Check for toxicity in the text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage checkToxicity(Boolean checkToxicity) { + this.checkToxicity = Optional.ofNullable(checkToxicity); + return this; + } + + /** + *

Check for toxicity in the text.

+ */ + @java.lang.Override + @JsonSetter(value = "check_toxicity", nulls = Nulls.SKIP) + public _FinalStage checkToxicity(Optional checkToxicity) { + this.checkToxicity = checkToxicity; + return this; + } + + @java.lang.Override + public CheckGuardrailsRequest build() { + return new CheckGuardrailsRequest(vaultId, text, checkToxicity, denyTopics, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java b/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java index 757ee8e4..a810f142 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java @@ -12,7 +12,10 @@ import com.skyflow.generated.rest.core.ObjectMappers; import com.skyflow.generated.rest.core.QueryStringMapper; import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.errors.BadRequestError; +import com.skyflow.generated.rest.errors.InternalServerError; import com.skyflow.generated.rest.errors.NotFoundError; +import com.skyflow.generated.rest.errors.UnauthorizedError; import com.skyflow.generated.rest.resources.records.requests.FileServiceUploadFileRequest; import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkDeleteRecordBody; @@ -20,6 +23,9 @@ import com.skyflow.generated.rest.resources.records.requests.RecordServiceGetRecordRequest; import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody; +import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request; +import com.skyflow.generated.rest.types.ErrorResponse; +import com.skyflow.generated.rest.types.UploadFileV2Response; import com.skyflow.generated.rest.types.V1BatchOperationResponse; import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; @@ -703,12 +709,12 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * Uploads a file to the specified record. */ public CompletableFuture> fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { + String vaultId, String objectName, String id, Optional file) { return fileServiceUploadFile( vaultId, objectName, id, - fileColumnName, + file, FileServiceUploadFileRequest.builder().build()); } @@ -716,12 +722,8 @@ public CompletableFuture> fileServ * Uploads a file to the specified record. */ public CompletableFuture> fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request) { - return fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, null); + String vaultId, String objectName, String id, Optional file, FileServiceUploadFileRequest request) { + return fileServiceUploadFile(vaultId, objectName, id, file, request, null); } /** @@ -731,7 +733,7 @@ public CompletableFuture> fileServ String vaultId, String objectName, String id, - Optional fileColumnName, + Optional file, FileServiceUploadFileRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -744,15 +746,15 @@ public CompletableFuture> fileServ .build(); MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM); try { - if (fileColumnName.isPresent()) { - String fileColumnNameMimeType = - Files.probeContentType(fileColumnName.get().toPath()); - MediaType fileColumnNameMimeTypeMediaType = - fileColumnNameMimeType != null ? MediaType.parse(fileColumnNameMimeType) : null; + if (file.isPresent()) { + String fileMimeType = Files.probeContentType(file.get().toPath()); + MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null; body.addFormDataPart( - "fileColumnName", - fileColumnName.get().getName(), - RequestBody.create(fileColumnName.get(), fileColumnNameMimeTypeMediaType)); + "file", file.get().getName(), RequestBody.create(file.get(), fileMimeTypeMediaType)); + } + if (request.getColumnName().isPresent()) { + QueryStringMapper.addFormDataPart( + body, "columnName", request.getColumnName().get(), false); } } catch (Exception e) { throw new RuntimeException(e); @@ -953,4 +955,111 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); return future; } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public CompletableFuture> uploadFileV2( + String vaultId, File file, UploadFileV2Request request) { + return uploadFileV2(vaultId, file, request, null); + } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public CompletableFuture> uploadFileV2( + String vaultId, File file, UploadFileV2Request request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/vaults") + .addPathSegment(vaultId) + .addPathSegments("files/upload") + .build(); + MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM); + try { + QueryStringMapper.addFormDataPart(body, "tableName", request.getTableName(), false); + QueryStringMapper.addFormDataPart(body, "columnName", request.getColumnName(), false); + String fileMimeType = Files.probeContentType(file.toPath()); + MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null; + body.addFormDataPart("file", file.getName(), RequestBody.create(file, fileMimeTypeMediaType)); + if (request.getSkyflowId().isPresent()) { + QueryStringMapper.addFormDataPart( + body, "skyflowID", request.getSkyflowId().get(), false); + } + if (request.getReturnFileMetadata().isPresent()) { + QueryStringMapper.addFormDataPart( + body, + "returnFileMetadata", + request.getReturnFileMetadata().get(), + false); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", body.build()) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UploadFileV2Response.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new ApiClientApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); + } + }); + return future; + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java b/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java index baf98c1d..c6925b50 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java @@ -12,6 +12,8 @@ import com.skyflow.generated.rest.resources.records.requests.RecordServiceGetRecordRequest; import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody; +import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request; +import com.skyflow.generated.rest.types.UploadFileV2Response; import com.skyflow.generated.rest.types.V1BatchOperationResponse; import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; @@ -240,9 +242,9 @@ public CompletableFuture recordServiceDeleteRecord( * Uploads a file to the specified record. */ public CompletableFuture fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { + String vaultId, String objectName, String id, Optional file) { return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName) + .fileServiceUploadFile(vaultId, objectName, id, file) .thenApply(response -> response.body()); } @@ -250,13 +252,9 @@ public CompletableFuture fileServiceUploadFile( * Uploads a file to the specified record. */ public CompletableFuture fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request) { + String vaultId, String objectName, String id, Optional file, FileServiceUploadFileRequest request) { return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request) + .fileServiceUploadFile(vaultId, objectName, id, file, request) .thenApply(response -> response.body()); } @@ -267,11 +265,11 @@ public CompletableFuture fileServiceUploadFile( String vaultId, String objectName, String id, - Optional fileColumnName, + Optional file, FileServiceUploadFileRequest request, RequestOptions requestOptions) { return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, requestOptions) + .fileServiceUploadFile(vaultId, objectName, id, file, request, requestOptions) .thenApply(response -> response.body()); } @@ -314,4 +312,22 @@ public CompletableFuture fileServiceGetFileScanStat .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, requestOptions) .thenApply(response -> response.body()); } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public CompletableFuture uploadFileV2( + String vaultId, File file, UploadFileV2Request request) { + return this.rawClient.uploadFileV2(vaultId, file, request).thenApply(response -> response.body()); + } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public CompletableFuture uploadFileV2( + String vaultId, File file, UploadFileV2Request request, RequestOptions requestOptions) { + return this.rawClient + .uploadFileV2(vaultId, file, request, requestOptions) + .thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java b/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java index 593f5e3d..d1b607a0 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java @@ -12,7 +12,10 @@ import com.skyflow.generated.rest.core.ObjectMappers; import com.skyflow.generated.rest.core.QueryStringMapper; import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.errors.BadRequestError; +import com.skyflow.generated.rest.errors.InternalServerError; import com.skyflow.generated.rest.errors.NotFoundError; +import com.skyflow.generated.rest.errors.UnauthorizedError; import com.skyflow.generated.rest.resources.records.requests.FileServiceUploadFileRequest; import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkDeleteRecordBody; @@ -20,6 +23,9 @@ import com.skyflow.generated.rest.resources.records.requests.RecordServiceGetRecordRequest; import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody; +import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request; +import com.skyflow.generated.rest.types.ErrorResponse; +import com.skyflow.generated.rest.types.UploadFileV2Response; import com.skyflow.generated.rest.types.V1BatchOperationResponse; import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; @@ -591,12 +597,12 @@ public ApiClientHttpResponse recordServiceDeleteRecord( * Uploads a file to the specified record. */ public ApiClientHttpResponse fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { + String vaultId, String objectName, String id, Optional file) { return fileServiceUploadFile( vaultId, objectName, id, - fileColumnName, + file, FileServiceUploadFileRequest.builder().build()); } @@ -604,12 +610,8 @@ public ApiClientHttpResponse fileServiceUploadFile( * Uploads a file to the specified record. */ public ApiClientHttpResponse fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request) { - return fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, null); + String vaultId, String objectName, String id, Optional file, FileServiceUploadFileRequest request) { + return fileServiceUploadFile(vaultId, objectName, id, file, request, null); } /** @@ -619,7 +621,7 @@ public ApiClientHttpResponse fileServiceUploadFile( String vaultId, String objectName, String id, - Optional fileColumnName, + Optional file, FileServiceUploadFileRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -632,15 +634,15 @@ public ApiClientHttpResponse fileServiceUploadFile( .build(); MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM); try { - if (fileColumnName.isPresent()) { - String fileColumnNameMimeType = - Files.probeContentType(fileColumnName.get().toPath()); - MediaType fileColumnNameMimeTypeMediaType = - fileColumnNameMimeType != null ? MediaType.parse(fileColumnNameMimeType) : null; + if (file.isPresent()) { + String fileMimeType = Files.probeContentType(file.get().toPath()); + MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null; body.addFormDataPart( - "fileColumnName", - fileColumnName.get().getName(), - RequestBody.create(fileColumnName.get(), fileColumnNameMimeTypeMediaType)); + "file", file.get().getName(), RequestBody.create(file.get(), fileMimeTypeMediaType)); + } + if (request.getColumnName().isPresent()) { + QueryStringMapper.addFormDataPart( + body, "columnName", request.getColumnName().get(), false); } } catch (Exception e) { throw new RuntimeException(e); @@ -797,4 +799,90 @@ public ApiClientHttpResponse fileServiceGetFileScan throw new ApiClientException("Network error executing HTTP request", e); } } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public ApiClientHttpResponse uploadFileV2( + String vaultId, File file, UploadFileV2Request request) { + return uploadFileV2(vaultId, file, request, null); + } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public ApiClientHttpResponse uploadFileV2( + String vaultId, File file, UploadFileV2Request request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/vaults") + .addPathSegment(vaultId) + .addPathSegments("files/upload") + .build(); + MultipartBody.Builder body = new MultipartBody.Builder().setType(MultipartBody.FORM); + try { + QueryStringMapper.addFormDataPart(body, "tableName", request.getTableName(), false); + QueryStringMapper.addFormDataPart(body, "columnName", request.getColumnName(), false); + String fileMimeType = Files.probeContentType(file.toPath()); + MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null; + body.addFormDataPart("file", file.getName(), RequestBody.create(file, fileMimeTypeMediaType)); + if (request.getSkyflowId().isPresent()) { + QueryStringMapper.addFormDataPart( + body, "skyflowID", request.getSkyflowId().get(), false); + } + if (request.getReturnFileMetadata().isPresent()) { + QueryStringMapper.addFormDataPart( + body, + "returnFileMetadata", + request.getReturnFileMetadata().get(), + false); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", body.build()) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UploadFileV2Response.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new ApiClientApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new ApiClientException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java b/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java index fee9d49b..7b4599c6 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java +++ b/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java @@ -12,6 +12,8 @@ import com.skyflow.generated.rest.resources.records.requests.RecordServiceGetRecordRequest; import com.skyflow.generated.rest.resources.records.requests.RecordServiceInsertRecordBody; import com.skyflow.generated.rest.resources.records.requests.RecordServiceUpdateRecordBody; +import com.skyflow.generated.rest.resources.records.requests.UploadFileV2Request; +import com.skyflow.generated.rest.types.UploadFileV2Response; import com.skyflow.generated.rest.types.V1BatchOperationResponse; import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; @@ -236,9 +238,9 @@ public V1DeleteRecordResponse recordServiceDeleteRecord( * Uploads a file to the specified record. */ public V1UpdateRecordResponse fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { + String vaultId, String objectName, String id, Optional file) { return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName) + .fileServiceUploadFile(vaultId, objectName, id, file) .body(); } @@ -246,13 +248,9 @@ public V1UpdateRecordResponse fileServiceUploadFile( * Uploads a file to the specified record. */ public V1UpdateRecordResponse fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request) { + String vaultId, String objectName, String id, Optional file, FileServiceUploadFileRequest request) { return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request) + .fileServiceUploadFile(vaultId, objectName, id, file, request) .body(); } @@ -263,11 +261,11 @@ public V1UpdateRecordResponse fileServiceUploadFile( String vaultId, String objectName, String id, - Optional fileColumnName, + Optional file, FileServiceUploadFileRequest request, RequestOptions requestOptions) { return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, requestOptions) + .fileServiceUploadFile(vaultId, objectName, id, file, request, requestOptions) .body(); } @@ -309,4 +307,21 @@ public V1GetFileScanStatusResponse fileServiceGetFileScanStatus( .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, requestOptions) .body(); } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public UploadFileV2Response uploadFileV2(String vaultId, File file, UploadFileV2Request request) { + return this.rawClient.uploadFileV2(vaultId, file, request).body(); + } + + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + */ + public UploadFileV2Response uploadFileV2( + String vaultId, File file, UploadFileV2Request request, RequestOptions requestOptions) { + return this.rawClient + .uploadFileV2(vaultId, file, request, requestOptions) + .body(); + } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java index d1b64906..8152e4d7 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java @@ -7,24 +7,40 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; +import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FileServiceUploadFileRequest.Builder.class) public final class FileServiceUploadFileRequest { + private final Optional columnName; + private final Map additionalProperties; - private FileServiceUploadFileRequest(Map additionalProperties) { + private FileServiceUploadFileRequest(Optional columnName, Map additionalProperties) { + this.columnName = columnName; this.additionalProperties = additionalProperties; } + /** + * @return Name of the column to store the file in. The column must have a file data type. + */ + @JsonProperty("columnName") + public Optional getColumnName() { + return columnName; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof FileServiceUploadFileRequest; + return other instanceof FileServiceUploadFileRequest && equalTo((FileServiceUploadFileRequest) other); } @JsonAnyGetter @@ -32,6 +48,15 @@ public Map getAdditionalProperties() { return this.additionalProperties; } + private boolean equalTo(FileServiceUploadFileRequest other) { + return columnName.equals(other.columnName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.columnName); + } + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); @@ -43,17 +68,34 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional columnName = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(FileServiceUploadFileRequest other) { + columnName(other.getColumnName()); + return this; + } + + /** + *

Name of the column to store the file in. The column must have a file data type.

+ */ + @JsonSetter(value = "columnName", nulls = Nulls.SKIP) + public Builder columnName(Optional columnName) { + this.columnName = columnName; + return this; + } + + public Builder columnName(String columnName) { + this.columnName = Optional.ofNullable(columnName); return this; } public FileServiceUploadFileRequest build() { - return new FileServiceUploadFileRequest(additionalProperties); + return new FileServiceUploadFileRequest(columnName, additionalProperties); } } } diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/UploadFileV2Request.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/UploadFileV2Request.java new file mode 100644 index 00000000..ca26f0d3 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/resources/records/requests/UploadFileV2Request.java @@ -0,0 +1,236 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UploadFileV2Request.Builder.class) +public final class UploadFileV2Request { + private final String tableName; + + private final String columnName; + + private final Optional skyflowId; + + private final Optional returnFileMetadata; + + private final Map additionalProperties; + + private UploadFileV2Request( + String tableName, + String columnName, + Optional skyflowId, + Optional returnFileMetadata, + Map additionalProperties) { + this.tableName = tableName; + this.columnName = columnName; + this.skyflowId = skyflowId; + this.returnFileMetadata = returnFileMetadata; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the table to upload the file to. + */ + @JsonProperty("tableName") + public String getTableName() { + return tableName; + } + + /** + * @return Name of the column to upload the file to. The column must have a file data type. + */ + @JsonProperty("columnName") + public String getColumnName() { + return columnName; + } + + /** + * @return Skyflow ID of the record to upload the file to. If skyflowID isn't specified, a new record will be created. + */ + @JsonProperty("skyflowID") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return If true, returns metadata about the uploaded file. + */ + @JsonProperty("returnFileMetadata") + public Optional getReturnFileMetadata() { + return returnFileMetadata; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UploadFileV2Request && equalTo((UploadFileV2Request) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UploadFileV2Request other) { + return tableName.equals(other.tableName) + && columnName.equals(other.columnName) + && skyflowId.equals(other.skyflowId) + && returnFileMetadata.equals(other.returnFileMetadata); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.tableName, this.columnName, this.skyflowId, this.returnFileMetadata); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TableNameStage builder() { + return new Builder(); + } + + public interface TableNameStage { + /** + * Name of the table to upload the file to. + */ + ColumnNameStage tableName(@NotNull String tableName); + + Builder from(UploadFileV2Request other); + } + + public interface ColumnNameStage { + /** + * Name of the column to upload the file to. The column must have a `file` data type. + */ + _FinalStage columnName(@NotNull String columnName); + } + + public interface _FinalStage { + UploadFileV2Request build(); + + /** + *

Skyflow ID of the record to upload the file to. If skyflowID isn't specified, a new record will be created.

+ */ + _FinalStage skyflowId(Optional skyflowId); + + _FinalStage skyflowId(String skyflowId); + + /** + *

If true, returns metadata about the uploaded file.

+ */ + _FinalStage returnFileMetadata(Optional returnFileMetadata); + + _FinalStage returnFileMetadata(Boolean returnFileMetadata); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TableNameStage, ColumnNameStage, _FinalStage { + private String tableName; + + private String columnName; + + private Optional returnFileMetadata = Optional.empty(); + + private Optional skyflowId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UploadFileV2Request other) { + tableName(other.getTableName()); + columnName(other.getColumnName()); + skyflowId(other.getSkyflowId()); + returnFileMetadata(other.getReturnFileMetadata()); + return this; + } + + /** + * Name of the table to upload the file to.

Name of the table to upload the file to.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("tableName") + public ColumnNameStage tableName(@NotNull String tableName) { + this.tableName = Objects.requireNonNull(tableName, "tableName must not be null"); + return this; + } + + /** + * Name of the column to upload the file to. The column must have a `file` data type.

Name of the column to upload the file to. The column must have a file data type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("columnName") + public _FinalStage columnName(@NotNull String columnName) { + this.columnName = Objects.requireNonNull(columnName, "columnName must not be null"); + return this; + } + + /** + *

If true, returns metadata about the uploaded file.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage returnFileMetadata(Boolean returnFileMetadata) { + this.returnFileMetadata = Optional.ofNullable(returnFileMetadata); + return this; + } + + /** + *

If true, returns metadata about the uploaded file.

+ */ + @java.lang.Override + @JsonSetter(value = "returnFileMetadata", nulls = Nulls.SKIP) + public _FinalStage returnFileMetadata(Optional returnFileMetadata) { + this.returnFileMetadata = returnFileMetadata; + return this; + } + + /** + *

Skyflow ID of the record to upload the file to. If skyflowID isn't specified, a new record will be created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage skyflowId(String skyflowId) { + this.skyflowId = Optional.ofNullable(skyflowId); + return this; + } + + /** + *

Skyflow ID of the record to upload the file to. If skyflowID isn't specified, a new record will be created.

+ */ + @java.lang.Override + @JsonSetter(value = "skyflowID", nulls = Nulls.SKIP) + public _FinalStage skyflowId(Optional skyflowId) { + this.skyflowId = skyflowId; + return this; + } + + @java.lang.Override + public UploadFileV2Request build() { + return new UploadFileV2Request(tableName, columnName, skyflowId, returnFileMetadata, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java b/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java index 4a74fcba..18b6cd98 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java +++ b/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java @@ -29,6 +29,8 @@ public final class DeidentifyStringRequest { private final String text; + private final Optional configurationId; + private final Optional> entityTypes; private final Optional tokenType; @@ -44,6 +46,7 @@ public final class DeidentifyStringRequest { private DeidentifyStringRequest( String vaultId, String text, + Optional configurationId, Optional> entityTypes, Optional tokenType, Optional> allowRegex, @@ -52,6 +55,7 @@ private DeidentifyStringRequest( Map additionalProperties) { this.vaultId = vaultId; this.text = text; + this.configurationId = configurationId; this.entityTypes = entityTypes; this.tokenType = tokenType; this.allowRegex = allowRegex; @@ -73,6 +77,11 @@ public String getText() { return text; } + @JsonProperty("configuration_id") + public Optional getConfigurationId() { + return configurationId; + } + @JsonProperty("entity_types") public Optional> getEntityTypes() { return entityTypes; @@ -112,6 +121,7 @@ public Map getAdditionalProperties() { private boolean equalTo(DeidentifyStringRequest other) { return vaultId.equals(other.vaultId) && text.equals(other.text) + && configurationId.equals(other.configurationId) && entityTypes.equals(other.entityTypes) && tokenType.equals(other.tokenType) && allowRegex.equals(other.allowRegex) @@ -124,6 +134,7 @@ public int hashCode() { return Objects.hash( this.vaultId, this.text, + this.configurationId, this.entityTypes, this.tokenType, this.allowRegex, @@ -156,6 +167,10 @@ public interface TextStage { public interface _FinalStage { DeidentifyStringRequest build(); + _FinalStage configurationId(Optional configurationId); + + _FinalStage configurationId(String configurationId); + _FinalStage entityTypes(Optional> entityTypes); _FinalStage entityTypes(List entityTypes); @@ -193,6 +208,8 @@ public static final class Builder implements VaultIdStage, TextStage, _FinalStag private Optional> entityTypes = Optional.empty(); + private Optional configurationId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -202,6 +219,7 @@ private Builder() {} public Builder from(DeidentifyStringRequest other) { vaultId(other.getVaultId()); text(other.getText()); + configurationId(other.getConfigurationId()); entityTypes(other.getEntityTypes()); tokenType(other.getTokenType()); allowRegex(other.getAllowRegex()); @@ -293,11 +311,25 @@ public _FinalStage entityTypes(Optional> entityTypes) { return this; } + @java.lang.Override + public _FinalStage configurationId(String configurationId) { + this.configurationId = Optional.ofNullable(configurationId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "configuration_id", nulls = Nulls.SKIP) + public _FinalStage configurationId(Optional configurationId) { + this.configurationId = configurationId; + return this; + } + @java.lang.Override public DeidentifyStringRequest build() { return new DeidentifyStringRequest( vaultId, text, + configurationId, entityTypes, tokenType, allowRegex, diff --git a/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java b/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java deleted file mode 100644 index 0f5d1fc2..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AdvancedOptionsColumnMapping.Builder.class) -public final class AdvancedOptionsColumnMapping { - private final String sessionId; - - private final String default_; - - private final Optional> entityColumnMap; - - private final Map additionalProperties; - - private AdvancedOptionsColumnMapping( - String sessionId, - String default_, - Optional> entityColumnMap, - Map additionalProperties) { - this.sessionId = sessionId; - this.default_ = default_; - this.entityColumnMap = entityColumnMap; - this.additionalProperties = additionalProperties; - } - - /** - * @return Table name of the vault. - */ - @JsonProperty("session_id") - public String getSessionId() { - return sessionId; - } - - /** - * @return Name of column to store data in when no explicit mapping exists. - */ - @JsonProperty("default") - public String getDefault() { - return default_; - } - - /** - * @return Column mapping for different entities. - */ - @JsonProperty("entity_column_map") - public Optional> getEntityColumnMap() { - return entityColumnMap; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AdvancedOptionsColumnMapping && equalTo((AdvancedOptionsColumnMapping) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AdvancedOptionsColumnMapping other) { - return sessionId.equals(other.sessionId) - && default_.equals(other.default_) - && entityColumnMap.equals(other.entityColumnMap); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.sessionId, this.default_, this.entityColumnMap); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static SessionIdStage builder() { - return new Builder(); - } - - public interface SessionIdStage { - /** - * Table name of the vault. - */ - DefaultStage sessionId(@NotNull String sessionId); - - Builder from(AdvancedOptionsColumnMapping other); - } - - public interface DefaultStage { - /** - * Name of column to store data in when no explicit mapping exists. - */ - _FinalStage default_(@NotNull String default_); - } - - public interface _FinalStage { - AdvancedOptionsColumnMapping build(); - - /** - *

Column mapping for different entities.

- */ - _FinalStage entityColumnMap(Optional> entityColumnMap); - - _FinalStage entityColumnMap(List entityColumnMap); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SessionIdStage, DefaultStage, _FinalStage { - private String sessionId; - - private String default_; - - private Optional> entityColumnMap = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AdvancedOptionsColumnMapping other) { - sessionId(other.getSessionId()); - default_(other.getDefault()); - entityColumnMap(other.getEntityColumnMap()); - return this; - } - - /** - * Table name of the vault.

Table name of the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("session_id") - public DefaultStage sessionId(@NotNull String sessionId) { - this.sessionId = Objects.requireNonNull(sessionId, "sessionId must not be null"); - return this; - } - - /** - * Name of column to store data in when no explicit mapping exists.

Name of column to store data in when no explicit mapping exists.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("default") - public _FinalStage default_(@NotNull String default_) { - this.default_ = Objects.requireNonNull(default_, "default_ must not be null"); - return this; - } - - /** - *

Column mapping for different entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage entityColumnMap(List entityColumnMap) { - this.entityColumnMap = Optional.ofNullable(entityColumnMap); - return this; - } - - /** - *

Column mapping for different entities.

- */ - @java.lang.Override - @JsonSetter(value = "entity_column_map", nulls = Nulls.SKIP) - public _FinalStage entityColumnMap(Optional> entityColumnMap) { - this.entityColumnMap = entityColumnMap; - return this; - } - - @java.lang.Override - public AdvancedOptionsColumnMapping build() { - return new AdvancedOptionsColumnMapping(sessionId, default_, entityColumnMap, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java b/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java deleted file mode 100644 index 3df03da3..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AdvancedOptionsEntityColumnMap.Builder.class) -public final class AdvancedOptionsEntityColumnMap { - private final Optional entityType; - - private final Optional columnName; - - private final Map additionalProperties; - - private AdvancedOptionsEntityColumnMap( - Optional entityType, - Optional columnName, - Map additionalProperties) { - this.entityType = entityType; - this.columnName = columnName; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("entity_type") - public Optional getEntityType() { - return entityType; - } - - /** - * @return Column name where the entity has to be stored. - */ - @JsonProperty("column_name") - public Optional getColumnName() { - return columnName; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AdvancedOptionsEntityColumnMap && equalTo((AdvancedOptionsEntityColumnMap) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AdvancedOptionsEntityColumnMap other) { - return entityType.equals(other.entityType) && columnName.equals(other.columnName); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.entityType, this.columnName); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional entityType = Optional.empty(); - - private Optional columnName = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AdvancedOptionsEntityColumnMap other) { - entityType(other.getEntityType()); - columnName(other.getColumnName()); - return this; - } - - @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) - public Builder entityType(Optional entityType) { - this.entityType = entityType; - return this; - } - - public Builder entityType(DetectDataEntities entityType) { - this.entityType = Optional.ofNullable(entityType); - return this; - } - - /** - *

Column name where the entity has to be stored.

- */ - @JsonSetter(value = "column_name", nulls = Nulls.SKIP) - public Builder columnName(Optional columnName) { - this.columnName = columnName; - return this; - } - - public Builder columnName(String columnName) { - this.columnName = Optional.ofNullable(columnName); - return this; - } - - public AdvancedOptionsEntityColumnMap build() { - return new AdvancedOptionsEntityColumnMap(entityType, columnName, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java b/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java deleted file mode 100644 index dcacb09f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AdvancedOptionsVaultSchema.Builder.class) -public final class AdvancedOptionsVaultSchema { - private final String tableName; - - private final AdvancedOptionsColumnMapping mapping; - - private final Map additionalProperties; - - private AdvancedOptionsVaultSchema( - String tableName, AdvancedOptionsColumnMapping mapping, Map additionalProperties) { - this.tableName = tableName; - this.mapping = mapping; - this.additionalProperties = additionalProperties; - } - - /** - * @return Table name of the vault. - */ - @JsonProperty("table_name") - public String getTableName() { - return tableName; - } - - @JsonProperty("mapping") - public AdvancedOptionsColumnMapping getMapping() { - return mapping; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AdvancedOptionsVaultSchema && equalTo((AdvancedOptionsVaultSchema) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AdvancedOptionsVaultSchema other) { - return tableName.equals(other.tableName) && mapping.equals(other.mapping); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tableName, this.mapping); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TableNameStage builder() { - return new Builder(); - } - - public interface TableNameStage { - /** - * Table name of the vault. - */ - MappingStage tableName(@NotNull String tableName); - - Builder from(AdvancedOptionsVaultSchema other); - } - - public interface MappingStage { - _FinalStage mapping(@NotNull AdvancedOptionsColumnMapping mapping); - } - - public interface _FinalStage { - AdvancedOptionsVaultSchema build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TableNameStage, MappingStage, _FinalStage { - private String tableName; - - private AdvancedOptionsColumnMapping mapping; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AdvancedOptionsVaultSchema other) { - tableName(other.getTableName()); - mapping(other.getMapping()); - return this; - } - - /** - * Table name of the vault.

Table name of the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("table_name") - public MappingStage tableName(@NotNull String tableName) { - this.tableName = Objects.requireNonNull(tableName, "tableName must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("mapping") - public _FinalStage mapping(@NotNull AdvancedOptionsColumnMapping mapping) { - this.mapping = Objects.requireNonNull(mapping, "mapping must not be null"); - return this; - } - - @java.lang.Override - public AdvancedOptionsVaultSchema build() { - return new AdvancedOptionsVaultSchema(tableName, mapping, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java b/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java deleted file mode 100644 index e9052d16..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AudioConfigTranscriptionType { - NONE("none"), - - SKYFLOW_TRANSCRIPTION("skyflow_transcription"), - - AWS_TRANSCRIPTION("aws_transcription"), - - AWS_TRANSCRIPTION_DIARIZE("aws_transcription_diarize"), - - AWS_MEDICAL_TRANSCRIPTION("aws_medical_transcription"), - - AWS_MEDICAL_TRANSCRIPTION_DIARIZE("aws_medical_transcription_diarize"), - - AWS_TRANSCRIPTION_DIARIZE_JSON("aws_transcription_diarize_json"), - - DEEPGRAM_TRANSCRIPTION_DIARIZE("deepgram_transcription_diarize"), - - DEEPGRAM_TRANSCRIPTION_JSON("deepgram_transcription_json"), - - DEEPGRAM_WRAPPER("deepgram_wrapper"); - - private final String value; - - AudioConfigTranscriptionType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/CheckGuardrailsResponse.java b/src/main/java/com/skyflow/generated/rest/types/CheckGuardrailsResponse.java new file mode 100644 index 00000000..324cd1e6 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/types/CheckGuardrailsResponse.java @@ -0,0 +1,193 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CheckGuardrailsResponse.Builder.class) +public final class CheckGuardrailsResponse { + private final Optional text; + + private final Optional toxicity; + + private final Optional deniedTopics; + + private final Optional validation; + + private final Map additionalProperties; + + private CheckGuardrailsResponse( + Optional text, + Optional toxicity, + Optional deniedTopics, + Optional validation, + Map additionalProperties) { + this.text = text; + this.toxicity = toxicity; + this.deniedTopics = deniedTopics; + this.validation = validation; + this.additionalProperties = additionalProperties; + } + + /** + * @return Text that was checked against guardrails. + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + /** + * @return Whether the text is toxic. + */ + @JsonProperty("toxicity") + public Optional getToxicity() { + return toxicity; + } + + /** + * @return Whether any denied topics were found. + */ + @JsonProperty("denied_topics") + public Optional getDeniedTopics() { + return deniedTopics; + } + + /** + * @return Validation result. + */ + @JsonProperty("validation") + public Optional getValidation() { + return validation; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CheckGuardrailsResponse && equalTo((CheckGuardrailsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CheckGuardrailsResponse other) { + return text.equals(other.text) + && toxicity.equals(other.toxicity) + && deniedTopics.equals(other.deniedTopics) + && validation.equals(other.validation); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.text, this.toxicity, this.deniedTopics, this.validation); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional text = Optional.empty(); + + private Optional toxicity = Optional.empty(); + + private Optional deniedTopics = Optional.empty(); + + private Optional validation = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CheckGuardrailsResponse other) { + text(other.getText()); + toxicity(other.getToxicity()); + deniedTopics(other.getDeniedTopics()); + validation(other.getValidation()); + return this; + } + + /** + *

Text that was checked against guardrails.

+ */ + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.ofNullable(text); + return this; + } + + /** + *

Whether the text is toxic.

+ */ + @JsonSetter(value = "toxicity", nulls = Nulls.SKIP) + public Builder toxicity(Optional toxicity) { + this.toxicity = toxicity; + return this; + } + + public Builder toxicity(Boolean toxicity) { + this.toxicity = Optional.ofNullable(toxicity); + return this; + } + + /** + *

Whether any denied topics were found.

+ */ + @JsonSetter(value = "denied_topics", nulls = Nulls.SKIP) + public Builder deniedTopics(Optional deniedTopics) { + this.deniedTopics = deniedTopics; + return this; + } + + public Builder deniedTopics(Boolean deniedTopics) { + this.deniedTopics = Optional.ofNullable(deniedTopics); + return this; + } + + /** + *

Validation result.

+ */ + @JsonSetter(value = "validation", nulls = Nulls.SKIP) + public Builder validation(Optional validation) { + this.validation = validation; + return this; + } + + public Builder validation(CheckGuardrailsResponseValidation validation) { + this.validation = Optional.ofNullable(validation); + return this; + } + + public CheckGuardrailsResponse build() { + return new CheckGuardrailsResponse(text, toxicity, deniedTopics, validation, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java b/src/main/java/com/skyflow/generated/rest/types/CheckGuardrailsResponseValidation.java similarity index 70% rename from src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java rename to src/main/java/com/skyflow/generated/rest/types/CheckGuardrailsResponseValidation.java index e039bc86..2ff9edb8 100644 --- a/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java +++ b/src/main/java/com/skyflow/generated/rest/types/CheckGuardrailsResponseValidation.java @@ -5,14 +5,14 @@ import com.fasterxml.jackson.annotation.JsonValue; -public enum DetectFileRequestDataType { - UNKNOWN("UNKNOWN"), +public enum CheckGuardrailsResponseValidation { + FAILED("failed"), - BASE_64("BASE64"); + PASSED("passed"); private final String value; - DetectFileRequestDataType(String value) { + CheckGuardrailsResponseValidation(String value) { this.value = value; } diff --git a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java index 9f73e9ad..9beef0a2 100644 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java +++ b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java @@ -35,9 +35,9 @@ public final class DeidentifyStatusResponse { private final Optional characterCount; - private final Optional size; + private final Optional size; - private final Optional duration; + private final Optional duration; private final Optional pages; @@ -52,8 +52,8 @@ private DeidentifyStatusResponse( String message, Optional wordCount, Optional characterCount, - Optional size, - Optional duration, + Optional size, + Optional duration, Optional pages, Optional slides, Map additionalProperties) { @@ -122,7 +122,7 @@ public Optional getCharacterCount() { * @return Size of the processed text in kilobytes (KB). */ @JsonProperty("size") - public Optional getSize() { + public Optional getSize() { return size; } @@ -130,7 +130,7 @@ public Optional getSize() { * @return Duration of the processed audio in seconds. */ @JsonProperty("duration") - public Optional getDuration() { + public Optional getDuration() { return duration; } @@ -250,16 +250,16 @@ public interface _FinalStage { /** *

Size of the processed text in kilobytes (KB).

*/ - _FinalStage size(Optional size); + _FinalStage size(Optional size); - _FinalStage size(Integer size); + _FinalStage size(Double size); /** *

Duration of the processed audio in seconds.

*/ - _FinalStage duration(Optional duration); + _FinalStage duration(Optional duration); - _FinalStage duration(Integer duration); + _FinalStage duration(Double duration); /** *

Number of pages in the processed PDF.

@@ -288,9 +288,9 @@ public static final class Builder implements StatusStage, OutputTypeStage, Messa private Optional pages = Optional.empty(); - private Optional duration = Optional.empty(); + private Optional duration = Optional.empty(); - private Optional size = Optional.empty(); + private Optional size = Optional.empty(); private Optional characterCount = Optional.empty(); @@ -396,7 +396,7 @@ public _FinalStage pages(Optional pages) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage duration(Integer duration) { + public _FinalStage duration(Double duration) { this.duration = Optional.ofNullable(duration); return this; } @@ -406,7 +406,7 @@ public _FinalStage duration(Integer duration) { */ @java.lang.Override @JsonSetter(value = "duration", nulls = Nulls.SKIP) - public _FinalStage duration(Optional duration) { + public _FinalStage duration(Optional duration) { this.duration = duration; return this; } @@ -416,7 +416,7 @@ public _FinalStage duration(Optional duration) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage size(Integer size) { + public _FinalStage size(Double size) { this.size = Optional.ofNullable(size); return this; } @@ -426,7 +426,7 @@ public _FinalStage size(Integer size) { */ @java.lang.Override @JsonSetter(value = "size", nulls = Nulls.SKIP) - public _FinalStage size(Optional size) { + public _FinalStage size(Optional size) { this.size = size; return this; } diff --git a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java index 547bf414..4db4d813 100644 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java +++ b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java @@ -8,8 +8,6 @@ public enum DeidentifyStatusResponseOutputType { BASE_64("BASE64"), - EFS_PATH("EFS_PATH"), - UNKNOWN("UNKNOWN"); private final String value; diff --git a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java index 4e51e5cf..f03db2ed 100644 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java +++ b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java @@ -10,7 +10,9 @@ public enum DeidentifyStatusResponseStatus { IN_PROGRESS("IN_PROGRESS"), - SUCCESS("SUCCESS"); + SUCCESS("SUCCESS"), + + UNKNOWN("UNKNOWN"); private final String value; diff --git a/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java b/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java deleted file mode 100644 index 64afed64..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DetectDataAccuracy { - UNKNOWN("unknown"), - - STANDARD("standard"), - - STANDARD_PLUS("standard_plus"), - - STANDARD_PLUS_MULTILINGUAL("standard_plus_multilingual"), - - STANDARD_PLUS_AUTOMATIC("standard_plus_automatic"), - - HIGH("high"), - - HIGH_MULTILINGUAL("high_multilingual"), - - HIGH_AUTOMATIC("high_automatic"); - - private final String value; - - DetectDataAccuracy(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java b/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java deleted file mode 100644 index d655bb64..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DetectDataEntities { - AGE("age"), - - BANK_ACCOUNT("bank_account"), - - CREDIT_CARD("credit_card"), - - CREDIT_CARD_EXPIRATION("credit_card_expiration"), - - CVV("cvv"), - - DATE("date"), - - DATE_INTERVAL("date_interval"), - - DOB("dob"), - - DRIVER_LICENSE("driver_license"), - - EMAIL_ADDRESS("email_address"), - - HEALTHCARE_NUMBER("healthcare_number"), - - IP_ADDRESS("ip_address"), - - LOCATION("location"), - - NAME("name"), - - NUMERICAL_PII("numerical_pii"), - - PHONE_NUMBER("phone_number"), - - SSN("ssn"), - - URL("url"), - - VEHICLE_ID("vehicle_id"), - - MEDICAL_CODE("medical_code"), - - NAME_FAMILY("name_family"), - - NAME_GIVEN("name_given"), - - ACCOUNT_NUMBER("account_number"), - - EVENT("event"), - - FILENAME("filename"), - - GENDER_SEXUALITY("gender_sexuality"), - - LANGUAGE("language"), - - LOCATION_ADDRESS("location_address"), - - LOCATION_CITY("location_city"), - - LOCATION_COORDINATE("location_coordinate"), - - LOCATION_COUNTRY("location_country"), - - LOCATION_STATE("location_state"), - - LOCATION_ZIP("location_zip"), - - MARITAL_STATUS("marital_status"), - - MONEY("money"), - - NAME_MEDICAL_PROFESSIONAL("name_medical_professional"), - - OCCUPATION("occupation"), - - ORGANIZATION("organization"), - - ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), - - ORIGIN("origin"), - - PASSPORT_NUMBER("passport_number"), - - PASSWORD("password"), - - PHYSICAL_ATTRIBUTE("physical_attribute"), - - POLITICAL_AFFILIATION("political_affiliation"), - - RELIGION("religion"), - - TIME("time"), - - USERNAME("username"), - - ZODIAC_SIGN("zodiac_sign"), - - BLOOD_TYPE("blood_type"), - - CONDITION("condition"), - - DOSE("dose"), - - DRUG("drug"), - - INJURY("injury"), - - MEDICAL_PROCESS("medical_process"), - - STATISTICS("statistics"), - - ROUTING_NUMBER("routing_number"), - - CORPORATE_ACTION("corporate_action"), - - FINANCIAL_METRIC("financial_metric"), - - PRODUCT("product"), - - TREND("trend"), - - DURATION("duration"), - - LOCATION_ADDRESS_STREET("location_address_street"), - - ALL("all"); - - private final String value; - - DetectDataEntities(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/EntityType.java b/src/main/java/com/skyflow/generated/rest/types/EntityType.java index 605282ed..e6dcf699 100644 --- a/src/main/java/com/skyflow/generated/rest/types/EntityType.java +++ b/src/main/java/com/skyflow/generated/rest/types/EntityType.java @@ -30,6 +30,8 @@ public enum EntityType { DATE_INTERVAL("date_interval"), + DAY("day"), + DOB("dob"), DOSE("dose"), @@ -40,6 +42,8 @@ public enum EntityType { DURATION("duration"), + EFFECT("effect"), + EMAIL_ADDRESS("email_address"), EVENT("event"), @@ -48,7 +52,7 @@ public enum EntityType { FINANCIAL_METRIC("financial_metric"), - GENDER_SEXUALITY("gender_sexuality"), + GENDER("gender"), HEALTHCARE_NUMBER("healthcare_number"), @@ -82,6 +86,8 @@ public enum EntityType { MONEY("money"), + MONTH("month"), + NAME("name"), NAME_FAMILY("name_family"), @@ -96,6 +102,8 @@ public enum EntityType { ORGANIZATION("organization"), + ORGANIZATION_ID("organization_id"), + ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), ORIGIN("origin"), @@ -112,10 +120,14 @@ public enum EntityType { PRODUCT("product"), + PROJECT("project"), + RELIGION("religion"), ROUTING_NUMBER("routing_number"), + SEXUALITY("sexuality"), + SSN("ssn"), STATISTICS("statistics"), @@ -130,6 +142,8 @@ public enum EntityType { VEHICLE_ID("vehicle_id"), + YEAR("year"), + ZODIAC_SIGN("zodiac_sign"); private final String value; diff --git a/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java b/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java deleted file mode 100644 index 0563503c..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ProcessedFileOutputProcessedFileType { - NONE("none"), - - REDACTED_AUDIO("redacted_audio"), - - REDACTED_IMAGE("redacted_image"), - - REDACTED_TRANSCRIPTION("redacted_transcription"), - - REDACTED_FILE("redacted_file"), - - REDACTED_TEXT("redacted_text"), - - ENTITIES("entities"), - - REDACTED_AWS_TRANSCRIPTION_DIARIZE_JSON("redacted_aws_transcription_diarize_json"), - - REDACTED_DEEPGRAM_TRANSCRIPTION_DIARIZE_JSON("redacted_deepgram_transcription_diarize_json"), - - PLAINTEXT_TRANSCRIBED("plaintext_transcribed"); - - private final String value; - - ProcessedFileOutputProcessedFileType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponse.java b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponse.java new file mode 100644 index 00000000..46804db0 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponse.java @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReidentifyFileResponse.Builder.class) +public final class ReidentifyFileResponse { + private final ReidentifyFileResponseStatus status; + + private final ReidentifyFileResponseOutputType outputType; + + private final ReidentifyFileResponseOutput output; + + private final Map additionalProperties; + + private ReidentifyFileResponse( + ReidentifyFileResponseStatus status, + ReidentifyFileResponseOutputType outputType, + ReidentifyFileResponseOutput output, + Map additionalProperties) { + this.status = status; + this.outputType = outputType; + this.output = output; + this.additionalProperties = additionalProperties; + } + + /** + * @return Status of the re-identify operation. + */ + @JsonProperty("status") + public ReidentifyFileResponseStatus getStatus() { + return status; + } + + /** + * @return Format of the output file. + */ + @JsonProperty("output_type") + public ReidentifyFileResponseOutputType getOutputType() { + return outputType; + } + + @JsonProperty("output") + public ReidentifyFileResponseOutput getOutput() { + return output; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyFileResponse && equalTo((ReidentifyFileResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyFileResponse other) { + return status.equals(other.status) && outputType.equals(other.outputType) && output.equals(other.output); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status, this.outputType, this.output); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static StatusStage builder() { + return new Builder(); + } + + public interface StatusStage { + /** + * Status of the re-identify operation. + */ + OutputTypeStage status(@NotNull ReidentifyFileResponseStatus status); + + Builder from(ReidentifyFileResponse other); + } + + public interface OutputTypeStage { + /** + * Format of the output file. + */ + OutputStage outputType(@NotNull ReidentifyFileResponseOutputType outputType); + } + + public interface OutputStage { + _FinalStage output(@NotNull ReidentifyFileResponseOutput output); + } + + public interface _FinalStage { + ReidentifyFileResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements StatusStage, OutputTypeStage, OutputStage, _FinalStage { + private ReidentifyFileResponseStatus status; + + private ReidentifyFileResponseOutputType outputType; + + private ReidentifyFileResponseOutput output; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReidentifyFileResponse other) { + status(other.getStatus()); + outputType(other.getOutputType()); + output(other.getOutput()); + return this; + } + + /** + * Status of the re-identify operation.

Status of the re-identify operation.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("status") + public OutputTypeStage status(@NotNull ReidentifyFileResponseStatus status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + /** + * Format of the output file.

Format of the output file.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("output_type") + public OutputStage outputType(@NotNull ReidentifyFileResponseOutputType outputType) { + this.outputType = Objects.requireNonNull(outputType, "outputType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("output") + public _FinalStage output(@NotNull ReidentifyFileResponseOutput output) { + this.output = Objects.requireNonNull(output, "output must not be null"); + return this; + } + + @java.lang.Override + public ReidentifyFileResponse build() { + return new ReidentifyFileResponse(status, outputType, output, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseOutput.java b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseOutput.java new file mode 100644 index 00000000..266a9475 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseOutput.java @@ -0,0 +1,154 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReidentifyFileResponseOutput.Builder.class) +public final class ReidentifyFileResponseOutput { + private final String processedFile; + + private final String processedFileExtension; + + private final Map additionalProperties; + + private ReidentifyFileResponseOutput( + String processedFile, String processedFileExtension, Map additionalProperties) { + this.processedFile = processedFile; + this.processedFileExtension = processedFileExtension; + this.additionalProperties = additionalProperties; + } + + /** + * @return Re-identified file content in base64 format. + */ + @JsonProperty("processed_file") + public String getProcessedFile() { + return processedFile; + } + + /** + * @return Type of the processed file. + */ + @JsonProperty("processed_file_type") + public String getProcessedFileType() { + return "reidentified_file"; + } + + /** + * @return Extension of the processed file. + */ + @JsonProperty("processed_file_extension") + public String getProcessedFileExtension() { + return processedFileExtension; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyFileResponseOutput && equalTo((ReidentifyFileResponseOutput) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyFileResponseOutput other) { + return processedFile.equals(other.processedFile) && processedFileExtension.equals(other.processedFileExtension); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.processedFile, this.processedFileExtension); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProcessedFileStage builder() { + return new Builder(); + } + + public interface ProcessedFileStage { + /** + * Re-identified file content in base64 format. + */ + ProcessedFileExtensionStage processedFile(@NotNull String processedFile); + + Builder from(ReidentifyFileResponseOutput other); + } + + public interface ProcessedFileExtensionStage { + /** + * Extension of the processed file. + */ + _FinalStage processedFileExtension(@NotNull String processedFileExtension); + } + + public interface _FinalStage { + ReidentifyFileResponseOutput build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProcessedFileStage, ProcessedFileExtensionStage, _FinalStage { + private String processedFile; + + private String processedFileExtension; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReidentifyFileResponseOutput other) { + processedFile(other.getProcessedFile()); + processedFileExtension(other.getProcessedFileExtension()); + return this; + } + + /** + * Re-identified file content in base64 format.

Re-identified file content in base64 format.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("processed_file") + public ProcessedFileExtensionStage processedFile(@NotNull String processedFile) { + this.processedFile = Objects.requireNonNull(processedFile, "processedFile must not be null"); + return this; + } + + /** + * Extension of the processed file.

Extension of the processed file.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("processed_file_extension") + public _FinalStage processedFileExtension(@NotNull String processedFileExtension) { + this.processedFileExtension = + Objects.requireNonNull(processedFileExtension, "processedFileExtension must not be null"); + return this; + } + + @java.lang.Override + public ReidentifyFileResponseOutput build() { + return new ReidentifyFileResponseOutput(processedFile, processedFileExtension, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseOutputType.java similarity index 63% rename from src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java rename to src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseOutputType.java index bdc82ccf..167cb387 100644 --- a/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java +++ b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseOutputType.java @@ -5,16 +5,14 @@ import com.fasterxml.jackson.annotation.JsonValue; -public enum DetectRequestDeidentifyOption { - UNKNOWN("UNKNOWN"), +public enum ReidentifyFileResponseOutputType { + BASE_64("BASE64"), - ENTITY_UNQ_COUNTER("ENTITY_UNQ_COUNTER"), - - ENTITY_ONLY("ENTITY_ONLY"); + UNKNOWN("UNKNOWN"); private final String value; - DetectRequestDeidentifyOption(String value) { + ReidentifyFileResponseOutputType(String value) { this.value = value; } diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseStatus.java similarity index 72% rename from src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java rename to src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseStatus.java index c819b167..7b56adcf 100644 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java +++ b/src/main/java/com/skyflow/generated/rest/types/ReidentifyFileResponseStatus.java @@ -5,18 +5,18 @@ import com.fasterxml.jackson.annotation.JsonValue; -public enum V1DetectStatusResponseStatus { - UNKNOWN("UNKNOWN"), - +public enum ReidentifyFileResponseStatus { FAILED("FAILED"), + IN_PROGRESS("IN_PROGRESS"), + SUCCESS("SUCCESS"), - IN_PROGRESS("IN_PROGRESS"); + UNKNOWN("UNKNOWN"); private final String value; - V1DetectStatusResponseStatus(String value) { + ReidentifyFileResponseStatus(String value) { this.value = value; } diff --git a/src/main/java/com/skyflow/generated/rest/types/UploadFileV2Response.java b/src/main/java/com/skyflow/generated/rest/types/UploadFileV2Response.java new file mode 100644 index 00000000..85f98bd1 --- /dev/null +++ b/src/main/java/com/skyflow/generated/rest/types/UploadFileV2Response.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UploadFileV2Response.Builder.class) +public final class UploadFileV2Response { + private final Optional skyflowId; + + private final Optional fileMetadata; + + private final Map additionalProperties; + + private UploadFileV2Response( + Optional skyflowId, Optional fileMetadata, Map additionalProperties) { + this.skyflowId = skyflowId; + this.fileMetadata = fileMetadata; + this.additionalProperties = additionalProperties; + } + + /** + * @return Skyflow ID of the record the file was uploaded to. + */ + @JsonProperty("skyflowID") + public Optional getSkyflowId() { + return skyflowId; + } + + @JsonProperty("fileMetadata") + public Optional getFileMetadata() { + return fileMetadata; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UploadFileV2Response && equalTo((UploadFileV2Response) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UploadFileV2Response other) { + return skyflowId.equals(other.skyflowId) && fileMetadata.equals(other.fileMetadata); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.fileMetadata); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional skyflowId = Optional.empty(); + + private Optional fileMetadata = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UploadFileV2Response other) { + skyflowId(other.getSkyflowId()); + fileMetadata(other.getFileMetadata()); + return this; + } + + /** + *

Skyflow ID of the record the file was uploaded to.

+ */ + @JsonSetter(value = "skyflowID", nulls = Nulls.SKIP) + public Builder skyflowId(Optional skyflowId) { + this.skyflowId = skyflowId; + return this; + } + + public Builder skyflowId(String skyflowId) { + this.skyflowId = Optional.ofNullable(skyflowId); + return this; + } + + @JsonSetter(value = "fileMetadata", nulls = Nulls.SKIP) + public Builder fileMetadata(Optional fileMetadata) { + this.fileMetadata = fileMetadata; + return this; + } + + public Builder fileMetadata(Object fileMetadata) { + this.fileMetadata = Optional.ofNullable(fileMetadata); + return this; + } + + public UploadFileV2Response build() { + return new UploadFileV2Response(skyflowId, fileMetadata, additionalProperties); + } + } +} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java b/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java deleted file mode 100644 index 999153e4..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1AdvancedOptions.Builder.class) -public final class V1AdvancedOptions { - private final Optional dateShift; - - private final Optional customClient; - - private final Optional schema; - - private final Map additionalProperties; - - private V1AdvancedOptions( - Optional dateShift, - Optional customClient, - Optional schema, - Map additionalProperties) { - this.dateShift = dateShift; - this.customClient = customClient; - this.schema = schema; - this.additionalProperties = additionalProperties; - } - - /** - * @return No. of days by which original date has to be shifted to. - */ - @JsonProperty("date_shift") - public Optional getDateShift() { - return dateShift; - } - - /** - * @return Custom client specific logic. - */ - @JsonProperty("custom_client") - public Optional getCustomClient() { - return customClient; - } - - @JsonProperty("schema") - public Optional getSchema() { - return schema; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AdvancedOptions && equalTo((V1AdvancedOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AdvancedOptions other) { - return dateShift.equals(other.dateShift) - && customClient.equals(other.customClient) - && schema.equals(other.schema); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.dateShift, this.customClient, this.schema); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional dateShift = Optional.empty(); - - private Optional customClient = Optional.empty(); - - private Optional schema = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AdvancedOptions other) { - dateShift(other.getDateShift()); - customClient(other.getCustomClient()); - schema(other.getSchema()); - return this; - } - - /** - *

No. of days by which original date has to be shifted to.

- */ - @JsonSetter(value = "date_shift", nulls = Nulls.SKIP) - public Builder dateShift(Optional dateShift) { - this.dateShift = dateShift; - return this; - } - - public Builder dateShift(Integer dateShift) { - this.dateShift = Optional.ofNullable(dateShift); - return this; - } - - /** - *

Custom client specific logic.

- */ - @JsonSetter(value = "custom_client", nulls = Nulls.SKIP) - public Builder customClient(Optional customClient) { - this.customClient = customClient; - return this; - } - - public Builder customClient(Boolean customClient) { - this.customClient = Optional.ofNullable(customClient); - return this; - } - - @JsonSetter(value = "schema", nulls = Nulls.SKIP) - public Builder schema(Optional schema) { - this.schema = schema; - return this; - } - - public Builder schema(AdvancedOptionsVaultSchema schema) { - this.schema = Optional.ofNullable(schema); - return this; - } - - public V1AdvancedOptions build() { - return new V1AdvancedOptions(dateShift, customClient, schema, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java b/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java deleted file mode 100644 index 50e5508a..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1AudioConfig.Builder.class) -public final class V1AudioConfig { - private final Optional outputTranscription; - - private final Optional outputProcessedAudio; - - private final Optional options; - - private final Map additionalProperties; - - private V1AudioConfig( - Optional outputTranscription, - Optional outputProcessedAudio, - Optional options, - Map additionalProperties) { - this.outputTranscription = outputTranscription; - this.outputProcessedAudio = outputProcessedAudio; - this.options = options; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("output_transcription") - public Optional getOutputTranscription() { - return outputTranscription; - } - - /** - * @return If true, includes processed audio file in the response. - */ - @JsonProperty("output_processed_audio") - public Optional getOutputProcessedAudio() { - return outputProcessedAudio; - } - - @JsonProperty("options") - public Optional getOptions() { - return options; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AudioConfig && equalTo((V1AudioConfig) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AudioConfig other) { - return outputTranscription.equals(other.outputTranscription) - && outputProcessedAudio.equals(other.outputProcessedAudio) - && options.equals(other.options); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.outputTranscription, this.outputProcessedAudio, this.options); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional outputTranscription = Optional.empty(); - - private Optional outputProcessedAudio = Optional.empty(); - - private Optional options = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AudioConfig other) { - outputTranscription(other.getOutputTranscription()); - outputProcessedAudio(other.getOutputProcessedAudio()); - options(other.getOptions()); - return this; - } - - @JsonSetter(value = "output_transcription", nulls = Nulls.SKIP) - public Builder outputTranscription(Optional outputTranscription) { - this.outputTranscription = outputTranscription; - return this; - } - - public Builder outputTranscription(AudioConfigTranscriptionType outputTranscription) { - this.outputTranscription = Optional.ofNullable(outputTranscription); - return this; - } - - /** - *

If true, includes processed audio file in the response.

- */ - @JsonSetter(value = "output_processed_audio", nulls = Nulls.SKIP) - public Builder outputProcessedAudio(Optional outputProcessedAudio) { - this.outputProcessedAudio = outputProcessedAudio; - return this; - } - - public Builder outputProcessedAudio(Boolean outputProcessedAudio) { - this.outputProcessedAudio = Optional.ofNullable(outputProcessedAudio); - return this; - } - - @JsonSetter(value = "options", nulls = Nulls.SKIP) - public Builder options(Optional options) { - this.options = options; - return this; - } - - public Builder options(V1AudioOptions options) { - this.options = Optional.ofNullable(options); - return this; - } - - public V1AudioConfig build() { - return new V1AudioConfig(outputTranscription, outputProcessedAudio, options, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java b/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java deleted file mode 100644 index d71b77a0..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java +++ /dev/null @@ -1,234 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1AudioOptions.Builder.class) -public final class V1AudioOptions { - private final Optional bleepStartPadding; - - private final Optional bleepEndPadding; - - private final Optional distortionSteps; - - private final Optional bleepFrequency; - - private final Optional bleepGain; - - private final Map additionalProperties; - - private V1AudioOptions( - Optional bleepStartPadding, - Optional bleepEndPadding, - Optional distortionSteps, - Optional bleepFrequency, - Optional bleepGain, - Map additionalProperties) { - this.bleepStartPadding = bleepStartPadding; - this.bleepEndPadding = bleepEndPadding; - this.distortionSteps = distortionSteps; - this.bleepFrequency = bleepFrequency; - this.bleepGain = bleepGain; - this.additionalProperties = additionalProperties; - } - - /** - * @return Padding added to the beginning of a bleep, in seconds. - */ - @JsonProperty("bleep_start_padding") - public Optional getBleepStartPadding() { - return bleepStartPadding; - } - - /** - * @return Padding added to the end of a bleep, in seconds. - */ - @JsonProperty("bleep_end_padding") - public Optional getBleepEndPadding() { - return bleepEndPadding; - } - - /** - * @return Specifies how the distortion will be made. Providing a number more than 0 will result in a higher tone and a coefficient less than 0 will result in a lower tone. - */ - @JsonProperty("distortion_steps") - public Optional getDistortionSteps() { - return distortionSteps; - } - - /** - * @return This parameter configures the frequency of the sine wave used for the bleep sound in an audio segment. - */ - @JsonProperty("bleep_frequency") - public Optional getBleepFrequency() { - return bleepFrequency; - } - - /** - * @return It controls the relative loudness of the bleep,positive values increase its loudness, and negative values decrease it. - */ - @JsonProperty("bleep_gain") - public Optional getBleepGain() { - return bleepGain; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AudioOptions && equalTo((V1AudioOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AudioOptions other) { - return bleepStartPadding.equals(other.bleepStartPadding) - && bleepEndPadding.equals(other.bleepEndPadding) - && distortionSteps.equals(other.distortionSteps) - && bleepFrequency.equals(other.bleepFrequency) - && bleepGain.equals(other.bleepGain); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.bleepStartPadding, - this.bleepEndPadding, - this.distortionSteps, - this.bleepFrequency, - this.bleepGain); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional bleepStartPadding = Optional.empty(); - - private Optional bleepEndPadding = Optional.empty(); - - private Optional distortionSteps = Optional.empty(); - - private Optional bleepFrequency = Optional.empty(); - - private Optional bleepGain = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AudioOptions other) { - bleepStartPadding(other.getBleepStartPadding()); - bleepEndPadding(other.getBleepEndPadding()); - distortionSteps(other.getDistortionSteps()); - bleepFrequency(other.getBleepFrequency()); - bleepGain(other.getBleepGain()); - return this; - } - - /** - *

Padding added to the beginning of a bleep, in seconds.

- */ - @JsonSetter(value = "bleep_start_padding", nulls = Nulls.SKIP) - public Builder bleepStartPadding(Optional bleepStartPadding) { - this.bleepStartPadding = bleepStartPadding; - return this; - } - - public Builder bleepStartPadding(Float bleepStartPadding) { - this.bleepStartPadding = Optional.ofNullable(bleepStartPadding); - return this; - } - - /** - *

Padding added to the end of a bleep, in seconds.

- */ - @JsonSetter(value = "bleep_end_padding", nulls = Nulls.SKIP) - public Builder bleepEndPadding(Optional bleepEndPadding) { - this.bleepEndPadding = bleepEndPadding; - return this; - } - - public Builder bleepEndPadding(Float bleepEndPadding) { - this.bleepEndPadding = Optional.ofNullable(bleepEndPadding); - return this; - } - - /** - *

Specifies how the distortion will be made. Providing a number more than 0 will result in a higher tone and a coefficient less than 0 will result in a lower tone.

- */ - @JsonSetter(value = "distortion_steps", nulls = Nulls.SKIP) - public Builder distortionSteps(Optional distortionSteps) { - this.distortionSteps = distortionSteps; - return this; - } - - public Builder distortionSteps(Integer distortionSteps) { - this.distortionSteps = Optional.ofNullable(distortionSteps); - return this; - } - - /** - *

This parameter configures the frequency of the sine wave used for the bleep sound in an audio segment.

- */ - @JsonSetter(value = "bleep_frequency", nulls = Nulls.SKIP) - public Builder bleepFrequency(Optional bleepFrequency) { - this.bleepFrequency = bleepFrequency; - return this; - } - - public Builder bleepFrequency(Integer bleepFrequency) { - this.bleepFrequency = Optional.ofNullable(bleepFrequency); - return this; - } - - /** - *

It controls the relative loudness of the bleep,positive values increase its loudness, and negative values decrease it.

- */ - @JsonSetter(value = "bleep_gain", nulls = Nulls.SKIP) - public Builder bleepGain(Optional bleepGain) { - this.bleepGain = bleepGain; - return this; - } - - public Builder bleepGain(Integer bleepGain) { - this.bleepGain = Optional.ofNullable(bleepGain); - return this; - } - - public V1AudioOptions build() { - return new V1AudioOptions( - bleepStartPadding, - bleepEndPadding, - distortionSteps, - bleepFrequency, - bleepGain, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java deleted file mode 100644 index 0c309cb9..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1DetectFileResponse.Builder.class) -public final class V1DetectFileResponse { - private final Optional statusUrl; - - private final Map additionalProperties; - - private V1DetectFileResponse(Optional statusUrl, Map additionalProperties) { - this.statusUrl = statusUrl; - this.additionalProperties = additionalProperties; - } - - /** - * @return Status URL for the deidentification request. - */ - @JsonProperty("status_url") - public Optional getStatusUrl() { - return statusUrl; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetectFileResponse && equalTo((V1DetectFileResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetectFileResponse other) { - return statusUrl.equals(other.statusUrl); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.statusUrl); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional statusUrl = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetectFileResponse other) { - statusUrl(other.getStatusUrl()); - return this; - } - - /** - *

Status URL for the deidentification request.

- */ - @JsonSetter(value = "status_url", nulls = Nulls.SKIP) - public Builder statusUrl(Optional statusUrl) { - this.statusUrl = statusUrl; - return this; - } - - public Builder statusUrl(String statusUrl) { - this.statusUrl = Optional.ofNullable(statusUrl); - return this; - } - - public V1DetectFileResponse build() { - return new V1DetectFileResponse(statusUrl, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java deleted file mode 100644 index 95e7845c..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1DetectStatusResponse.Builder.class) -public final class V1DetectStatusResponse { - private final Optional status; - - private final Optional> output; - - private final Optional message; - - private final Map additionalProperties; - - private V1DetectStatusResponse( - Optional status, - Optional> output, - Optional message, - Map additionalProperties) { - this.status = status; - this.output = output; - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public Optional getStatus() { - return status; - } - - /** - * @return How the input file was specified. - */ - @JsonProperty("output") - public Optional> getOutput() { - return output; - } - - /** - * @return Status details about the deidentification request. - */ - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetectStatusResponse && equalTo((V1DetectStatusResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetectStatusResponse other) { - return status.equals(other.status) && output.equals(other.output) && message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.status, this.output, this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional status = Optional.empty(); - - private Optional> output = Optional.empty(); - - private Optional message = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetectStatusResponse other) { - status(other.getStatus()); - output(other.getOutput()); - message(other.getMessage()); - return this; - } - - @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { - this.status = status; - return this; - } - - public Builder status(V1DetectStatusResponseStatus status) { - this.status = Optional.ofNullable(status); - return this; - } - - /** - *

How the input file was specified.

- */ - @JsonSetter(value = "output", nulls = Nulls.SKIP) - public Builder output(Optional> output) { - this.output = output; - return this; - } - - public Builder output(List output) { - this.output = Optional.ofNullable(output); - return this; - } - - /** - *

Status details about the deidentification request.

- */ - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public Builder message(Optional message) { - this.message = message; - return this; - } - - public Builder message(String message) { - this.message = Optional.ofNullable(message); - return this; - } - - public V1DetectStatusResponse build() { - return new V1DetectStatusResponse(status, output, message, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java b/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java deleted file mode 100644 index 57778d80..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java +++ /dev/null @@ -1,522 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1DetectTextRequest.Builder.class) -public final class V1DetectTextRequest { - private final String text; - - private final String vaultId; - - private final Optional sessionId; - - private final Optional> restrictEntityTypes; - - private final Optional deidentifyTokenFormat; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional returnEntities; - - private final Optional accuracy; - - private final Optional advancedOptions; - - private final Optional storeEntities; - - private final Map additionalProperties; - - private V1DetectTextRequest( - String text, - String vaultId, - Optional sessionId, - Optional> restrictEntityTypes, - Optional deidentifyTokenFormat, - Optional> allowRegex, - Optional> restrictRegex, - Optional returnEntities, - Optional accuracy, - Optional advancedOptions, - Optional storeEntities, - Map additionalProperties) { - this.text = text; - this.vaultId = vaultId; - this.sessionId = sessionId; - this.restrictEntityTypes = restrictEntityTypes; - this.deidentifyTokenFormat = deidentifyTokenFormat; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.returnEntities = returnEntities; - this.accuracy = accuracy; - this.advancedOptions = advancedOptions; - this.storeEntities = storeEntities; - this.additionalProperties = additionalProperties; - } - - /** - * @return Data to deidentify. - */ - @JsonProperty("text") - public String getText() { - return text; - } - - /** - * @return ID of the vault. - */ - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return Will give a handle to delete the tokens generated during a specific interaction. - */ - @JsonProperty("session_id") - public Optional getSessionId() { - return sessionId; - } - - /** - * @return Entities to detect and deidentify. - */ - @JsonProperty("restrict_entity_types") - public Optional> getRestrictEntityTypes() { - return restrictEntityTypes; - } - - @JsonProperty("deidentify_token_format") - public Optional getDeidentifyTokenFormat() { - return deidentifyTokenFormat; - } - - /** - * @return Regular expressions to ignore when detecting entities. - */ - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - /** - * @return Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'. - */ - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - /** - * @return If true, returns the details for the detected entities. - */ - @JsonProperty("return_entities") - public Optional getReturnEntities() { - return returnEntities; - } - - @JsonProperty("accuracy") - public Optional getAccuracy() { - return accuracy; - } - - @JsonProperty("advanced_options") - public Optional getAdvancedOptions() { - return advancedOptions; - } - - /** - * @return Indicates whether entities should be stored in the vault. - */ - @JsonProperty("store_entities") - public Optional getStoreEntities() { - return storeEntities; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetectTextRequest && equalTo((V1DetectTextRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetectTextRequest other) { - return text.equals(other.text) - && vaultId.equals(other.vaultId) - && sessionId.equals(other.sessionId) - && restrictEntityTypes.equals(other.restrictEntityTypes) - && deidentifyTokenFormat.equals(other.deidentifyTokenFormat) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && returnEntities.equals(other.returnEntities) - && accuracy.equals(other.accuracy) - && advancedOptions.equals(other.advancedOptions) - && storeEntities.equals(other.storeEntities); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.text, - this.vaultId, - this.sessionId, - this.restrictEntityTypes, - this.deidentifyTokenFormat, - this.allowRegex, - this.restrictRegex, - this.returnEntities, - this.accuracy, - this.advancedOptions, - this.storeEntities); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TextStage builder() { - return new Builder(); - } - - public interface TextStage { - /** - * Data to deidentify. - */ - VaultIdStage text(@NotNull String text); - - Builder from(V1DetectTextRequest other); - } - - public interface VaultIdStage { - /** - * ID of the vault. - */ - _FinalStage vaultId(@NotNull String vaultId); - } - - public interface _FinalStage { - V1DetectTextRequest build(); - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- */ - _FinalStage sessionId(Optional sessionId); - - _FinalStage sessionId(String sessionId); - - /** - *

Entities to detect and deidentify.

- */ - _FinalStage restrictEntityTypes(Optional> restrictEntityTypes); - - _FinalStage restrictEntityTypes(List restrictEntityTypes); - - _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat); - - _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat); - - /** - *

Regular expressions to ignore when detecting entities.

- */ - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- */ - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - /** - *

If true, returns the details for the detected entities.

- */ - _FinalStage returnEntities(Optional returnEntities); - - _FinalStage returnEntities(Boolean returnEntities); - - _FinalStage accuracy(Optional accuracy); - - _FinalStage accuracy(DetectDataAccuracy accuracy); - - _FinalStage advancedOptions(Optional advancedOptions); - - _FinalStage advancedOptions(V1AdvancedOptions advancedOptions); - - /** - *

Indicates whether entities should be stored in the vault.

- */ - _FinalStage storeEntities(Optional storeEntities); - - _FinalStage storeEntities(Boolean storeEntities); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TextStage, VaultIdStage, _FinalStage { - private String text; - - private String vaultId; - - private Optional storeEntities = Optional.empty(); - - private Optional advancedOptions = Optional.empty(); - - private Optional accuracy = Optional.empty(); - - private Optional returnEntities = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional deidentifyTokenFormat = Optional.empty(); - - private Optional> restrictEntityTypes = Optional.empty(); - - private Optional sessionId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(V1DetectTextRequest other) { - text(other.getText()); - vaultId(other.getVaultId()); - sessionId(other.getSessionId()); - restrictEntityTypes(other.getRestrictEntityTypes()); - deidentifyTokenFormat(other.getDeidentifyTokenFormat()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - returnEntities(other.getReturnEntities()); - accuracy(other.getAccuracy()); - advancedOptions(other.getAdvancedOptions()); - storeEntities(other.getStoreEntities()); - return this; - } - - /** - * Data to deidentify.

Data to deidentify.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("text") - public VaultIdStage text(@NotNull String text) { - this.text = Objects.requireNonNull(text, "text must not be null"); - return this; - } - - /** - * ID of the vault.

ID of the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("vault_id") - public _FinalStage vaultId(@NotNull String vaultId) { - this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); - return this; - } - - /** - *

Indicates whether entities should be stored in the vault.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage storeEntities(Boolean storeEntities) { - this.storeEntities = Optional.ofNullable(storeEntities); - return this; - } - - /** - *

Indicates whether entities should be stored in the vault.

- */ - @java.lang.Override - @JsonSetter(value = "store_entities", nulls = Nulls.SKIP) - public _FinalStage storeEntities(Optional storeEntities) { - this.storeEntities = storeEntities; - return this; - } - - @java.lang.Override - public _FinalStage advancedOptions(V1AdvancedOptions advancedOptions) { - this.advancedOptions = Optional.ofNullable(advancedOptions); - return this; - } - - @java.lang.Override - @JsonSetter(value = "advanced_options", nulls = Nulls.SKIP) - public _FinalStage advancedOptions(Optional advancedOptions) { - this.advancedOptions = advancedOptions; - return this; - } - - @java.lang.Override - public _FinalStage accuracy(DetectDataAccuracy accuracy) { - this.accuracy = Optional.ofNullable(accuracy); - return this; - } - - @java.lang.Override - @JsonSetter(value = "accuracy", nulls = Nulls.SKIP) - public _FinalStage accuracy(Optional accuracy) { - this.accuracy = accuracy; - return this; - } - - /** - *

If true, returns the details for the detected entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage returnEntities(Boolean returnEntities) { - this.returnEntities = Optional.ofNullable(returnEntities); - return this; - } - - /** - *

If true, returns the details for the detected entities.

- */ - @java.lang.Override - @JsonSetter(value = "return_entities", nulls = Nulls.SKIP) - public _FinalStage returnEntities(Optional returnEntities) { - this.returnEntities = returnEntities; - return this; - } - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - /** - *

Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'.

- */ - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - /** - *

Regular expressions to ignore when detecting entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - /** - *

Regular expressions to ignore when detecting entities.

- */ - @java.lang.Override - @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) - public _FinalStage allowRegex(Optional> allowRegex) { - this.allowRegex = allowRegex; - return this; - } - - @java.lang.Override - public _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat) { - this.deidentifyTokenFormat = Optional.ofNullable(deidentifyTokenFormat); - return this; - } - - @java.lang.Override - @JsonSetter(value = "deidentify_token_format", nulls = Nulls.SKIP) - public _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat) { - this.deidentifyTokenFormat = deidentifyTokenFormat; - return this; - } - - /** - *

Entities to detect and deidentify.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage restrictEntityTypes(List restrictEntityTypes) { - this.restrictEntityTypes = Optional.ofNullable(restrictEntityTypes); - return this; - } - - /** - *

Entities to detect and deidentify.

- */ - @java.lang.Override - @JsonSetter(value = "restrict_entity_types", nulls = Nulls.SKIP) - public _FinalStage restrictEntityTypes(Optional> restrictEntityTypes) { - this.restrictEntityTypes = restrictEntityTypes; - return this; - } - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sessionId(String sessionId) { - this.sessionId = Optional.ofNullable(sessionId); - return this; - } - - /** - *

Will give a handle to delete the tokens generated during a specific interaction.

- */ - @java.lang.Override - @JsonSetter(value = "session_id", nulls = Nulls.SKIP) - public _FinalStage sessionId(Optional sessionId) { - this.sessionId = sessionId; - return this; - } - - @java.lang.Override - public V1DetectTextRequest build() { - return new V1DetectTextRequest( - text, - vaultId, - sessionId, - restrictEntityTypes, - deidentifyTokenFormat, - allowRegex, - restrictRegex, - returnEntities, - accuracy, - advancedOptions, - storeEntities, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java deleted file mode 100644 index a07c3344..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1DetectTextResponse.Builder.class) -public final class V1DetectTextResponse { - private final Optional processedText; - - private final Optional> entities; - - private final Map additionalProperties; - - private V1DetectTextResponse( - Optional processedText, - Optional> entities, - Map additionalProperties) { - this.processedText = processedText; - this.entities = entities; - this.additionalProperties = additionalProperties; - } - - /** - * @return Deidentified text. If the input was a file, text that was extracted or transcribed from the file and deidentified. - */ - @JsonProperty("processed_text") - public Optional getProcessedText() { - return processedText; - } - - /** - * @return Detected entities. - */ - @JsonProperty("entities") - public Optional> getEntities() { - return entities; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetectTextResponse && equalTo((V1DetectTextResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetectTextResponse other) { - return processedText.equals(other.processedText) && entities.equals(other.entities); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.processedText, this.entities); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional processedText = Optional.empty(); - - private Optional> entities = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetectTextResponse other) { - processedText(other.getProcessedText()); - entities(other.getEntities()); - return this; - } - - /** - *

Deidentified text. If the input was a file, text that was extracted or transcribed from the file and deidentified.

- */ - @JsonSetter(value = "processed_text", nulls = Nulls.SKIP) - public Builder processedText(Optional processedText) { - this.processedText = processedText; - return this; - } - - public Builder processedText(String processedText) { - this.processedText = Optional.ofNullable(processedText); - return this; - } - - /** - *

Detected entities.

- */ - @JsonSetter(value = "entities", nulls = Nulls.SKIP) - public Builder entities(Optional> entities) { - this.entities = entities; - return this; - } - - public Builder entities(List entities) { - this.entities = Optional.ofNullable(entities); - return this; - } - - public V1DetectTextResponse build() { - return new V1DetectTextResponse(processedText, entities, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java b/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java deleted file mode 100644 index cd40fb5b..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1ImageOptions.Builder.class) -public final class V1ImageOptions { - private final Optional outputProcessedImage; - - private final Optional outputOcrText; - - private final Map additionalProperties; - - private V1ImageOptions( - Optional outputProcessedImage, - Optional outputOcrText, - Map additionalProperties) { - this.outputProcessedImage = outputProcessedImage; - this.outputOcrText = outputOcrText; - this.additionalProperties = additionalProperties; - } - - /** - * @return If true, includes processed image in the output. - */ - @JsonProperty("output_processed_image") - public Optional getOutputProcessedImage() { - return outputProcessedImage; - } - - /** - * @return If true, includes OCR text output in the response. - */ - @JsonProperty("output_ocr_text") - public Optional getOutputOcrText() { - return outputOcrText; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1ImageOptions && equalTo((V1ImageOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1ImageOptions other) { - return outputProcessedImage.equals(other.outputProcessedImage) && outputOcrText.equals(other.outputOcrText); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.outputProcessedImage, this.outputOcrText); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional outputProcessedImage = Optional.empty(); - - private Optional outputOcrText = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1ImageOptions other) { - outputProcessedImage(other.getOutputProcessedImage()); - outputOcrText(other.getOutputOcrText()); - return this; - } - - /** - *

If true, includes processed image in the output.

- */ - @JsonSetter(value = "output_processed_image", nulls = Nulls.SKIP) - public Builder outputProcessedImage(Optional outputProcessedImage) { - this.outputProcessedImage = outputProcessedImage; - return this; - } - - public Builder outputProcessedImage(Boolean outputProcessedImage) { - this.outputProcessedImage = Optional.ofNullable(outputProcessedImage); - return this; - } - - /** - *

If true, includes OCR text output in the response.

- */ - @JsonSetter(value = "output_ocr_text", nulls = Nulls.SKIP) - public Builder outputOcrText(Optional outputOcrText) { - this.outputOcrText = outputOcrText; - return this; - } - - public Builder outputOcrText(Boolean outputOcrText) { - this.outputOcrText = Optional.ofNullable(outputOcrText); - return this; - } - - public V1ImageOptions build() { - return new V1ImageOptions(outputProcessedImage, outputOcrText, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1Locations.java b/src/main/java/com/skyflow/generated/rest/types/V1Locations.java deleted file mode 100644 index ef1593ca..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1Locations.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1Locations.Builder.class) -public final class V1Locations { - private final Optional startIndex; - - private final Optional endIndex; - - private final Optional startIndexProcessed; - - private final Optional endIndexProcessed; - - private final Map additionalProperties; - - private V1Locations( - Optional startIndex, - Optional endIndex, - Optional startIndexProcessed, - Optional endIndexProcessed, - Map additionalProperties) { - this.startIndex = startIndex; - this.endIndex = endIndex; - this.startIndexProcessed = startIndexProcessed; - this.endIndexProcessed = endIndexProcessed; - this.additionalProperties = additionalProperties; - } - - /** - * @return Index of the first character of the string in the original text. - */ - @JsonProperty("start_index") - public Optional getStartIndex() { - return startIndex; - } - - /** - * @return Index of the last character of the string in the original text. - */ - @JsonProperty("end_index") - public Optional getEndIndex() { - return endIndex; - } - - /** - * @return Index of the first character of the string in the processed text. - */ - @JsonProperty("start_index_processed") - public Optional getStartIndexProcessed() { - return startIndexProcessed; - } - - /** - * @return Index of the last character of the string in the processed text. - */ - @JsonProperty("end_index_processed") - public Optional getEndIndexProcessed() { - return endIndexProcessed; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Locations && equalTo((V1Locations) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1Locations other) { - return startIndex.equals(other.startIndex) - && endIndex.equals(other.endIndex) - && startIndexProcessed.equals(other.startIndexProcessed) - && endIndexProcessed.equals(other.endIndexProcessed); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.startIndex, this.endIndex, this.startIndexProcessed, this.endIndexProcessed); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional startIndex = Optional.empty(); - - private Optional endIndex = Optional.empty(); - - private Optional startIndexProcessed = Optional.empty(); - - private Optional endIndexProcessed = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1Locations other) { - startIndex(other.getStartIndex()); - endIndex(other.getEndIndex()); - startIndexProcessed(other.getStartIndexProcessed()); - endIndexProcessed(other.getEndIndexProcessed()); - return this; - } - - /** - *

Index of the first character of the string in the original text.

- */ - @JsonSetter(value = "start_index", nulls = Nulls.SKIP) - public Builder startIndex(Optional startIndex) { - this.startIndex = startIndex; - return this; - } - - public Builder startIndex(Integer startIndex) { - this.startIndex = Optional.ofNullable(startIndex); - return this; - } - - /** - *

Index of the last character of the string in the original text.

- */ - @JsonSetter(value = "end_index", nulls = Nulls.SKIP) - public Builder endIndex(Optional endIndex) { - this.endIndex = endIndex; - return this; - } - - public Builder endIndex(Integer endIndex) { - this.endIndex = Optional.ofNullable(endIndex); - return this; - } - - /** - *

Index of the first character of the string in the processed text.

- */ - @JsonSetter(value = "start_index_processed", nulls = Nulls.SKIP) - public Builder startIndexProcessed(Optional startIndexProcessed) { - this.startIndexProcessed = startIndexProcessed; - return this; - } - - public Builder startIndexProcessed(Integer startIndexProcessed) { - this.startIndexProcessed = Optional.ofNullable(startIndexProcessed); - return this; - } - - /** - *

Index of the last character of the string in the processed text.

- */ - @JsonSetter(value = "end_index_processed", nulls = Nulls.SKIP) - public Builder endIndexProcessed(Optional endIndexProcessed) { - this.endIndexProcessed = endIndexProcessed; - return this; - } - - public Builder endIndexProcessed(Integer endIndexProcessed) { - this.endIndexProcessed = Optional.ofNullable(endIndexProcessed); - return this; - } - - public V1Locations build() { - return new V1Locations(startIndex, endIndex, startIndexProcessed, endIndexProcessed, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java b/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java deleted file mode 100644 index 8731c1b9..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1PdfConfig.Builder.class) -public final class V1PdfConfig { - private final Optional options; - - private final Map additionalProperties; - - private V1PdfConfig(Optional options, Map additionalProperties) { - this.options = options; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("options") - public Optional getOptions() { - return options; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1PdfConfig && equalTo((V1PdfConfig) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1PdfConfig other) { - return options.equals(other.options); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.options); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional options = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1PdfConfig other) { - options(other.getOptions()); - return this; - } - - @JsonSetter(value = "options", nulls = Nulls.SKIP) - public Builder options(Optional options) { - this.options = options; - return this; - } - - public Builder options(V1PdfOptions options) { - this.options = Optional.ofNullable(options); - return this; - } - - public V1PdfConfig build() { - return new V1PdfConfig(options, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java b/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java deleted file mode 100644 index 63de909b..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1PdfOptions.Builder.class) -public final class V1PdfOptions { - private final Optional density; - - private final Optional maxResolution; - - private final Map additionalProperties; - - private V1PdfOptions( - Optional density, Optional maxResolution, Map additionalProperties) { - this.density = density; - this.maxResolution = maxResolution; - this.additionalProperties = additionalProperties; - } - - /** - * @return Pixel density at which to process the PDF file. - */ - @JsonProperty("density") - public Optional getDensity() { - return density; - } - - /** - * @return Max resolution at which to process the PDF file. - */ - @JsonProperty("max_resolution") - public Optional getMaxResolution() { - return maxResolution; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1PdfOptions && equalTo((V1PdfOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1PdfOptions other) { - return density.equals(other.density) && maxResolution.equals(other.maxResolution); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.density, this.maxResolution); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional density = Optional.empty(); - - private Optional maxResolution = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1PdfOptions other) { - density(other.getDensity()); - maxResolution(other.getMaxResolution()); - return this; - } - - /** - *

Pixel density at which to process the PDF file.

- */ - @JsonSetter(value = "density", nulls = Nulls.SKIP) - public Builder density(Optional density) { - this.density = density; - return this; - } - - public Builder density(Integer density) { - this.density = Optional.ofNullable(density); - return this; - } - - /** - *

Max resolution at which to process the PDF file.

- */ - @JsonSetter(value = "max_resolution", nulls = Nulls.SKIP) - public Builder maxResolution(Optional maxResolution) { - this.maxResolution = maxResolution; - return this; - } - - public Builder maxResolution(Integer maxResolution) { - this.maxResolution = Optional.ofNullable(maxResolution); - return this; - } - - public V1PdfOptions build() { - return new V1PdfOptions(density, maxResolution, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java b/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java deleted file mode 100644 index e4117109..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1ProcessedFileOutput.Builder.class) -public final class V1ProcessedFileOutput { - private final Optional outputType; - - private final Optional processedFile; - - private final Optional processedFileType; - - private final Map additionalProperties; - - private V1ProcessedFileOutput( - Optional outputType, - Optional processedFile, - Optional processedFileType, - Map additionalProperties) { - this.outputType = outputType; - this.processedFile = processedFile; - this.processedFileType = processedFileType; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("output_type") - public Optional getOutputType() { - return outputType; - } - - /** - * @return URL or base64-encoded data of the output. - */ - @JsonProperty("processed_file") - public Optional getProcessedFile() { - return processedFile; - } - - @JsonProperty("processed_file_type") - public Optional getProcessedFileType() { - return processedFileType; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1ProcessedFileOutput && equalTo((V1ProcessedFileOutput) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1ProcessedFileOutput other) { - return outputType.equals(other.outputType) - && processedFile.equals(other.processedFile) - && processedFileType.equals(other.processedFileType); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.outputType, this.processedFile, this.processedFileType); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional outputType = Optional.empty(); - - private Optional processedFile = Optional.empty(); - - private Optional processedFileType = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1ProcessedFileOutput other) { - outputType(other.getOutputType()); - processedFile(other.getProcessedFile()); - processedFileType(other.getProcessedFileType()); - return this; - } - - @JsonSetter(value = "output_type", nulls = Nulls.SKIP) - public Builder outputType(Optional outputType) { - this.outputType = outputType; - return this; - } - - public Builder outputType(DetectFileRequestDataType outputType) { - this.outputType = Optional.ofNullable(outputType); - return this; - } - - /** - *

URL or base64-encoded data of the output.

- */ - @JsonSetter(value = "processed_file", nulls = Nulls.SKIP) - public Builder processedFile(Optional processedFile) { - this.processedFile = processedFile; - return this; - } - - public Builder processedFile(String processedFile) { - this.processedFile = Optional.ofNullable(processedFile); - return this; - } - - @JsonSetter(value = "processed_file_type", nulls = Nulls.SKIP) - public Builder processedFileType(Optional processedFileType) { - this.processedFileType = processedFileType; - return this; - } - - public Builder processedFileType(ProcessedFileOutputProcessedFileType processedFileType) { - this.processedFileType = Optional.ofNullable(processedFileType); - return this; - } - - public V1ProcessedFileOutput build() { - return new V1ProcessedFileOutput(outputType, processedFile, processedFileType, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java b/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java deleted file mode 100644 index c02ab39f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1ResponseEntities.Builder.class) -public final class V1ResponseEntities { - private final Optional processedText; - - private final Optional originalText; - - private final Optional location; - - private final Optional bestLabel; - - private final Optional> labels; - - private final Map additionalProperties; - - private V1ResponseEntities( - Optional processedText, - Optional originalText, - Optional location, - Optional bestLabel, - Optional> labels, - Map additionalProperties) { - this.processedText = processedText; - this.originalText = originalText; - this.location = location; - this.bestLabel = bestLabel; - this.labels = labels; - this.additionalProperties = additionalProperties; - } - - /** - * @return Processed text of the entity. - */ - @JsonProperty("processed_text") - public Optional getProcessedText() { - return processedText; - } - - /** - * @return Original text of the entity. - */ - @JsonProperty("original_text") - public Optional getOriginalText() { - return originalText; - } - - @JsonProperty("location") - public Optional getLocation() { - return location; - } - - /** - * @return Highest rated label. - */ - @JsonProperty("best_label") - public Optional getBestLabel() { - return bestLabel; - } - - /** - * @return Labels and their scores. - */ - @JsonProperty("labels") - public Optional> getLabels() { - return labels; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1ResponseEntities && equalTo((V1ResponseEntities) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1ResponseEntities other) { - return processedText.equals(other.processedText) - && originalText.equals(other.originalText) - && location.equals(other.location) - && bestLabel.equals(other.bestLabel) - && labels.equals(other.labels); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.processedText, this.originalText, this.location, this.bestLabel, this.labels); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional processedText = Optional.empty(); - - private Optional originalText = Optional.empty(); - - private Optional location = Optional.empty(); - - private Optional bestLabel = Optional.empty(); - - private Optional> labels = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1ResponseEntities other) { - processedText(other.getProcessedText()); - originalText(other.getOriginalText()); - location(other.getLocation()); - bestLabel(other.getBestLabel()); - labels(other.getLabels()); - return this; - } - - /** - *

Processed text of the entity.

- */ - @JsonSetter(value = "processed_text", nulls = Nulls.SKIP) - public Builder processedText(Optional processedText) { - this.processedText = processedText; - return this; - } - - public Builder processedText(String processedText) { - this.processedText = Optional.ofNullable(processedText); - return this; - } - - /** - *

Original text of the entity.

- */ - @JsonSetter(value = "original_text", nulls = Nulls.SKIP) - public Builder originalText(Optional originalText) { - this.originalText = originalText; - return this; - } - - public Builder originalText(String originalText) { - this.originalText = Optional.ofNullable(originalText); - return this; - } - - @JsonSetter(value = "location", nulls = Nulls.SKIP) - public Builder location(Optional location) { - this.location = location; - return this; - } - - public Builder location(V1Locations location) { - this.location = Optional.ofNullable(location); - return this; - } - - /** - *

Highest rated label.

- */ - @JsonSetter(value = "best_label", nulls = Nulls.SKIP) - public Builder bestLabel(Optional bestLabel) { - this.bestLabel = bestLabel; - return this; - } - - public Builder bestLabel(String bestLabel) { - this.bestLabel = Optional.ofNullable(bestLabel); - return this; - } - - /** - *

Labels and their scores.

- */ - @JsonSetter(value = "labels", nulls = Nulls.SKIP) - public Builder labels(Optional> labels) { - this.labels = labels; - return this; - } - - public Builder labels(Map labels) { - this.labels = Optional.ofNullable(labels); - return this; - } - - public V1ResponseEntities build() { - return new V1ResponseEntities( - processedText, originalText, location, bestLabel, labels, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/logs/ErrorLogs.java b/src/main/java/com/skyflow/logs/ErrorLogs.java index 3415860c..eb5ea742 100644 --- a/src/main/java/com/skyflow/logs/ErrorLogs.java +++ b/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -109,6 +109,15 @@ public enum ErrorLogs { INVALID_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), INVOKE_CONNECTION_REQUEST_REJECTED("Invoke connection request resulted in failure."), + // File upload interface + COLUMN_NAME_IS_REQUIRED_FILE_UPLOAD("Invalid %s1 request. Column name is required."), + EMPTY_COLUMN_NAME_FILE_UPLOAD("Invalid %s1 request. Column name can not be empty."), + FILE_IS_REQUIRED("Invalid %s1 request. File is required."), + EMPTY_FILE("Invalid %s1 request. File can not be empty."), + INVALID_FILE_TYPE("Invalid %s1 request. File should be of type java.io.File"), + MISSING_FILE_SOURCE_IN_UPLOAD_FILE("Invalid %s1 request. Provide exactly one of filePath, base64, or fileObject."), + UPLOAD_FILE_REQUEST_REJECTED("Upload file request resulted in failure."), + // detect interface INVALID_TEXT_IN_DEIDENTIFY("Invalid %s1 request. The text field is required and must be a non-empty string. Specify a valid text."), diff --git a/src/main/java/com/skyflow/logs/InfoLogs.java b/src/main/java/com/skyflow/logs/InfoLogs.java index efd81a49..f71fc416 100644 --- a/src/main/java/com/skyflow/logs/InfoLogs.java +++ b/src/main/java/com/skyflow/logs/InfoLogs.java @@ -69,6 +69,11 @@ public enum InfoLogs { TOKENIZE_REQUEST_RESOLVED("Tokenize request resolved."), TOKENIZE_SUCCESS("Data tokenized."), + // File upload interface + FILE_UPLOAD_TRIGGERED("File upload method triggered."), + VALIDATING_FILE_UPLOAD_REQUEST("Validating file upload request."), + FILE_UPLOAD_REQUEST_RESOLVED("File upload request resolved."), + FILE_UPLOAD_SUCCESS("File uploaded successfully."), // Invoke connection interface INVOKE_CONNECTION_TRIGGERED("Invoke connection method triggered."), diff --git a/src/main/java/com/skyflow/utils/Constants.java b/src/main/java/com/skyflow/utils/Constants.java index b9264a22..f12e6a48 100644 --- a/src/main/java/com/skyflow/utils/Constants.java +++ b/src/main/java/com/skyflow/utils/Constants.java @@ -26,6 +26,6 @@ public final class Constants { public static final String SDK_METRICS_HEADER_KEY = "sky-metadata"; public static final String REQUEST_ID_HEADER_KEY = "x-request-id"; public static final String PROCESSED_FILE_NAME_PREFIX = "processed-"; - public static final String ERROR_FROM_CLIENT_HEADER_KEY = "eror-from-client"; - public static final String DEIDENTIFIED_FILE_PREFIX = "deidentified";; + public static final String ERROR_FROM_CLIENT_HEADER_KEY = "error-from-client"; + public static final String DEIDENTIFIED_FILE_PREFIX = "deidentified"; } diff --git a/src/main/java/com/skyflow/utils/validations/Validations.java b/src/main/java/com/skyflow/utils/validations/Validations.java index 841c03b6..0372749a 100644 --- a/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/src/main/java/com/skyflow/utils/validations/Validations.java @@ -408,12 +408,7 @@ public static void validateGetRequest(GetRequest getRequest) throws SkyflowExcep } } } - if (redactionType == null && (tokenization == null || !tokenization)) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.REDACTION_IS_REQUIRED.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.RedactionKeyError.getMessage()); - } + if (tokenization != null && tokenization) { if (redactionType != null) { LogUtil.printErrorLog(Utils.parameterizedString( @@ -687,6 +682,99 @@ public static void validateTokenizeRequest(TokenizeRequest tokenizeRequest) thro } } + public static void validateFileUploadRequest(FileUploadRequest fileUploadRequest) throws SkyflowException { + if (fileUploadRequest == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_REQUEST_BODY.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); + } + + String table = fileUploadRequest.getTable(); + if (table == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TableKeyError.getMessage()); + } else if (table.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_TABLE_NAME.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); + } + + String skyflowId = fileUploadRequest.getSkyflowId(); + if (skyflowId == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.SKYFLOW_ID_IS_REQUIRED.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.SkyflowIdKeyError.getMessage()); + } else if (skyflowId.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_SKYFLOW_ID.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptySkyflowId.getMessage()); + } + + String columnName = fileUploadRequest.getColumnName(); + if (columnName == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.COLUMN_NAME_IS_REQUIRED_FILE_UPLOAD.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnNameKeyErrorFileUpload.getMessage()); + } else if (columnName.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_COLUMN_NAME.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnName.getMessage()); + } + + String filePath = fileUploadRequest.getFilePath(); + String base64 = fileUploadRequest.getBase64(); + File fileObject = fileUploadRequest.getFileObject(); + String fileName = fileUploadRequest.getFileName(); + + // Check if at least one (path, base64, fileObject) is provided + if (isNullOrEmpty(filePath) && isNullOrEmpty(base64) && fileObject == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.MISSING_FILE_SOURCE_IN_UPLOAD_FILE.getLog(), InterfaceName.FILE_UPLOAD.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingFileSourceInUploadFileRequest.getMessage()); + } + + // Check filePath + if (!isNullOrEmpty(filePath)) { + File f = new File(filePath); + if (!f.exists() || !f.isFile()) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidFilePath.getMessage()); + } + } + + // Check base64 + if (!isNullOrEmpty(base64)) { + if (isNullOrEmpty(fileName)) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FileNameMustBeProvidedWithFileObject.getMessage()); + } + // Validate if Base64 is actually valid + try { + java.util.Base64.getDecoder().decode(base64); + } catch (IllegalArgumentException e) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidBase64.getMessage()); + } + } + + // Check fileObject + if (fileObject != null) { + if (!fileObject.exists() || !fileObject.isFile()) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidFileObject.getMessage()); + } + } + } + + private static boolean isNullOrEmpty(String str) { + return str == null || str.trim().isEmpty(); + } + public static void validateDeidentifyTextRequest(DeidentifyTextRequest deidentifyTextRequest) throws SkyflowException { // Validate required fields String deidentifyText = deidentifyTextRequest.getText(); @@ -788,6 +876,11 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); } + TokenFormat tokenFormat = request.getTokenFormat(); + if (tokenFormat != null && tokenFormat.getVaultToken() != null && !tokenFormat.getVaultToken().isEmpty()) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultTokenFormatIsNotAllowedForFiles.getMessage()); + } + File file = request.getFileInput().getFile(); String filePath = request.getFileInput().getFilePath(); @@ -842,9 +935,6 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); } - if (request.getBleep().getGain() == null) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); - } if (request.getBleep().getStartPadding() == null || request.getBleep().getStartPadding() < 0) { throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); } diff --git a/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java b/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java index a2d44d99..1a81eca0 100644 --- a/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java +++ b/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java @@ -3,15 +3,18 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import java.util.ArrayList; import java.util.HashMap; public class InvokeConnectionResponse { private final Object data; private final HashMap metadata; + private final ArrayList> errors; - public InvokeConnectionResponse(Object data, HashMap metadata) { + public InvokeConnectionResponse(Object data, HashMap metadata, ArrayList> errors) { this.data = data; this.metadata = metadata; + this.errors = errors; } public Object getData() { @@ -22,9 +25,13 @@ public HashMap getMetadata() { return metadata; } + public ArrayList> getErrors() { + return errors; + } + @Override public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); + Gson gson = new Gson().newBuilder().serializeNulls().create(); return gson.toJson(this); } } diff --git a/src/main/java/com/skyflow/vault/controller/ConnectionController.java b/src/main/java/com/skyflow/vault/controller/ConnectionController.java index 68a39751..4a9334d4 100644 --- a/src/main/java/com/skyflow/vault/controller/ConnectionController.java +++ b/src/main/java/com/skyflow/vault/controller/ConnectionController.java @@ -67,7 +67,7 @@ public InvokeConnectionResponse invoke(InvokeConnectionRequest invokeConnectionR JsonObject data = JsonParser.parseString(response).getAsJsonObject(); HashMap metadata = new HashMap<>(); metadata.put("requestId", HttpUtility.getRequestID()); - connectionResponse = new InvokeConnectionResponse(data, metadata); + connectionResponse = new InvokeConnectionResponse(data, metadata, null); LogUtil.printInfoLog(InfoLogs.INVOKE_CONNECTION_REQUEST_RESOLVED.getLog()); } catch (IOException e) { LogUtil.printErrorLog(ErrorLogs.INVOKE_CONNECTION_REQUEST_REJECTED.getLog()); diff --git a/src/main/java/com/skyflow/vault/controller/DetectController.java b/src/main/java/com/skyflow/vault/controller/DetectController.java index 411658ae..c92e6b2c 100644 --- a/src/main/java/com/skyflow/vault/controller/DetectController.java +++ b/src/main/java/com/skyflow/vault/controller/DetectController.java @@ -12,6 +12,7 @@ import com.skyflow.generated.rest.resources.files.requests.*; import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; +import com.skyflow.generated.rest.types.DeidentifyStatusResponseOutputType; import com.skyflow.generated.rest.types.*; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; @@ -28,7 +29,11 @@ import java.util.*; public final class DetectController extends VaultClient { - private static final Gson gson = new GsonBuilder().serializeNulls().create(); + Gson gson = new GsonBuilder() + .registerTypeAdapter(Optional.class, (JsonSerializer>) (src, typeOfSrc, context) -> + src.map(context::serialize).orElse(null)) + .serializeNulls() + .create(); public DetectController(VaultConfig vaultConfig, Credentials credentials) { super(vaultConfig, credentials); @@ -55,7 +60,7 @@ public DeidentifyTextResponse deidentifyText(DeidentifyTextRequest deidentifyTex deidentifyTextResponse = getDeIdentifyTextResponse(deidentifyStringResponse); LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_REQUEST_RESOLVED.getLog()); } catch (ApiClientApiException ex) { - String bodyString = gson.toJson(ex.body()); + String bodyString = extractBodyAsString(ex); LogUtil.printErrorLog(ErrorLogs.DEIDENTIFY_TEXT_REQUEST_REJECTED.getLog()); throw new SkyflowException(ex.statusCode(), ex, ex.headers(), bodyString); } @@ -82,7 +87,7 @@ public ReidentifyTextResponse reidentifyText(ReidentifyTextRequest reidentifyTex reidentifyTextResponse = new ReidentifyTextResponse(reidentifyStringResponse.getText().orElse(null)); LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_REQUEST_RESOLVED.getLog()); } catch (ApiClientApiException ex) { - String bodyString = gson.toJson(ex.body()); + String bodyString = extractBodyAsString(ex); LogUtil.printErrorLog(ErrorLogs.REIDENTIFY_TEXT_REQUEST_REJECTED.getLog()); throw new SkyflowException(ex.statusCode(), ex, ex.headers(), bodyString); } @@ -126,10 +131,11 @@ public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) thro if (DeidentifyFileStatus.SUCCESS.value().equalsIgnoreCase(response.getStatus())) { String base64File = response.getFileBase64(); + response.getEntities().get(0).getFile(); if (base64File != null) { byte[] decodedBytes = Base64.getDecoder().decode(base64File); String outputDir = request.getOutputDirectory(); - String outputFileName = Constants.PROCESSED_FILE_NAME_PREFIX + fileName; + String outputFileName = Constants.PROCESSED_FILE_NAME_PREFIX + fileName.substring(0, fileName.lastIndexOf('.')) + "."+response.getExtension(); File outputFile; if (outputDir != null && !outputDir.isEmpty()) { outputFile = new File(outputDir, outputFileName); @@ -143,9 +149,31 @@ public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) thro } } + + List entities = response.getEntities(); + if (entities != null && !entities.isEmpty()) { + FileEntityInfo entityInfo = entities.get(0); + String entityBase64 = entityInfo.getFile(); + String outputDir = request.getOutputDirectory(); + if (entityBase64 != null) { + byte[] entityDecodedBytes = Base64.getDecoder().decode(entityBase64); + String entityFileName = Constants.PROCESSED_FILE_NAME_PREFIX + fileName.substring(0, fileName.lastIndexOf('.')) + ".json"; + File entityFile; + if (outputDir != null && !outputDir.isEmpty()) { + entityFile = new File(outputDir, entityFileName); + } else { + entityFile = new File(entityFileName); + } + try { + java.nio.file.Files.write(entityFile.toPath(), entityDecodedBytes); + } catch (IOException ioe) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedtoSaveProcessedFile.getMessage()); + } + } + } } } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); + String bodyString = extractBodyAsString(e); LogUtil.printErrorLog(ErrorLogs.DEIDENTIFY_FILE_REQUEST_REJECTED.getLog()); throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); } @@ -212,6 +240,24 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D String runId, String status) throws SkyflowException { DeidentifyFileOutput firstOutput = getFirstOutput(response); + if (firstOutput == null) { + return new DeidentifyFileResponse( + null, + null, + response.getOutputType().name(), + null, + null, + null, + response.getSize().orElse(null), + response.getDuration().orElse(null), + response.getPages().orElse(null), + response.getSlides().orElse(null), + getEntities(response), + runId, + response.getStatus().name() + ); + } + Object wordCharObj = response.getAdditionalProperties().get("word_character_count"); Integer wordCount = null; Integer charCount = null; @@ -230,9 +276,8 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D File processedFileObject = null; FileInfo fileInfo = null; - Optional processedFileBase64 = firstOutput != null ? firstOutput.getProcessedFile() : Optional.empty(); - Optional processedFileExtension = firstOutput != null ? firstOutput.getProcessedFileExtension() : Optional.empty(); - + Optional processedFileBase64 = Optional.of(firstOutput).flatMap(DeidentifyFileOutput::getProcessedFile); + Optional processedFileExtension = Optional.of(firstOutput).flatMap(DeidentifyFileOutput::getProcessedFileExtension); if (processedFileBase64.isPresent() && processedFileExtension.isPresent()) { try { byte[] decodedBytes = Base64.getDecoder().decode(processedFileBase64.get()); @@ -247,21 +292,27 @@ private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(D } } + String processedFileType = firstOutput.getProcessedFileType() + .map(Object::toString) + .orElse(DeidentifyStatusResponseOutputType.UNKNOWN.toString()); + + String fileExtension = firstOutput.getProcessedFileExtension() + .orElse(DeidentifyStatusResponseOutputType.UNKNOWN.toString()); + return new DeidentifyFileResponse( fileInfo, firstOutput.getProcessedFile().orElse(null), - firstOutput.getProcessedFileType().get().toString(), - firstOutput.getProcessedFileExtension().get(), + processedFileType, + fileExtension, wordCount, charCount, - response.getSize().map(Double::valueOf).orElse(null), - response.getDuration().map(Double::valueOf).orElse(null), + response.getSize().orElse(null), + response.getDuration().orElse(null), response.getPages().orElse(null), response.getSlides().orElse(null), getEntities(response), runId, - status, - null + status ); } @@ -287,6 +338,13 @@ private static synchronized List getEntities(DeidentifyStatusRes return entities; } + private String extractBodyAsString(ApiClientApiException e) { + return e.statusCode() == 500 + ? e.body().toString() + : gson.toJson(e.body()); + } + + private com.skyflow.generated.rest.types.DeidentifyFileResponse processFileByType(String fileExtension, String base64Content, DeidentifyFileRequest request, String vaultId) throws SkyflowException { switch (fileExtension.toLowerCase()) { case "txt": @@ -367,7 +425,7 @@ public DeidentifyFileResponse getDetectRun(GetDetectRunRequest request) throws S return parseDeidentifyFileResponse(apiResponse, runId, apiResponse.getStatus().toString()); } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); + String bodyString = extractBodyAsString(e); LogUtil.printErrorLog(ErrorLogs.GET_DETECT_RUN_REQUEST_REJECTED.getLog()); throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); } diff --git a/src/main/java/com/skyflow/vault/controller/VaultController.java b/src/main/java/com/skyflow/vault/controller/VaultController.java index 84e528b0..3493227c 100644 --- a/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -22,6 +22,9 @@ import com.skyflow.utils.validations.Validations; import com.skyflow.vault.data.*; import com.skyflow.vault.tokens.*; + +import java.io.File; +import java.io.IOException; import java.util.*; public final class VaultController extends VaultClient { @@ -31,7 +34,7 @@ public VaultController(VaultConfig vaultConfig, Credentials credentials) { super(vaultConfig, credentials); } - private static synchronized HashMap getFormattedBatchInsertRecord(Object record, int requestIndex) { + private static synchronized HashMap getFormattedBatchInsertRecord(Object record, Integer requestIndex) { HashMap insertRecord = new HashMap<>(); String jsonString = gson.toJson(record); JsonObject bodyObject = JsonParser.parseString(jsonString).getAsJsonObject().get("Body").getAsJsonObject(); @@ -95,11 +98,9 @@ private static synchronized HashMap getFormattedUpdateRecord(V1U private static synchronized HashMap getFormattedQueryRecord(V1FieldRecords record) { HashMap queryRecord = new HashMap<>(); - Object fields = record.getFields(); - if (fields != null) { - String fieldsString = gson.toJson(fields); - JsonObject fieldsObject = JsonParser.parseString(fieldsString).getAsJsonObject(); - queryRecord.putAll(fieldsObject.asMap()); + Optional> fieldsOpt = record.getFields(); + if (fieldsOpt.isPresent()) { + queryRecord.putAll(fieldsOpt.get()); } return queryRecord; } @@ -124,7 +125,7 @@ public InsertResponse insert(InsertRequest insertRequest) throws SkyflowExceptio if (records.isPresent()) { List> recordList = records.get(); - for (int index = 0; index < recordList.size(); index++) { + for (Integer index = (Integer) 0; index < recordList.size(); index++) { Map record = recordList.get(index); HashMap insertRecord = getFormattedBatchInsertRecord(record, index); @@ -132,6 +133,7 @@ public InsertResponse insert(InsertRequest insertRequest) throws SkyflowExceptio insertedFields.add(insertRecord); } else { insertRecord.put("requestId", batchInsertResult.headers().get("x-request-id").get(0)); + insertRecord.put("httpCode", 400); errorFields.add(insertRecord); } } @@ -232,6 +234,7 @@ public GetResponse get(GetRequest getRequest) throws SkyflowException { .downloadUrl(getRequest.getDownloadURL()) .columnName(getRequest.getColumnName()) .columnValues(getRequest.getColumnValues()) + .fields(getRequest.getFields()) .orderBy(RecordServiceBulkGetRecordRequestOrderBy.valueOf(getRequest.getOrderBy())) .build(); @@ -359,4 +362,40 @@ public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws Skyflow LogUtil.printInfoLog(InfoLogs.TOKENIZE_SUCCESS.getLog()); return new TokenizeResponse(list); } + + public FileUploadResponse uploadFile(FileUploadRequest fileUploadRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.FILE_UPLOAD_TRIGGERED.getLog()); + FileUploadResponse fileUploadResponse = null; + + try { + LogUtil.printInfoLog(InfoLogs.VALIDATING_FILE_UPLOAD_REQUEST.getLog()); + Validations.validateFileUploadRequest(fileUploadRequest); + setBearerToken(); + File file = super.getFileForFileUpload(fileUploadRequest); + + UploadFileV2Request uploadFileV2Request = UploadFileV2Request.builder() + .tableName(fileUploadRequest.getTable()) + .columnName(fileUploadRequest.getColumnName()) + .skyflowId(fileUploadRequest.getSkyflowId()) + .returnFileMetadata(false) + .build(); + + UploadFileV2Response uploadFileV2Response = super.getRecordsApi().uploadFileV2(super.getVaultConfig().getVaultId(), file, uploadFileV2Request); + + fileUploadResponse = new FileUploadResponse( + uploadFileV2Response.getSkyflowId().orElse(null), + null + ); + + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.UPLOAD_FILE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } catch (IOException e) { + LogUtil.printErrorLog(ErrorLogs.UPLOAD_FILE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.getMessage(), e); + } + LogUtil.printInfoLog(InfoLogs.FILE_UPLOAD_SUCCESS.getLog()); + return fileUploadResponse; + } } diff --git a/src/main/java/com/skyflow/vault/data/FileUploadRequest.java b/src/main/java/com/skyflow/vault/data/FileUploadRequest.java new file mode 100644 index 00000000..1d6ba6be --- /dev/null +++ b/src/main/java/com/skyflow/vault/data/FileUploadRequest.java @@ -0,0 +1,97 @@ +package com.skyflow.vault.data; + +import java.io.File; + +public class FileUploadRequest { + + private final FileUploadRequest.FileUploadRequestBuilder builder; + + private FileUploadRequest(FileUploadRequest.FileUploadRequestBuilder builder) { + this.builder = builder; + } + + public static FileUploadRequest.FileUploadRequestBuilder builder() { + return new FileUploadRequest.FileUploadRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public String getSkyflowId() { + return this.builder.skyflowId; + } + + public String getColumnName() { + return this.builder.columnName; + } + + public String getFilePath() { + return this.builder.filePath; + } + + public String getBase64() { + return this.builder.base64; + } + + public File getFileObject() { + return this.builder.fileObject; + } + + public String getFileName() { + return this.builder.fileName; + } + + public static final class FileUploadRequestBuilder { + + private String table; + private String skyflowId; + private String columnName; + private String filePath; + private String base64; + private File fileObject; + private String fileName; + + private FileUploadRequestBuilder() { + } + + public FileUploadRequest.FileUploadRequestBuilder table(String table) { + this.table = table; + return this; + } + + public FileUploadRequest.FileUploadRequestBuilder skyflowId(String skyflowId) { + this.skyflowId = skyflowId; + return this; + } + + public FileUploadRequest.FileUploadRequestBuilder columnName(String columnName) { + this.columnName = columnName; + return this; + } + + public FileUploadRequest.FileUploadRequestBuilder filePath(String filePath) { + this.filePath = filePath; + return this; + } + + public FileUploadRequest.FileUploadRequestBuilder base64(String base64) { + this.base64 = base64; + return this; + } + + public FileUploadRequest.FileUploadRequestBuilder fileObject(File fileObject) { + this.fileObject = fileObject; + return this; + } + + public FileUploadRequest.FileUploadRequestBuilder fileName(String fileName) { + this.fileName = fileName; + return this; + } + + public FileUploadRequest build() { + return new FileUploadRequest(this); + } + } +} diff --git a/src/main/java/com/skyflow/vault/data/FileUploadResponse.java b/src/main/java/com/skyflow/vault/data/FileUploadResponse.java new file mode 100644 index 00000000..9e4557a3 --- /dev/null +++ b/src/main/java/com/skyflow/vault/data/FileUploadResponse.java @@ -0,0 +1,31 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.HashMap; + +public class FileUploadResponse { + private final String skyflowId; + private final ArrayList> errors; + + public FileUploadResponse(String skyflowId, ArrayList> errors) { + this.skyflowId = skyflowId; + this.errors = errors; + } + + public String getSkyflowId() { + return skyflowId; + } + + public ArrayList> getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson().newBuilder().serializeNulls().create(); + return gson.toJson(this); + } + +} diff --git a/src/main/java/com/skyflow/vault/data/GetResponse.java b/src/main/java/com/skyflow/vault/data/GetResponse.java index 41821969..34a01303 100644 --- a/src/main/java/com/skyflow/vault/data/GetResponse.java +++ b/src/main/java/com/skyflow/vault/data/GetResponse.java @@ -24,7 +24,7 @@ public ArrayList> getErrors() { @Override public String toString() { - Gson gson = new Gson(); + Gson gson = new Gson().newBuilder().serializeNulls().create(); return gson.toJson(this); } } diff --git a/src/main/java/com/skyflow/vault/data/InsertResponse.java b/src/main/java/com/skyflow/vault/data/InsertResponse.java index a4f97967..3d311525 100644 --- a/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -24,7 +24,7 @@ public ArrayList> getErrors() { @Override public String toString() { - Gson gson = new Gson(); + Gson gson = new Gson().newBuilder().serializeNulls().create(); return gson.toJson(this); } } diff --git a/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java b/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java index 95effea0..66590f8e 100644 --- a/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java +++ b/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java @@ -20,13 +20,12 @@ public class DeidentifyFileResponse { private final List entities; private final String runId; private final String status; - private final List errors; public DeidentifyFileResponse(FileInfo file, String fileBase64, String type, String extension, Integer wordCount, Integer charCount, Double sizeInKb, Double durationInSeconds, Integer pageCount, Integer slideCount, - List entities, String runId, String status, List errors) { + List entities, String runId, String status) { this.file = file; this.fileBase64 = fileBase64; this.type = type; @@ -40,11 +39,10 @@ public DeidentifyFileResponse(FileInfo file, String fileBase64, String type, Str this.entities = entities; this.runId = runId; this.status = status; - this.errors = errors; } public DeidentifyFileResponse(String runId, String status) { - this(null, null, null, null, null, null, null, null, null, null, null, runId, status, null); + this(null, null, null, null, null, null, null, null, null, null, null, runId, status); } public FileInfo getFile() { @@ -99,10 +97,6 @@ public String getStatus() { return status; } - public List getErrors() { - return errors; - } - @Override public String toString() { Gson gson = new GsonBuilder().serializeNulls().create(); diff --git a/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java b/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java index 33bba2b9..0e1b6b63 100644 --- a/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java +++ b/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java @@ -8,12 +8,12 @@ public class DetokenizeData { public DetokenizeData(String token) { this.token = token; - this.redactionType = RedactionType.PLAIN_TEXT; + this.redactionType = RedactionType.DEFAULT; } public DetokenizeData(String token, RedactionType redactionType) { this.token = token; - this.redactionType = redactionType == null ? RedactionType.PLAIN_TEXT : redactionType; + this.redactionType = redactionType == null ? RedactionType.DEFAULT : redactionType; } public String getToken() { diff --git a/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java b/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java index 31ff64b2..bd1d7cde 100644 --- a/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java +++ b/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java @@ -1,6 +1,9 @@ package com.skyflow.vault.tokens; +import com.google.gson.ExclusionStrategy; +import com.google.gson.FieldAttributes; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import java.util.ArrayList; @@ -23,7 +26,29 @@ public ArrayList getErrors() { @Override public String toString() { - Gson gson = new Gson(); + Gson gson = new GsonBuilder() + .serializeNulls() + .registerTypeAdapter( + DetokenizeRecordResponse.class, + (com.google.gson.JsonSerializer) (src, typeOfSrc, context) -> { + com.google.gson.JsonObject obj = new com.google.gson.JsonObject(); + obj.addProperty("token", src.getToken()); + if (src.getValue() != null) { + obj.addProperty("value", src.getValue()); + } + if (src.getType() != null) { + obj.addProperty("type", src.getType()); + } + if (src.getError() != null) { + obj.add("error", context.serialize(src.getError())); + } + if (src.getRequestId() != null) { + obj.addProperty("requestId", src.getRequestId()); + } + return obj; + } + ) + .create(); return gson.toJson(this); } } diff --git a/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java b/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java index 89e0643b..e2a1d921 100644 --- a/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java +++ b/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java @@ -3,10 +3,7 @@ import org.junit.Assert; import org.junit.Test; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class SkyflowExceptionTest { @@ -38,6 +35,8 @@ public void testConstructorWithCodeAndMessage() { Assert.assertEquals(Integer.valueOf(400), Integer.valueOf(ex.getHttpCode())); Assert.assertEquals("Bad Request", ex.getMessage()); Assert.assertEquals("Bad Request", ex.toString().contains("Bad Request") ? "Bad Request" : null); + Assert.assertNotNull(ex.getDetails()); + Assert.assertEquals(0, ex.getDetails().size()); } @Test @@ -49,7 +48,7 @@ public void testToStringFormat() { } @Test - public void testConstructorWithJsonErrorBody() { + public void testConstructorWithJsonErrorBodyArrayDetailsNonEmpty() { String json = "{\"error\":{\"message\":\"json error\",\"grpc_code\":7,\"http_status\":\"NOT_FOUND\",\"details\":[{\"info\":\"detail1\"}]}}"; Map> headers = new HashMap<>(); headers.put("x-request-id", Collections.singletonList("req-123")); @@ -62,21 +61,29 @@ public void testConstructorWithJsonErrorBody() { Assert.assertTrue(ex.getDetails().size() > 0); } + @Test + public void testConstructorWithJsonErrorBodyArrayDetailsEmpty() { + String json = "{\"error\":{\"message\":\"json error\",\"grpc_code\":7,\"http_status\":\"NOT_FOUND\",\"details\":[]}}"; + Map> headers = new HashMap<>(); + SkyflowException ex = new SkyflowException(404, new RuntimeException("fail"), headers, json); + Assert.assertEquals("json error", ex.getMessage()); + Assert.assertEquals(Integer.valueOf(7), ex.getGrpcCode()); + Assert.assertEquals("NOT_FOUND", ex.getHttpStatus()); + Assert.assertNotNull(ex.getDetails()); + Assert.assertEquals(0, ex.getDetails().size()); + } @Test public void testConstructorWithNullErrorBody() { Map> headers = new HashMap<>(); SkyflowException ex = new SkyflowException(500, new RuntimeException("fail"), headers, null); - Assert.assertNull(ex.getMessage()); + Assert.assertEquals("fail", ex.getMessage()); Assert.assertNull(ex.getGrpcCode()); - Assert.assertNull(ex.getHttpStatus()); } @Test public void testGettersAndSetters() { SkyflowException ex = new SkyflowException("msg"); - // Simulate setting fields via reflection or constructor - // (getters are already tested above) Assert.assertNull(ex.getRequestId()); Assert.assertNull(ex.getDetails()); Assert.assertNull(ex.getGrpcCode()); @@ -95,4 +102,39 @@ public void testSetDetailsWithErrorFromClientHeader() { Assert.assertEquals(1, ex.getDetails().size()); Assert.assertEquals("client error", ex.getDetails().get(0).getAsJsonObject().get("errorFromClient").getAsString()); } + + @Test + public void testSetDetailsWithErrorFromClientHeaderAndNullDetails() { + String json = "{\"error\":{\"message\":\"test error\",\"grpc_code\":13}}"; + Map> headers = new HashMap<>(); + headers.put("error-from-client", Collections.singletonList("client error")); + + SkyflowException ex = new SkyflowException(500, new RuntimeException("fail"), headers, json); + + Assert.assertNotNull(ex.getDetails()); + Assert.assertEquals(1, ex.getDetails().size()); + Assert.assertEquals("client error", ex.getDetails().get(0).getAsJsonObject().get("errorFromClient").getAsString()); + } + + @Test + public void testSetDetailsWithNoErrorFromClientHeaderAndEmptyDetails() { + String json = "{\"error\":{\"message\":\"test error\",\"grpc_code\":13,\"details\":[]}}"; + Map> headers = new HashMap<>(); + + SkyflowException ex = new SkyflowException(500, new RuntimeException("fail"), headers, json); + + Assert.assertNotNull(ex.getDetails()); + Assert.assertEquals(0, ex.getDetails().size()); + } + + @Test + public void testToStringWithNullFields() { + SkyflowException ex = new SkyflowException("msg"); + String str = ex.toString(); + Assert.assertTrue(str.contains("requestId: null")); + Assert.assertTrue(str.contains("grpcCode: null")); + Assert.assertTrue(str.contains("httpCode: null")); + Assert.assertTrue(str.contains("httpStatus: null")); + Assert.assertTrue(str.contains("details: null")); + } } \ No newline at end of file diff --git a/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java b/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java index 42ad9bc7..04083077 100644 --- a/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java +++ b/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java @@ -214,8 +214,11 @@ public void testSignedDataTokenResponse() { try { String signedToken = "test_signed_data_token"; SignedDataTokenResponse response = new SignedDataTokenResponse(dataToken, signedToken); - String responseString = "{\"token\":\"" + dataToken + "\"," + - "\"signedToken\":\"signed_token_" + signedToken + "\"}"; + String responseString = "{" + + "\"token\":\"" + dataToken + "\"," + + "\"signedToken\":\"signed_token_" + signedToken + "\"" + + "}"; + Assert.assertEquals(responseString, response.toString()); Assert.assertEquals(dataToken, response.getToken()); Assert.assertEquals("signed_token_" + signedToken, response.getSignedToken()); diff --git a/src/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java b/src/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java index a29a3335..63717b5c 100644 --- a/src/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java +++ b/src/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java @@ -425,9 +425,11 @@ public void testInvokeConnectionResponse() { data.addProperty("test_key_2", "test_value_2"); HashMap metadata = new HashMap<>(); metadata.put("requestId", "12345"); - InvokeConnectionResponse connectionResponse = new InvokeConnectionResponse(data, metadata); + InvokeConnectionResponse connectionResponse = new InvokeConnectionResponse(data, metadata, null); String responseString = "{\"data\":{\"test_key_1\":\"test_value_1\",\"test_key_2\":\"test_value_2\"}," + - "\"metadata\":{\"requestId\":\"12345\"}}"; + "\"metadata\":{\"requestId\":\"12345\"}," + + "\"errors\":null}"; + Assert.assertNotNull(connectionResponse.getData()); Assert.assertEquals(responseString, connectionResponse.toString()); Assert.assertEquals(1, connectionResponse.getMetadata().size()); diff --git a/src/test/java/com/skyflow/vault/controller/VaultControllerTests.java b/src/test/java/com/skyflow/vault/controller/VaultControllerTests.java index 5f3ae771..4115bc2c 100644 --- a/src/test/java/com/skyflow/vault/controller/VaultControllerTests.java +++ b/src/test/java/com/skyflow/vault/controller/VaultControllerTests.java @@ -165,4 +165,24 @@ public void testInvalidRequestInTokenizeMethod() { } } + @Test + public void testInvalidRequestInFileUploadMethod() { + try { + FileUploadRequest request = FileUploadRequest.builder().build(); + skyflowClient = Skyflow.builder().setLogLevel(LogLevel.DEBUG).addVaultConfig(vaultConfig).build(); + skyflowClient.vault().uploadFile(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.TableKeyError.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + Assert.assertNull(e.getRequestId()); + Assert.assertNull(e.getGrpcCode()); + Assert.assertTrue(e.getDetails().isEmpty()); + Assert.assertEquals(HttpStatus.BAD_REQUEST.getHttpStatus(), e.getHttpStatus()); + } + } + } diff --git a/src/test/java/com/skyflow/vault/data/FileUploadTests.java b/src/test/java/com/skyflow/vault/data/FileUploadTests.java new file mode 100644 index 00000000..7758fe36 --- /dev/null +++ b/src/test/java/com/skyflow/vault/data/FileUploadTests.java @@ -0,0 +1,222 @@ +package com.skyflow.vault.data; + +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.utils.Constants; +import com.skyflow.utils.Utils; +import com.skyflow.utils.validations.Validations; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; + +public class FileUploadTests { + private static final String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception"; + private static final String EXCEPTION_NOT_THROWN = "Should have thrown an exception"; + private static String table; + private static String skyflowId; + private static String columnName; + private static String filePath; + private static String base64Content; + private static File fileObject; + private static String fileName; + + @BeforeClass + public static void setup() { + table = "test_table"; + skyflowId = "test_id"; + columnName = "file_column"; + filePath = "src/test/resources/notJson.txt"; + base64Content = "SGVsbG8gV29ybGQ="; + fileObject = new File(filePath); + fileName = "notJson.txt"; + } + + @Test + public void testValidFileUploadRequestWithFilePath() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId(skyflowId) + .columnName(columnName) + .filePath(filePath) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.assertEquals(table, request.getTable()); + Assert.assertEquals(skyflowId, request.getSkyflowId()); + Assert.assertEquals(columnName, request.getColumnName()); + Assert.assertEquals(filePath, request.getFilePath()); + Assert.assertEquals(fileName, request.getFileName()); + } catch (SkyflowException e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testValidFileUploadRequestWithBase64() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId(skyflowId) + .columnName(columnName) + .base64(base64Content) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.assertEquals(base64Content, request.getBase64()); + } catch (SkyflowException e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testValidFileUploadRequestWithFileObject() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId(skyflowId) + .columnName(columnName) + .fileObject(fileObject) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.assertEquals(fileObject, request.getFileObject()); + } catch (SkyflowException e) { + System.out.println("## e:" + e.getMessage()); + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testMissingTable() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .skyflowId(skyflowId) + .columnName(columnName) + .filePath(filePath) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.TableKeyError.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testMissingSkyflowId() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .columnName(columnName) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.SkyflowIdKeyError.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testEmptySkyflowId() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId("") + .columnName(columnName) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.EmptySkyflowId.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testMissingColumnName() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId(skyflowId) + .filePath(filePath) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.ColumnNameKeyErrorFileUpload.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testMissingFileData() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId(skyflowId) + .columnName(columnName) + .fileName(fileName) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.MissingFileSourceInUploadFileRequest.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testMissingFileNameWithBase64Invalid() { + try { + FileUploadRequest request = FileUploadRequest.builder() + .table(table) + .skyflowId(skyflowId) + .columnName(columnName) + .base64(base64Content) + .build(); + + Validations.validateFileUploadRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.FileNameMustBeProvidedWithFileObject.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + +} diff --git a/src/test/java/com/skyflow/vault/data/GetTests.java b/src/test/java/com/skyflow/vault/data/GetTests.java index 43b3f132..74306d4b 100644 --- a/src/test/java/com/skyflow/vault/data/GetTests.java +++ b/src/test/java/com/skyflow/vault/data/GetTests.java @@ -271,9 +271,9 @@ public void testNoRedactionInGetRequestValidations() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.RedactionKeyError.getMessage(), Constants.SDK_PREFIX), - e.getMessage() - ); + Utils.parameterizedString(ErrorMessage.UniqueColumnOrIdsKeyError.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); } } diff --git a/src/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java b/src/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java index a1243eea..89cf5114 100644 --- a/src/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java +++ b/src/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java @@ -26,12 +26,11 @@ public void testAllGettersAndToString() { java.util.List entities = Collections.singletonList(entityInfo); String runId = "run-123"; String status = "SUCCESS"; - java.util.List errors = Arrays.asList("error1", "error2"); FileInfo fileInfo = new FileInfo(fileObject); DeidentifyFileResponse response = new DeidentifyFileResponse( fileInfo, file, type, extension, wordCount, charCount, sizeInKb, - durationInSeconds, pageCount, slideCount, entities, runId, status, errors + durationInSeconds, pageCount, slideCount, entities, runId, status ); Assert.assertEquals(type, response.getType()); @@ -45,7 +44,6 @@ public void testAllGettersAndToString() { Assert.assertEquals(entities, response.getEntities()); Assert.assertEquals(runId, response.getRunId()); Assert.assertEquals(status, response.getStatus()); - Assert.assertEquals(errors, response.getErrors()); // toString should return a JSON string containing all fields String json = response.toString(); @@ -54,7 +52,6 @@ public void testAllGettersAndToString() { Assert.assertTrue(json.contains(extension)); Assert.assertTrue(json.contains(runId)); Assert.assertTrue(json.contains(status)); - Assert.assertTrue(json.contains("error1")); Assert.assertTrue(json.contains("PERSON")); } } \ No newline at end of file diff --git a/src/test/java/com/skyflow/vault/tokens/DetokenizeTests.java b/src/test/java/com/skyflow/vault/tokens/DetokenizeTests.java index ed6804b5..d417aeb7 100644 --- a/src/test/java/com/skyflow/vault/tokens/DetokenizeTests.java +++ b/src/test/java/com/skyflow/vault/tokens/DetokenizeTests.java @@ -136,7 +136,7 @@ public void testRedactionAndContinueOnErrorInDetokenizeRequestValidations() { detokenizeData(detokenizeData).continueOnError(null).build(); try { Validations.validateDetokenizeRequest(request); - Assert.assertEquals(RedactionType.PLAIN_TEXT, request.getDetokenizeData().get(0).getRedactionType()); + Assert.assertEquals(RedactionType.DEFAULT, request.getDetokenizeData().get(0).getRedactionType()); Assert.assertFalse(request.getContinueOnError()); Assert.assertFalse(request.getDownloadURL()); } catch (SkyflowException e) {