From 9efc7c428ec8e446ed88a446503440141b9179ae Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 11 Aug 2025 13:48:36 +0530 Subject: [PATCH 01/97] SK-2233: add v2, v3 and common modules --- common/pom.xml | 21 + .../java/com/skyflow/common/ApiClient.java | 28 + .../com/skyflow/common/ApiClientBuilder.java | 67 + .../com/skyflow/common/AsyncApiClient.java | 28 + .../skyflow/common/AsyncApiClientBuilder.java | 67 + .../common/core/ApiClientApiException.java | 73 + .../common/core/ApiClientException.java | 17 + .../common/core/ApiClientHttpResponse.java | 37 + .../skyflow/common/core/ClientOptions.java | 170 ++ .../common/core/DateTimeDeserializer.java | 55 + .../com/skyflow/common/core/Environment.java | 24 + .../com/skyflow/common/core/FileStream.java | 60 + .../common/core/InputStreamRequestBody.java | 79 + .../com/skyflow/common/core/MediaTypes.java | 13 + .../com/skyflow/common/core/Nullable.java | 140 ++ .../common/core/NullableNonemptyFilter.java | 19 + .../skyflow/common/core/ObjectMappers.java | 36 + .../common/core/QueryStringMapper.java | 142 ++ .../skyflow/common/core/RequestOptions.java | 101 ++ .../common/core/ResponseBodyInputStream.java | 45 + .../common/core/ResponseBodyReader.java | 44 + .../skyflow/common/core/RetryInterceptor.java | 78 + .../java/com/skyflow/common/core/Stream.java | 97 + .../com/skyflow/common/core/Suppliers.java | 23 + .../com/skyflow/common/enums/LogLevel.java | 9 + .../common/errors/BadRequestError.java | 33 + .../com/skyflow/common/errors/ErrorCode.java | 18 + .../skyflow/common/errors/ErrorMessage.java | 162 ++ .../com/skyflow/common/errors/HttpStatus.java | 15 + .../skyflow/common/errors/NotFoundError.java | 33 + .../common/errors/SkyflowException.java | 135 ++ .../common/errors/UnauthorizedError.java | 33 + .../com/skyflow/common/logs/ErrorLogs.java | 140 ++ .../com/skyflow/common/logs/InfoLogs.java | 105 ++ .../AsyncAuthenticationClient.java | 45 + .../AsyncRawAuthenticationClient.java | 131 ++ .../authentication/AuthenticationClient.java | 44 + .../RawAuthenticationClient.java | 110 ++ .../requests/V1GetAuthTokenRequest.java | 335 ++++ .../serviceaccount/util/BearerToken.java | 229 +++ .../util/SignedDataTokenResponse.java | 29 + .../serviceaccount/util/SignedDataTokens.java | 213 +++ .../common/serviceaccount/util/Token.java | 46 + .../skyflow/common/types/GooglerpcStatus.java | 144 ++ .../com/skyflow/common/types/ProtobufAny.java | 95 + .../common/types/V1GetAuthTokenResponse.java | 130 ++ .../com/skyflow/common/utils/Constants.java | 31 + .../java/com/skyflow/common/utils/Utils.java | 69 + .../skyflow/common/utils/logger/LogUtil.java | 100 ++ .../test/java/com/skyflow/api/TestClient.java | 11 + .../api/core/QueryStringMapperTest.java | 341 ++++ pom.xml | 7 +- v2/pom.xml | 55 + .../java/com/skyflow/ConnectionClient.java | 94 + v2/src/main/java/com/skyflow/Skyflow.java | 307 ++++ v2/src/main/java/com/skyflow/VaultClient.java | 823 +++++++++ .../com/skyflow/config/ConnectionConfig.java | 38 + .../java/com/skyflow/config/Credentials.java | 66 + .../com/skyflow/config/ManagementConfig.java | 11 + .../java/com/skyflow/config/VaultConfig.java | 49 + .../skyflow/enums/DeidentifyFileStatus.java | 16 + .../com/skyflow/enums/DetectEntities.java | 83 + .../enums/DetectOutputTranscriptions.java | 24 + v2/src/main/java/com/skyflow/enums/Env.java | 8 + .../java/com/skyflow/enums/InterfaceName.java | 24 + .../main/java/com/skyflow/enums/LogLevel.java | 9 + .../java/com/skyflow/enums/MaskingMethod.java | 21 + .../java/com/skyflow/enums/RedactionType.java | 26 + .../java/com/skyflow/enums/RequestMethod.java | 22 + .../java/com/skyflow/enums/TokenMode.java | 24 + .../java/com/skyflow/enums/TokenType.java | 27 + .../java/com/skyflow/errors/ErrorCode.java | 18 + .../java/com/skyflow/errors/ErrorMessage.java | 162 ++ .../java/com/skyflow/errors/HttpStatus.java | 15 + .../com/skyflow/errors/SkyflowException.java | 135 ++ .../com/skyflow/generated/rest/ApiClient.java | 92 + .../generated/rest/ApiClientBuilder.java | 67 + .../generated/rest/AsyncApiClient.java | 92 + .../generated/rest/AsyncApiClientBuilder.java | 67 + .../rest/core/ApiClientApiException.java | 73 + .../rest/core/ApiClientException.java | 17 + .../rest/core/ApiClientHttpResponse.java | 37 + .../generated/rest/core/ClientOptions.java | 170 ++ .../rest/core/DateTimeDeserializer.java | 55 + .../generated/rest/core/Environment.java | 24 + .../generated/rest/core/FileStream.java | 60 + .../rest/core/InputStreamRequestBody.java | 79 + .../generated/rest/core/MediaTypes.java | 13 + .../skyflow/generated/rest/core/Nullable.java | 140 ++ .../rest/core/NullableNonemptyFilter.java | 19 + .../generated/rest/core/ObjectMappers.java | 36 + .../rest/core/QueryStringMapper.java | 142 ++ .../rest/core/QueryStringMapperTest.java | 339 ++++ .../generated/rest/core/RequestOptions.java | 101 ++ .../rest/core/ResponseBodyInputStream.java | 45 + .../rest/core/ResponseBodyReader.java | 44 + .../generated/rest/core/RetryInterceptor.java | 78 + .../skyflow/generated/rest/core/Stream.java | 97 + .../generated/rest/core/Suppliers.java | 23 + .../rest/errors/BadRequestError.java | 32 + .../rest/errors/InternalServerError.java | 33 + .../generated/rest/errors/NotFoundError.java | 32 + .../rest/errors/UnauthorizedError.java | 32 + .../resources/audit/AsyncAuditClient.java | 45 + .../resources/audit/AsyncRawAuditClient.java | 284 +++ .../rest/resources/audit/AuditClient.java | 44 + .../rest/resources/audit/RawAuditClient.java | 277 +++ .../AuditServiceListAuditEventsRequest.java | 1589 +++++++++++++++++ ...AuditEventsRequestFilterOpsActionType.java | 56 + ...entsRequestFilterOpsContextAccessType.java | 28 + ...ventsRequestFilterOpsContextActorType.java | 26 + ...EventsRequestFilterOpsContextAuthMode.java | 28 + ...ditEventsRequestFilterOpsResourceType.java | 80 + ...eListAuditEventsRequestSortOpsOrderBy.java | 24 + .../AsyncAuthenticationClient.java | 45 + .../AsyncRawAuthenticationClient.java | 126 ++ .../authentication/AuthenticationClient.java | 44 + .../RawAuthenticationClient.java | 102 ++ .../requests/V1GetAuthTokenRequest.java | 335 ++++ .../binlookup/AsyncBinLookupClient.java | 52 + .../binlookup/AsyncRawBinLookupClient.java | 118 ++ .../resources/binlookup/BinLookupClient.java | 50 + .../binlookup/RawBinLookupClient.java | 98 + .../binlookup/requests/V1BinListRequest.java | 189 ++ .../deprecated/AsyncDeprecatedClient.java | 89 + .../deprecated/AsyncRawDeprecatedClient.java | 271 +++ .../deprecated/DeprecatedClient.java | 87 + .../deprecated/RawDeprecatedClient.java | 222 +++ .../DetectServiceDetectStatusRequest.java | 101 ++ .../DetectServiceDetectTextRequest.java | 526 ++++++ .../requests/V1DetectFileRequest.java | 634 +++++++ .../resources/files/AsyncFilesClient.java | 188 ++ .../resources/files/AsyncRawFilesClient.java | 929 ++++++++++ .../rest/resources/files/FilesClient.java | 180 ++ .../rest/resources/files/RawFilesClient.java | 714 ++++++++ .../requests/DeidentifyAudioRequest.java | 582 ++++++ .../requests/DeidentifyDocumentRequest.java | 310 ++++ .../files/requests/DeidentifyFileRequest.java | 310 ++++ .../requests/DeidentifyImageRequest.java | 446 +++++ .../files/requests/DeidentifyPdfRequest.java | 400 +++++ .../DeidentifyPresentationRequest.java | 310 ++++ .../DeidentifySpreadsheetRequest.java | 310 ++++ .../DeidentifyStructuredTextRequest.java | 310 ++++ .../files/requests/DeidentifyTextRequest.java | 310 ++++ .../files/requests/GetRunRequest.java | 112 ++ .../types/DeidentifyAudioRequestFile.java | 145 ++ .../DeidentifyAudioRequestFileDataFormat.java | 24 + ...entifyAudioRequestOutputTranscription.java | 30 + .../types/DeidentifyDocumentRequestFile.java | 147 ++ ...identifyDocumentRequestFileDataFormat.java | 26 + .../types/DeidentifyFileRequestFile.java | 145 ++ .../DeidentifyFileRequestFileDataFormat.java | 58 + .../types/DeidentifyImageRequestFile.java | 145 ++ .../DeidentifyImageRequestFileDataFormat.java | 32 + .../DeidentifyImageRequestMaskingMethod.java | 24 + .../files/types/DeidentifyPdfRequestFile.java | 120 ++ .../DeidentifyPresentationRequestFile.java | 147 ++ ...tifyPresentationRequestFileDataFormat.java | 24 + .../DeidentifySpreadsheetRequestFile.java | 147 ++ ...ntifySpreadsheetRequestFileDataFormat.java | 26 + .../DeidentifyStructuredTextRequestFile.java | 148 ++ ...fyStructuredTextRequestFileDataFormat.java | 24 + .../types/DeidentifyTextRequestFile.java | 120 ++ .../resources/query/AsyncQueryClient.java | 53 + .../resources/query/AsyncRawQueryClient.java | 121 ++ .../rest/resources/query/QueryClient.java | 51 + .../rest/resources/query/RawQueryClient.java | 102 ++ .../QueryServiceExecuteQueryBody.java | 101 ++ .../records/AsyncRawRecordsClient.java | 956 ++++++++++ .../resources/records/AsyncRecordsClient.java | 317 ++++ .../resources/records/RawRecordsClient.java | 800 +++++++++ .../rest/resources/records/RecordsClient.java | 312 ++++ .../FileServiceUploadFileRequest.java | 59 + .../RecordServiceBatchOperationBody.java | 160 ++ .../RecordServiceBulkDeleteRecordBody.java | 103 ++ .../RecordServiceBulkGetRecordRequest.java | 413 +++++ .../RecordServiceGetRecordRequest.java | 202 +++ .../RecordServiceInsertRecordBody.java | 221 +++ .../RecordServiceUpdateRecordBody.java | 151 ++ ...ordServiceBulkGetRecordRequestOrderBy.java | 26 + ...dServiceBulkGetRecordRequestRedaction.java | 28 + ...ecordServiceGetRecordRequestRedaction.java | 28 + .../strings/AsyncRawStringsClient.java | 217 +++ .../resources/strings/AsyncStringsClient.java | 60 + .../resources/strings/RawStringsClient.java | 171 ++ .../rest/resources/strings/StringsClient.java | 57 + .../requests/DeidentifyStringRequest.java | 309 ++++ .../requests/ReidentifyStringRequest.java | 192 ++ .../types/ReidentifyStringRequestFormat.java | 163 ++ .../tokens/AsyncRawTokensClient.java | 206 +++ .../resources/tokens/AsyncTokensClient.java | 79 + .../resources/tokens/RawTokensClient.java | 172 ++ .../rest/resources/tokens/TokensClient.java | 77 + .../tokens/requests/V1DetokenizePayload.java | 166 ++ .../tokens/requests/V1TokenizePayload.java | 104 ++ .../types/AdvancedOptionsColumnMapping.java | 194 ++ .../types/AdvancedOptionsEntityColumnMap.java | 126 ++ .../types/AdvancedOptionsVaultSchema.java | 135 ++ .../types/AudioConfigTranscriptionType.java | 40 + .../types/AuditEventAuditResourceType.java | 80 + .../rest/types/AuditEventContext.java | 440 +++++ .../generated/rest/types/AuditEventData.java | 101 ++ .../rest/types/AuditEventHttpInfo.java | 130 ++ .../rest/types/BatchRecordMethod.java | 30 + .../rest/types/ContextAccessType.java | 26 + .../generated/rest/types/ContextAuthMode.java | 28 + .../rest/types/DeidentifyFileOutput.java | 164 ++ ...DeidentifyFileOutputProcessedFileType.java | 40 + .../rest/types/DeidentifyFileResponse.java | 112 ++ .../rest/types/DeidentifyStatusResponse.java | 521 ++++++ .../DeidentifyStatusResponseOutputType.java | 26 + .../types/DeidentifyStatusResponseStatus.java | 26 + .../rest/types/DeidentifyStringResponse.java | 242 +++ .../rest/types/DetectDataAccuracy.java | 36 + .../rest/types/DetectDataEntities.java | 146 ++ .../rest/types/DetectFileRequestDataType.java | 24 + .../types/DetectRequestDeidentifyOption.java | 26 + .../generated/rest/types/DetectedEntity.java | 217 +++ .../DetokenizeRecordResponseValueType.java | 38 + .../generated/rest/types/EntityLocation.java | 194 ++ .../generated/rest/types/EntityType.java | 146 ++ .../generated/rest/types/ErrorResponse.java | 102 ++ .../rest/types/ErrorResponseError.java | 240 +++ .../generated/rest/types/GooglerpcStatus.java | 144 ++ .../ProcessedFileOutputProcessedFileType.java | 40 + .../generated/rest/types/ProtobufAny.java | 95 + .../rest/types/RedactionEnumRedaction.java | 28 + .../rest/types/ReidentifyStringResponse.java | 101 ++ .../rest/types/RequestActionType.java | 56 + .../generated/rest/types/TokenType.java | 188 ++ .../rest/types/TokenTypeDefault.java | 26 + .../rest/types/TokenTypeWithoutVault.java | 158 ++ .../types/TokenTypeWithoutVaultDefault.java | 24 + .../generated/rest/types/Transformations.java | 101 ++ .../rest/types/TransformationsShiftDates.java | 162 ++ ...nsformationsShiftDatesEntityTypesItem.java | 26 + .../rest/types/V1AdvancedOptions.java | 157 ++ .../generated/rest/types/V1AudioConfig.java | 151 ++ .../generated/rest/types/V1AudioOptions.java | 234 +++ .../rest/types/V1AuditAfterOptions.java | 130 ++ .../rest/types/V1AuditEventResponse.java | 187 ++ .../generated/rest/types/V1AuditResponse.java | 127 ++ .../rest/types/V1AuditResponseEvent.java | 238 +++ .../types/V1AuditResponseEventRequest.java | 339 ++++ .../rest/types/V1BatchOperationResponse.java | 133 ++ .../generated/rest/types/V1BatchRecord.java | 382 ++++ .../rest/types/V1BinListResponse.java | 102 ++ .../types/V1BulkDeleteRecordResponse.java | 103 ++ .../rest/types/V1BulkGetRecordResponse.java | 102 ++ .../skyflow/generated/rest/types/V1Byot.java | 26 + .../skyflow/generated/rest/types/V1Card.java | 362 ++++ .../rest/types/V1DeleteFileResponse.java | 130 ++ .../rest/types/V1DeleteRecordResponse.java | 130 ++ .../rest/types/V1DetectFileResponse.java | 101 ++ .../rest/types/V1DetectStatusResponse.java | 156 ++ .../types/V1DetectStatusResponseStatus.java | 28 + .../rest/types/V1DetectTextRequest.java | 522 ++++++ .../rest/types/V1DetectTextResponse.java | 133 ++ .../rest/types/V1DetokenizeRecordRequest.java | 126 ++ .../types/V1DetokenizeRecordResponse.java | 187 ++ .../rest/types/V1DetokenizeResponse.java | 103 ++ .../generated/rest/types/V1FieldRecords.java | 132 ++ .../rest/types/V1FileAvScanStatus.java | 38 + .../rest/types/V1FileDataFormat.java | 58 + .../rest/types/V1GetAuthTokenResponse.java | 130 ++ .../types/V1GetFileScanStatusResponse.java | 96 + .../rest/types/V1GetQueryResponse.java | 102 ++ .../generated/rest/types/V1ImageOptions.java | 132 ++ .../rest/types/V1InsertRecordResponse.java | 103 ++ .../generated/rest/types/V1Locations.java | 193 ++ .../generated/rest/types/V1MemberType.java | 26 + .../generated/rest/types/V1PdfConfig.java | 95 + .../generated/rest/types/V1PdfOptions.java | 130 ++ .../rest/types/V1ProcessedFileOutput.java | 151 ++ .../rest/types/V1RecordMetaProperties.java | 132 ++ .../rest/types/V1ResponseEntities.java | 218 +++ .../rest/types/V1TokenizeRecordRequest.java | 130 ++ .../rest/types/V1TokenizeRecordResponse.java | 101 ++ .../rest/types/V1TokenizeResponse.java | 103 ++ .../rest/types/V1UpdateRecordResponse.java | 132 ++ .../rest/types/V1VaultFieldMapping.java | 163 ++ .../rest/types/V1VaultSchemaConfig.java | 155 ++ .../main/java/com/skyflow/logs/ErrorLogs.java | 140 ++ .../main/java/com/skyflow/logs/InfoLogs.java | 105 ++ .../java/com/skyflow/utils/Constants.java | 31 + .../java/com/skyflow/utils/HttpUtility.java | 165 ++ v2/src/main/java/com/skyflow/utils/Utils.java | 202 +++ .../com/skyflow/utils/logger/LogUtil.java | 100 ++ .../utils/validations/Validations.java | 892 +++++++++ .../skyflow/vault/audit/ListEventRequest.java | 11 + .../vault/audit/ListEventResponse.java | 10 + .../com/skyflow/vault/bin/GetBinRequest.java | 10 + .../com/skyflow/vault/bin/GetBinResponse.java | 10 + .../connection/InvokeConnectionRequest.java | 82 + .../connection/InvokeConnectionResponse.java | 30 + .../vault/controller/AuditController.java | 18 + .../vault/controller/BinLookupController.java | 16 + .../controller/ConnectionController.java | 93 + .../vault/controller/DetectController.java | 375 ++++ .../vault/controller/VaultController.java | 362 ++++ .../com/skyflow/vault/data/DeleteRequest.java | 45 + .../skyflow/vault/data/DeleteResponse.java | 27 + .../com/skyflow/vault/data/GetRequest.java | 140 ++ .../com/skyflow/vault/data/GetResponse.java | 30 + .../com/skyflow/vault/data/InsertRequest.java | 111 ++ .../skyflow/vault/data/InsertResponse.java | 30 + .../com/skyflow/vault/data/QueryRequest.java | 33 + .../com/skyflow/vault/data/QueryResponse.java | 32 + .../com/skyflow/vault/data/UpdateRequest.java | 79 + .../skyflow/vault/data/UpdateResponse.java | 39 + .../com/skyflow/vault/detect/AudioBleep.java | 64 + .../vault/detect/DateTransformation.java | 30 + .../vault/detect/DeidentifyFileRequest.java | 192 ++ .../vault/detect/DeidentifyFileResponse.java | 111 ++ .../vault/detect/DeidentifyTextRequest.java | 88 + .../vault/detect/DeidentifyTextResponse.java | 44 + .../com/skyflow/vault/detect/EntityInfo.java | 46 + .../skyflow/vault/detect/FileEntityInfo.java | 19 + .../com/skyflow/vault/detect/FileInfo.java | 33 + .../com/skyflow/vault/detect/FileInput.java | 46 + .../vault/detect/GetDetectRunRequest.java | 33 + .../vault/detect/ReidentifyTextRequest.java | 68 + .../vault/detect/ReidentifyTextResponse.java | 23 + .../com/skyflow/vault/detect/TextIndex.java | 29 + .../com/skyflow/vault/detect/TokenFormat.java | 71 + .../skyflow/vault/detect/Transformations.java | 14 + .../com/skyflow/vault/tokens/ColumnValue.java | 45 + .../skyflow/vault/tokens/DetokenizeData.java | 26 + .../tokens/DetokenizeRecordResponse.java | 54 + .../vault/tokens/DetokenizeRequest.java | 57 + .../vault/tokens/DetokenizeResponse.java | 29 + .../skyflow/vault/tokens/TokenizeRequest.java | 35 + .../vault/tokens/TokenizeResponse.java | 33 + v3/pom.xml | 55 + .../java/com/skyflow/vaultLH/ApiClient.java | 29 + .../com/skyflow/vaultLH/ApiClientBuilder.java | 48 + .../com/skyflow/vaultLH/AsyncApiClient.java | 29 + .../vaultLH/AsyncApiClientBuilder.java | 48 + .../vaultLH/core/ApiClientApiException.java | 74 + .../vaultLH/core/ApiClientException.java | 17 + .../vaultLH/core/ApiClientHttpResponse.java | 38 + .../skyflow/vaultLH/core/ClientOptions.java | 171 ++ .../vaultLH/core/DateTimeDeserializer.java | 56 + .../com/skyflow/vaultLH/core/Environment.java | 20 + .../com/skyflow/vaultLH/core/FileStream.java | 61 + .../vaultLH/core/InputStreamRequestBody.java | 80 + .../com/skyflow/vaultLH/core/MediaTypes.java | 13 + .../com/skyflow/vaultLH/core/Nullable.java | 140 ++ .../vaultLH/core/NullableNonemptyFilter.java | 19 + .../skyflow/vaultLH/core/ObjectMappers.java | 37 + .../vaultLH/core/QueryStringMapper.java | 139 ++ .../skyflow/vaultLH/core/RequestOptions.java | 87 + .../vaultLH/core/ResponseBodyInputStream.java | 46 + .../vaultLH/core/ResponseBodyReader.java | 45 + .../vaultLH/core/RetryInterceptor.java | 79 + .../java/com/skyflow/vaultLH/core/Stream.java | 97 + .../com/skyflow/vaultLH/core/Suppliers.java | 23 + .../AsyncRawRecordserviceClient.java | 535 ++++++ .../AsyncRecordserviceClient.java | 136 ++ .../recordservice/RawRecordserviceClient.java | 418 +++++ .../recordservice/RecordserviceClient.java | 132 ++ .../recordservice/requests/DeleteRequest.java | 155 ++ .../requests/DeleteTokenRequest.java | 122 ++ .../requests/DetokenizeRequest.java | 156 ++ .../requests/ExecuteQueryRequest.java | 125 ++ .../recordservice/requests/GetRequest.java | 284 +++ .../recordservice/requests/InsertRequest.java | 181 ++ .../requests/TokenizeRequest.java | 125 ++ .../recordservice/requests/UpdateRequest.java | 181 ++ .../vaultLH/types/ColumnRedactions.java | 125 ++ .../skyflow/vaultLH/types/DeleteResponse.java | 93 + .../vaultLH/types/DeleteResponseObject.java | 156 ++ .../vaultLH/types/DeleteTokenResponse.java | 94 + .../types/DeleteTokenResponseObject.java | 156 ++ .../vaultLH/types/DetokenizeResponse.java | 94 + .../types/DetokenizeResponseObject.java | 243 +++ .../skyflow/vaultLH/types/EnumDataType.java | 30 + .../skyflow/vaultLH/types/EnumUpdateType.java | 24 + .../types/ExecuteQueryRecordResponse.java | 96 + .../vaultLH/types/ExecuteQueryResponse.java | 94 + .../skyflow/vaultLH/types/GetResponse.java | 93 + .../vaultLH/types/InsertRecordData.java | 127 ++ .../skyflow/vaultLH/types/InsertResponse.java | 93 + .../skyflow/vaultLH/types/ProtobufAny.java | 90 + .../vaultLH/types/RecordResponseObject.java | 248 +++ .../com/skyflow/vaultLH/types/RpcStatus.java | 135 ++ .../vaultLH/types/TokenGroupRedactions.java | 125 ++ .../vaultLH/types/TokenizeRequestObject.java | 143 ++ .../vaultLH/types/TokenizeResponse.java | 94 + .../vaultLH/types/TokenizeResponseObject.java | 118 ++ .../types/TokenizeResponseObjectToken.java | 188 ++ .../vaultLH/types/UpdateRecordData.java | 156 ++ .../skyflow/vaultLH/types/UpdateResponse.java | 93 + .../com/skyflow/vaultLH/types/Upsert.java | 118 ++ 394 files changed, 50165 insertions(+), 1 deletion(-) create mode 100644 common/pom.xml create mode 100644 common/src/main/java/com/skyflow/common/ApiClient.java create mode 100644 common/src/main/java/com/skyflow/common/ApiClientBuilder.java create mode 100644 common/src/main/java/com/skyflow/common/AsyncApiClient.java create mode 100644 common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java create mode 100644 common/src/main/java/com/skyflow/common/core/ApiClientApiException.java create mode 100644 common/src/main/java/com/skyflow/common/core/ApiClientException.java create mode 100644 common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java create mode 100644 common/src/main/java/com/skyflow/common/core/ClientOptions.java create mode 100644 common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java create mode 100644 common/src/main/java/com/skyflow/common/core/Environment.java create mode 100644 common/src/main/java/com/skyflow/common/core/FileStream.java create mode 100644 common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java create mode 100644 common/src/main/java/com/skyflow/common/core/MediaTypes.java create mode 100644 common/src/main/java/com/skyflow/common/core/Nullable.java create mode 100644 common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java create mode 100644 common/src/main/java/com/skyflow/common/core/ObjectMappers.java create mode 100644 common/src/main/java/com/skyflow/common/core/QueryStringMapper.java create mode 100644 common/src/main/java/com/skyflow/common/core/RequestOptions.java create mode 100644 common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java create mode 100644 common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java create mode 100644 common/src/main/java/com/skyflow/common/core/RetryInterceptor.java create mode 100644 common/src/main/java/com/skyflow/common/core/Stream.java create mode 100644 common/src/main/java/com/skyflow/common/core/Suppliers.java create mode 100644 common/src/main/java/com/skyflow/common/enums/LogLevel.java create mode 100644 common/src/main/java/com/skyflow/common/errors/BadRequestError.java create mode 100644 common/src/main/java/com/skyflow/common/errors/ErrorCode.java create mode 100644 common/src/main/java/com/skyflow/common/errors/ErrorMessage.java create mode 100644 common/src/main/java/com/skyflow/common/errors/HttpStatus.java create mode 100644 common/src/main/java/com/skyflow/common/errors/NotFoundError.java create mode 100644 common/src/main/java/com/skyflow/common/errors/SkyflowException.java create mode 100644 common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java create mode 100644 common/src/main/java/com/skyflow/common/logs/ErrorLogs.java create mode 100644 common/src/main/java/com/skyflow/common/logs/InfoLogs.java create mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java create mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java create mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java create mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java create mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java create mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java create mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java create mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java create mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java create mode 100644 common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java create mode 100644 common/src/main/java/com/skyflow/common/types/ProtobufAny.java create mode 100644 common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java create mode 100644 common/src/main/java/com/skyflow/common/utils/Constants.java create mode 100644 common/src/main/java/com/skyflow/common/utils/Utils.java create mode 100644 common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java create mode 100644 common/src/test/java/com/skyflow/api/TestClient.java create mode 100644 common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java create mode 100644 v2/pom.xml create mode 100644 v2/src/main/java/com/skyflow/ConnectionClient.java create mode 100644 v2/src/main/java/com/skyflow/Skyflow.java create mode 100644 v2/src/main/java/com/skyflow/VaultClient.java create mode 100644 v2/src/main/java/com/skyflow/config/ConnectionConfig.java create mode 100644 v2/src/main/java/com/skyflow/config/Credentials.java create mode 100644 v2/src/main/java/com/skyflow/config/ManagementConfig.java create mode 100644 v2/src/main/java/com/skyflow/config/VaultConfig.java create mode 100644 v2/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java create mode 100644 v2/src/main/java/com/skyflow/enums/DetectEntities.java create mode 100644 v2/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java create mode 100644 v2/src/main/java/com/skyflow/enums/Env.java create mode 100644 v2/src/main/java/com/skyflow/enums/InterfaceName.java create mode 100644 v2/src/main/java/com/skyflow/enums/LogLevel.java create mode 100644 v2/src/main/java/com/skyflow/enums/MaskingMethod.java create mode 100644 v2/src/main/java/com/skyflow/enums/RedactionType.java create mode 100644 v2/src/main/java/com/skyflow/enums/RequestMethod.java create mode 100644 v2/src/main/java/com/skyflow/enums/TokenMode.java create mode 100644 v2/src/main/java/com/skyflow/enums/TokenType.java create mode 100644 v2/src/main/java/com/skyflow/errors/ErrorCode.java create mode 100644 v2/src/main/java/com/skyflow/errors/ErrorMessage.java create mode 100644 v2/src/main/java/com/skyflow/errors/HttpStatus.java create mode 100644 v2/src/main/java/com/skyflow/errors/SkyflowException.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/ApiClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/Environment.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/FileStream.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/Nullable.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/Stream.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/core/Suppliers.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AuditEventData.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/EntityLocation.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/EntityType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/TokenType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/Transformations.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1Byot.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1Card.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1Locations.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1MemberType.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java create mode 100644 v2/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java create mode 100644 v2/src/main/java/com/skyflow/logs/ErrorLogs.java create mode 100644 v2/src/main/java/com/skyflow/logs/InfoLogs.java create mode 100644 v2/src/main/java/com/skyflow/utils/Constants.java create mode 100644 v2/src/main/java/com/skyflow/utils/HttpUtility.java create mode 100644 v2/src/main/java/com/skyflow/utils/Utils.java create mode 100644 v2/src/main/java/com/skyflow/utils/logger/LogUtil.java create mode 100644 v2/src/main/java/com/skyflow/utils/validations/Validations.java create mode 100644 v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/controller/AuditController.java create mode 100644 v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java create mode 100644 v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java create mode 100644 v2/src/main/java/com/skyflow/vault/controller/DetectController.java create mode 100644 v2/src/main/java/com/skyflow/vault/controller/VaultController.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/DeleteRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/DeleteResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/GetRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/GetResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/InsertRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/InsertResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/QueryRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/QueryResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/UpdateRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/data/UpdateResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/AudioBleep.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/DateTransformation.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/EntityInfo.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/FileInfo.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/FileInput.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/TextIndex.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/TokenFormat.java create mode 100644 v2/src/main/java/com/skyflow/vault/detect/Transformations.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/ColumnValue.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java create mode 100644 v2/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java create mode 100644 v3/pom.xml create mode 100644 v3/src/main/java/com/skyflow/vaultLH/ApiClient.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/Environment.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/Stream.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java create mode 100644 v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 00000000..803af1f6 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.skyflow + skyflow-java + 2.0.0-beta.2 + + + common + 1.0.0 + com.skyflow.common + + + 8 + 8 + UTF-8 + + \ No newline at end of file diff --git a/common/src/main/java/com/skyflow/common/ApiClient.java b/common/src/main/java/com/skyflow/common/ApiClient.java new file mode 100644 index 00000000..f9aec9de --- /dev/null +++ b/common/src/main/java/com/skyflow/common/ApiClient.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common; + +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.Suppliers; +import com.skyflow.common.resources.authentication.AuthenticationClient; +import java.util.function.Supplier; + +public class ApiClient { + protected final ClientOptions clientOptions; + + protected final Supplier authenticationClient; + + public ApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.authenticationClient = Suppliers.memoize(() -> new AuthenticationClient(clientOptions)); + } + + public AuthenticationClient authentication() { + return this.authenticationClient.get(); + } + + public static ApiClientBuilder builder() { + return new ApiClientBuilder(); + } +} diff --git a/common/src/main/java/com/skyflow/common/ApiClientBuilder.java b/common/src/main/java/com/skyflow/common/ApiClientBuilder.java new file mode 100644 index 00000000..68277979 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/ApiClientBuilder.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common; + +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.Environment; +import okhttp3.OkHttpClient; + +public final class ApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private String token = null; + + private Environment environment = Environment.PRODUCTION; + + /** + * Sets token + */ + public ApiClientBuilder token(String token) { + this.token = token; + return this; + } + + public ApiClientBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public ApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public ApiClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public ApiClientBuilder maxRetries(int maxRetries) { + this.clientOptionsBuilder.maxRetries(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public ApiClientBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public ApiClient build() { + if (token == null) { + throw new RuntimeException("Please provide token"); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + clientOptionsBuilder.environment(this.environment); + return new ApiClient(clientOptionsBuilder.build()); + } +} diff --git a/common/src/main/java/com/skyflow/common/AsyncApiClient.java b/common/src/main/java/com/skyflow/common/AsyncApiClient.java new file mode 100644 index 00000000..310749e3 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/AsyncApiClient.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common; + +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.Suppliers; +import com.skyflow.common.resources.authentication.AsyncAuthenticationClient; +import java.util.function.Supplier; + +public class AsyncApiClient { + protected final ClientOptions clientOptions; + + protected final Supplier authenticationClient; + + public AsyncApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.authenticationClient = Suppliers.memoize(() -> new AsyncAuthenticationClient(clientOptions)); + } + + public AsyncAuthenticationClient authentication() { + return this.authenticationClient.get(); + } + + public static AsyncApiClientBuilder builder() { + return new AsyncApiClientBuilder(); + } +} diff --git a/common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java b/common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java new file mode 100644 index 00000000..90c42570 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common; + +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.Environment; +import okhttp3.OkHttpClient; + +public final class AsyncApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private String token = null; + + private Environment environment = Environment.PRODUCTION; + + /** + * Sets token + */ + public AsyncApiClientBuilder token(String token) { + this.token = token; + return this; + } + + public AsyncApiClientBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public AsyncApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public AsyncApiClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public AsyncApiClientBuilder maxRetries(int maxRetries) { + this.clientOptionsBuilder.maxRetries(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public AsyncApiClientBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public AsyncApiClient build() { + if (token == null) { + throw new RuntimeException("Please provide token"); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + clientOptionsBuilder.environment(this.environment); + return new AsyncApiClient(clientOptionsBuilder.build()); + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ApiClientApiException.java b/common/src/main/java/com/skyflow/common/core/ApiClientApiException.java new file mode 100644 index 00000000..98d9f740 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ApiClientApiException.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class ApiClientApiException extends ApiClientException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + private final Map> headers; + + public ApiClientApiException(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + } + + public ApiClientApiException(String message, int statusCode, Object body, Response rawResponse) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + /** + * @return the headers + */ + public Map> headers() { + return this.headers; + } + + @java.lang.Override + public String toString() { + return "ApiClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + + "}"; + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ApiClientException.java b/common/src/main/java/com/skyflow/common/core/ApiClientException.java new file mode 100644 index 00000000..6537d6e8 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ApiClientException.java @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +/** + * This class serves as the base exception for all errors in the SDK. + */ +public class ApiClientException extends RuntimeException { + public ApiClientException(String message) { + super(message); + } + + public ApiClientException(String message, Exception e) { + super(message, e); + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java b/common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java new file mode 100644 index 00000000..7dbcd35f --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + +public final class ApiClientHttpResponse { + + private final T body; + + private final Map> headers; + + public ApiClientHttpResponse(T body, Response rawResponse) { + this.body = body; + + Map> headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + this.headers = headers; + } + + public T body() { + return this.body; + } + + public Map> headers() { + return headers; + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ClientOptions.java b/common/src/main/java/com/skyflow/common/core/ClientOptions.java new file mode 100644 index 00000000..f60d6b56 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ClientOptions.java @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final int timeout; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + int timeout) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("X-Fern-Language", "JAVA"); + put("X-Fern-SDK-Name", "com.skyflow.fern:api-sdk"); + put("X-Fern-SDK-Version", "0.0.279"); + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.timeout = timeout; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int maxRetries = 2; + + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { + this.timeout = timeout; + return this; + } + + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + public ClientOptions build() { + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor(this.maxRetries)); + } + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java b/common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java new file mode 100644 index 00000000..e3869be3 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQueries; + +/** + * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. + */ +class DateTimeDeserializer extends JsonDeserializer { + private static final SimpleModule MODULE; + + static { + MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); + } + + /** + * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. + * + * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. + */ + public static SimpleModule getModule() { + return MODULE; + } + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonToken token = parser.currentToken(); + if (token == JsonToken.VALUE_NUMBER_INT) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); + } else { + TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( + parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); + + if (temporal.query(TemporalQueries.offset()) == null) { + return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); + } else { + return OffsetDateTime.from(temporal); + } + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/Environment.java b/common/src/main/java/com/skyflow/common/core/Environment.java new file mode 100644 index 00000000..75102104 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/Environment.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +public final class Environment { + public static final Environment PRODUCTION = new Environment("https://manage.skyflowapis.com"); + + public static final Environment SANDBOX = new Environment("https://manage.skyflowapis-preview.com"); + + private final String url; + + private Environment(String url) { + this.url = url; + } + + public String getUrl() { + return this.url; + } + + public static Environment custom(String url) { + return new Environment(url); + } +} diff --git a/common/src/main/java/com/skyflow/common/core/FileStream.java b/common/src/main/java/com/skyflow/common/core/FileStream.java new file mode 100644 index 00000000..6a999376 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/FileStream.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a file stream with associated metadata for file uploads. + */ +public class FileStream { + private final InputStream inputStream; + private final String fileName; + private final MediaType contentType; + + /** + * Constructs a FileStream with the given input stream and optional metadata. + * + * @param inputStream The input stream of the file content. Must not be null. + * @param fileName The name of the file, or null if unknown. + * @param contentType The MIME type of the file content, or null if unknown. + * @throws NullPointerException if inputStream is null + */ + public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { + this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); + this.fileName = fileName; + this.contentType = contentType; + } + + public FileStream(InputStream inputStream) { + this(inputStream, null, null); + } + + public InputStream getInputStream() { + return inputStream; + } + + @Nullable + public String getFileName() { + return fileName; + } + + @Nullable + public MediaType getContentType() { + return contentType; + } + + /** + * Creates a RequestBody suitable for use with OkHttp client. + * + * @return A RequestBody instance representing this file stream. + */ + public RequestBody toRequestBody() { + return new InputStreamRequestBody(contentType, inputStream); + } +} diff --git a/common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java b/common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java new file mode 100644 index 00000000..e5bdc8ad --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.internal.Util; +import okio.BufferedSink; +import okio.Okio; +import okio.Source; +import org.jetbrains.annotations.Nullable; + +/** + * A custom implementation of OkHttp's RequestBody that wraps an InputStream. + * This class allows streaming of data from an InputStream directly to an HTTP request body, + * which is useful for file uploads or sending large amounts of data without loading it all into memory. + */ +public class InputStreamRequestBody extends RequestBody { + private final InputStream inputStream; + private final MediaType contentType; + + /** + * Constructs an InputStreamRequestBody with the specified content type and input stream. + * + * @param contentType the MediaType of the content, or null if not known + * @param inputStream the InputStream containing the data to be sent + * @throws NullPointerException if inputStream is null + */ + public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { + this.contentType = contentType; + this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); + } + + /** + * Returns the content type of this request body. + * + * @return the MediaType of the content, or null if not specified + */ + @Nullable + @Override + public MediaType contentType() { + return contentType; + } + + /** + * Returns the content length of this request body, if known. + * This method attempts to determine the length using the InputStream's available() method, + * which may not always accurately reflect the total length of the stream. + * + * @return the content length, or -1 if the length is unknown + * @throws IOException if an I/O error occurs + */ + @Override + public long contentLength() throws IOException { + return inputStream.available() == 0 ? -1 : inputStream.available(); + } + + /** + * Writes the content of the InputStream to the given BufferedSink. + * This method is responsible for transferring the data from the InputStream to the network request. + * + * @param sink the BufferedSink to write the content to + * @throws IOException if an I/O error occurs during writing + */ + @Override + public void writeTo(BufferedSink sink) throws IOException { + Source source = null; + try { + source = Okio.source(inputStream); + sink.writeAll(source); + } finally { + Util.closeQuietly(Objects.requireNonNull(source)); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/MediaTypes.java b/common/src/main/java/com/skyflow/common/core/MediaTypes.java new file mode 100644 index 00000000..ed48020a --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/common/src/main/java/com/skyflow/common/core/Nullable.java b/common/src/main/java/com/skyflow/common/core/Nullable.java new file mode 100644 index 00000000..77d34027 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/Nullable.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.Optional; +import java.util.function.Function; + +public final class Nullable { + + private final Either, Null> value; + + private Nullable() { + this.value = Either.left(Optional.empty()); + } + + private Nullable(T value) { + if (value == null) { + this.value = Either.right(Null.INSTANCE); + } else { + this.value = Either.left(Optional.of(value)); + } + } + + public static Nullable ofNull() { + return new Nullable<>(null); + } + + public static Nullable of(T value) { + return new Nullable<>(value); + } + + public static Nullable empty() { + return new Nullable<>(); + } + + public static Nullable ofOptional(Optional value) { + if (value.isPresent()) { + return of(value.get()); + } else { + return empty(); + } + } + + public boolean isNull() { + return this.value.isRight(); + } + + public boolean isEmpty() { + return this.value.isLeft() && !this.value.getLeft().isPresent(); + } + + public T get() { + if (this.isNull()) { + return null; + } + + return this.value.getLeft().get(); + } + + public Nullable map(Function mapper) { + if (this.isNull()) { + return Nullable.ofNull(); + } + + return Nullable.ofOptional(this.value.getLeft().map(mapper)); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Nullable)) { + return false; + } + + if (((Nullable) other).isNull() && this.isNull()) { + return true; + } + + return this.value.getLeft().equals(((Nullable) other).value.getLeft()); + } + + private static final class Either { + private L left = null; + private R right = null; + + private Either(L left, R right) { + if (left != null && right != null) { + throw new IllegalArgumentException("Left and right argument cannot both be non-null."); + } + + if (left == null && right == null) { + throw new IllegalArgumentException("Left and right argument cannot both be null."); + } + + if (left != null) { + this.left = left; + } + + if (right != null) { + this.right = right; + } + } + + public static Either left(L left) { + return new Either<>(left, null); + } + + public static Either right(R right) { + return new Either<>(null, right); + } + + public boolean isLeft() { + return this.left != null; + } + + public boolean isRight() { + return this.right != null; + } + + public L getLeft() { + if (!this.isLeft()) { + throw new IllegalArgumentException("Cannot get left from right Either."); + } + return this.left; + } + + public R getRight() { + if (!this.isRight()) { + throw new IllegalArgumentException("Cannot get right from left Either."); + } + return this.right; + } + } + + private static final class Null { + private static final Null INSTANCE = new Null(); + + private Null() {} + } +} diff --git a/common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java b/common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java new file mode 100644 index 00000000..c0a6fe3d --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.Optional; + +public final class NullableNonemptyFilter { + @Override + public boolean equals(Object o) { + boolean isOptionalEmpty = isOptionalEmpty(o); + + return isOptionalEmpty; + } + + private boolean isOptionalEmpty(Object o) { + return o instanceof Optional && !((Optional) o).isPresent(); + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ObjectMappers.java b/common/src/main/java/com/skyflow/common/core/ObjectMappers.java new file mode 100644 index 00000000..feee4402 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ObjectMappers.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.IOException; + +public final class ObjectMappers { + public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .addModule(new JavaTimeModule()) + .addModule(DateTimeDeserializer.getModule()) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + private ObjectMappers() {} + + public static String stringify(Object o) { + try { + return JSON_MAPPER + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .writerWithDefaultPrettyPrinter() + .writeValueAsString(o); + } catch (IOException e) { + return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/QueryStringMapper.java b/common/src/main/java/com/skyflow/common/core/QueryStringMapper.java new file mode 100644 index 00000000..877b4307 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/QueryStringMapper.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import okhttp3.MultipartBody; + +public class QueryStringMapper { + + private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; + + public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + httpUrl.addQueryParameter(key, valueNode.textValue()); + } else { + httpUrl.addQueryParameter(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); + } else { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); + } + } + } + + public static void addFormDataPart( + MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + multipartBody.addFormDataPart(key, valueNode.textValue()); + } else { + multipartBody.addFormDataPart(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().textValue()); + } else { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().toString()); + } + } + } + + public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator> fields = object.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + + String key = "[" + field.getKey() + "]"; + + if (field.getValue().isObject()) { + List> flatField = + flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); + addAll(flat, flatField, key); + } else if (field.getValue().isArray()) { + List> flatField = + flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); + addAll(flat, flatField, ""); + } else { + flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); + } + } + + return flat; + } + + private static List> flattenArray( + ArrayNode array, String key, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator elements = array.elements(); + + int index = 0; + while (elements.hasNext()) { + JsonNode element = elements.next(); + + String indexKey = key + "[" + index + "]"; + + if (arraysAsRepeats) { + indexKey = key; + } + + if (element.isObject()) { + List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else if (element.isArray()) { + List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else { + flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); + } + + index++; + } + + return flat; + } + + private static void addAll( + List> target, List> source, String prefix) { + for (Map.Entry entry : source) { + Map.Entry entryToAdd = + new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); + target.add(entryToAdd); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/RequestOptions.java b/common/src/main/java/com/skyflow/common/core/RequestOptions.java new file mode 100644 index 00000000..df0db4f7 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/RequestOptions.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +public final class RequestOptions { + private final String token; + + private final Optional timeout; + + private final TimeUnit timeoutTimeUnit; + + private final Map headers; + + private final Map> headerSuppliers; + + private RequestOptions( + String token, + Optional timeout, + TimeUnit timeoutTimeUnit, + Map headers, + Map> headerSuppliers) { + this.token = token; + this.timeout = timeout; + this.timeoutTimeUnit = timeoutTimeUnit; + this.headers = headers; + this.headerSuppliers = headerSuppliers; + } + + public Optional getTimeout() { + return timeout; + } + + public TimeUnit getTimeoutTimeUnit() { + return timeoutTimeUnit; + } + + public Map getHeaders() { + Map headers = new HashMap<>(); + if (this.token != null) { + headers.put("Authorization", "Bearer " + this.token); + } + headers.putAll(this.headers); + this.headerSuppliers.forEach((key, supplier) -> { + headers.put(key, supplier.get()); + }); + return headers; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private String token = null; + + private Optional timeout = Optional.empty(); + + private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + public Builder token(String token) { + this.token = token; + return this; + } + + public Builder timeout(Integer timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { + this.timeout = Optional.of(timeout); + this.timeoutTimeUnit = timeoutTimeUnit; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + public RequestOptions build() { + return new RequestOptions(token, timeout, timeoutTimeUnit, headers, headerSuppliers); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java b/common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java new file mode 100644 index 00000000..2bdd5e5a --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.io.FilterInputStream; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the stream is closed. + * + * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. + * It retrieves the InputStream from the Response and overrides the close method to close + * both the InputStream and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyInputStream extends FilterInputStream { + private final Response response; + + /** + * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp + * Response object. + * + * @param response the OkHttp Response object from which the InputStream is retrieved + * @throws IOException if an I/O error occurs while retrieving the InputStream + */ + public ResponseBodyInputStream(Response response) throws IOException { + super(response.body().byteStream()); + this.response = response; + } + + /** + * Closes the InputStream and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the stream is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the stream is closed + } +} diff --git a/common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java b/common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java new file mode 100644 index 00000000..73be351b --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.io.FilterReader; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the reader is closed. + * + * This class extends FilterReader and takes an OkHttp Response object as a parameter. + * It retrieves the Reader from the Response and overrides the close method to close + * both the Reader and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyReader extends FilterReader { + private final Response response; + + /** + * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. + * + * @param response the OkHttp Response object from which the Reader is retrieved + * @throws IOException if an I/O error occurs while retrieving the Reader + */ + public ResponseBodyReader(Response response) throws IOException { + super(response.body().charStream()); + this.response = response; + } + + /** + * Closes the Reader and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the reader is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the reader is closed + } +} diff --git a/common/src/main/java/com/skyflow/common/core/RetryInterceptor.java b/common/src/main/java/com/skyflow/common/core/RetryInterceptor.java new file mode 100644 index 00000000..987548ea --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/RetryInterceptor.java @@ -0,0 +1,78 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.io.IOException; +import java.time.Duration; +import java.util.Optional; +import java.util.Random; +import okhttp3.Interceptor; +import okhttp3.Response; + +public class RetryInterceptor implements Interceptor { + + private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private final ExponentialBackoff backoff; + private final Random random = new Random(); + + public RetryInterceptor(int maxRetries) { + this.backoff = new ExponentialBackoff(maxRetries); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Response response = chain.proceed(chain.request()); + + if (shouldRetry(response.code())) { + return retryChain(response, chain); + } + + return response; + } + + private Response retryChain(Response response, Chain chain) throws IOException { + Optional nextBackoff = this.backoff.nextBackoff(); + while (nextBackoff.isPresent()) { + try { + Thread.sleep(nextBackoff.get().toMillis()); + } catch (InterruptedException e) { + throw new IOException("Interrupted while trying request", e); + } + response.close(); + response = chain.proceed(chain.request()); + if (shouldRetry(response.code())) { + nextBackoff = this.backoff.nextBackoff(); + } else { + return response; + } + } + + return response; + } + + private static boolean shouldRetry(int statusCode) { + return statusCode == 408 || statusCode == 429 || statusCode >= 500; + } + + private final class ExponentialBackoff { + + private final int maxNumRetries; + + private int retryNumber = 0; + + ExponentialBackoff(int maxNumRetries) { + this.maxNumRetries = maxNumRetries; + } + + public Optional nextBackoff() { + retryNumber += 1; + if (retryNumber > maxNumRetries) { + return Optional.empty(); + } + + int upperBound = (int) Math.pow(2, retryNumber); + return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/core/Stream.java b/common/src/main/java/com/skyflow/common/core/Stream.java new file mode 100644 index 00000000..486fc238 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/Stream.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.io.Reader; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Scanner; + +/** + * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing + * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. + *

+ * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a + * {@code Scanner} to block during iteration if the next object is not available. + * + * @param The type of objects in the stream. + */ +public final class Stream implements Iterable { + /** + * The {@link Class} of the objects in the stream. + */ + private final Class valueType; + /** + * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. + */ + private final Scanner scanner; + + /** + * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. + * + * @param valueType The class of the objects in the stream. + * @param reader The reader that provides the streamed data. + * @param delimiter The delimiter used to separate elements in the stream. + */ + public Stream(Class valueType, Reader reader, String delimiter) { + this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.valueType = valueType; + } + + /** + * Returns an iterator over the elements in this stream that blocks during iteration when the next object is + * not yet available. + * + * @return An iterator that can be used to traverse the elements in the stream. + */ + @Override + public Iterator iterator() { + return new Iterator() { + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Removing elements from {@code Stream} is not supported. + * + * @throws UnsupportedOperationException Always, as removal is not supported. + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } +} diff --git a/common/src/main/java/com/skyflow/common/core/Suppliers.java b/common/src/main/java/com/skyflow/common/core/Suppliers.java new file mode 100644 index 00000000..5992c2d0 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/core/Suppliers.java @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.core; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public final class Suppliers { + private Suppliers() {} + + public static Supplier memoize(Supplier delegate) { + AtomicReference value = new AtomicReference<>(); + return () -> { + T val = value.get(); + if (val == null) { + val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); + } + return val; + }; + } +} diff --git a/common/src/main/java/com/skyflow/common/enums/LogLevel.java b/common/src/main/java/com/skyflow/common/enums/LogLevel.java new file mode 100644 index 00000000..ff17c291 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/enums/LogLevel.java @@ -0,0 +1,9 @@ +package com.skyflow.common.enums; + +public enum LogLevel { + OFF, + ERROR, + WARN, + INFO, + DEBUG +} diff --git a/common/src/main/java/com/skyflow/common/errors/BadRequestError.java b/common/src/main/java/com/skyflow/common/errors/BadRequestError.java new file mode 100644 index 00000000..85f14f70 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/BadRequestError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.errors; + +import com.skyflow.common.core.ApiClientApiException; +import java.util.Map; +import okhttp3.Response; + +public final class BadRequestError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final Map body; + + public BadRequestError(Map body) { + super("BadRequestError", 400, body); + this.body = body; + } + + public BadRequestError(Map body, Response rawResponse) { + super("BadRequestError", 400, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Map body() { + return this.body; + } +} diff --git a/common/src/main/java/com/skyflow/common/errors/ErrorCode.java b/common/src/main/java/com/skyflow/common/errors/ErrorCode.java new file mode 100644 index 00000000..d99e3ff2 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/ErrorCode.java @@ -0,0 +1,18 @@ +package com.skyflow.common.errors; + +public enum ErrorCode { + INVALID_INPUT(400), + INVALID_INDEX(404), + SERVER_ERROR(500), + PARTIAL_SUCCESS(500); + + private final int code; + + ErrorCode(int code) { + this.code = code; + } + + public int getCode() { + return code; + } +} diff --git a/common/src/main/java/com/skyflow/common/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/common/errors/ErrorMessage.java new file mode 100644 index 00000000..a9b62243 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/ErrorMessage.java @@ -0,0 +1,162 @@ +package com.skyflow.common.errors; + +import com.skyflow.common.utils.Constants; + +public enum ErrorMessage { + // Client initialization + VaultIdAlreadyInConfigList("%s0 Validation error. VaultId is present in an existing config. Specify a new vaultId in config."), + VaultIdNotInConfigList("%s0 Validation error. VaultId is missing from the config. Specify the vaultIds from configs."), + ConnectionIdAlreadyInConfigList("%s0 Validation error. ConnectionId is present in an existing config. Specify a connectionId in config."), + ConnectionIdNotInConfigList("%s0 Validation error. ConnectionId is missing from the config. Specify the connectionIds from configs."), + EmptyCredentials("%s0 Validation error. Invalid credentials. Credentials must not be empty."), + + // Vault config + InvalidVaultId("%s0 Initialization failed. Invalid vault ID. Specify a valid vault ID."), + EmptyVaultId("%s0 Initialization failed. Invalid vault ID. Vault ID must not be empty."), + InvalidClusterId("%s0 Initialization failed. Invalid cluster ID. Specify cluster ID."), + EmptyClusterId("%s0 Initialization failed. Invalid cluster ID. Specify a valid cluster ID."), + + // Connection config + InvalidConnectionId("%s0 Initialization failed. Invalid connection ID. Specify a valid connection ID."), + EmptyConnectionId("%s0 Initialization failed. Invalid connection ID. Connection ID must not be empty."), + InvalidConnectionUrl("%s0 Initialization failed. Invalid connection URL. Specify a valid connection URL."), + EmptyConnectionUrl("%s0 Initialization failed. Invalid connection URL. Connection URL must not be empty."), + InvalidConnectionUrlFormat("%s0 Initialization failed. Connection URL is not a valid URL. Specify a valid connection URL."), + + // Credentials + MultipleTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify only one from 'path', 'credentialsString', 'token' or 'apiKey'."), + NoTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify any one from 'path', 'credentialsString', 'token' or 'apiKey'."), + EmptyCredentialFilePath("%s0 Initialization failed. Invalid credentials. Credentials file path must not be empty."), + EmptyCredentialsString("%s0 Initialization failed. Invalid credentials. Credentials string must not be empty."), + EmptyToken("%s0 Initialization failed. Invalid credentials. Token must not be empty."), + EmptyApikey("%s0 Initialization failed. Invalid credentials. Api key must not be empty."), + InvalidApikey("%s0 Initialization failed. Invalid credentials. Specify valid api key."), + EmptyRoles("%s0 Initialization failed. Invalid roles. Specify at least one role."), + EmptyRoleInRoles("%s0 Initialization failed. Invalid role. Specify a valid role."), + EmptyContext("%s0 Initialization failed. Invalid context. Specify a valid context."), + + // Bearer token generation + FileNotFound("%s0 Initialization failed. Credential file not found at %s1. Verify the file path."), + FileInvalidJson("%s0 Initialization failed. File at %s1 is not in valid JSON format. Verify the file contents."), + CredentialsStringInvalidJson("%s0 Initialization failed. Credentials string is not in valid JSON format. Verify the credentials string contents."), + InvalidCredentials("%s0 Initialization failed. Invalid credentials provided. Specify valid credentials."), + MissingPrivateKey("%s0 Initialization failed. Unable to read private key in credentials. Verify your private key."), + MissingClientId("%s0 Initialization failed. Unable to read client ID in credentials. Verify your client ID."), + MissingKeyId("%s0 Initialization failed. Unable to read key ID in credentials. Verify your key ID."), + MissingTokenUri("%s0 Initialization failed. Unable to read token URI in credentials. Verify your token URI."), + InvalidTokenUri("%s0 Initialization failed. Token URI in not a valid URL in credentials. Verify your token URI."), + JwtInvalidFormat("%s0 Initialization failed. Invalid private key format. Verify your credentials."), + InvalidAlgorithm("%s0 Initialization failed. Invalid algorithm to parse private key. Specify valid algorithm."), + InvalidKeySpec("%s0 Initialization failed. Unable to parse RSA private key. Verify your credentials."), + JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."), + MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."), + MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."), + + // Insert + TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."), + EmptyTable("%s0 Validation error. 'table' can't be empty. Specify a table."), + ValuesKeyError("%s0 Validation error. 'values' key is missing from the payload. Specify a 'values' key."), + EmptyValues("%s0 Validation error. 'values' can't be empty. Specify values."), + EmptyKeyInValues("%s0 Validation error. Invalid key in values. Specify a valid key."), + EmptyValueInValues("%s0 Validation error. Invalid value in values. Specify a valid value."), + TokensKeyError("%s0 Validation error. 'tokens' key is missing from the payload. Specify a 'tokens' key."), + EmptyTokens("%s0 Validation error. The 'tokens' field is empty. Specify tokens for one or more fields."), + EmptyKeyInTokens("%s0 Validation error. Invalid key tokens. Specify a valid key."), + EmptyValueInTokens("%s0 Validation error. Invalid value in tokens. Specify a valid value."), + EmptyUpsert("%s0 Validation error. 'upsert' key can't be empty. Specify an upsert column."), + HomogenousNotSupportedWithUpsert("%s0 Validation error. 'homogenous' is not supported with 'upsert'. Specify either 'homogenous' or 'upsert'."), + TokensPassedForTokenModeDisable("%s0 Validation error. 'tokenMode' wasn't specified. Set 'tokenMode' to 'ENABLE' to insert tokens."), + NoTokensWithTokenMode("%s0 Validation error. Tokens weren't specified for records while 'tokenMode' was %s1. Specify tokens."), + MismatchOfFieldsAndTokens("%s0 Validation error. 'fields' and 'tokens' have different columns names. Verify that 'fields' and 'tokens' columns match."), + InsufficientTokensPassedForTokenModeEnableStrict("%s0 Validation error. 'tokenMode' is set to 'ENABLE_STRICT', but some fields are missing tokens. Specify tokens for all fields."), + BatchInsertPartialSuccess("%s0 Insert operation completed with partial success."), + BatchInsertFailure("%s0 Insert operation failed."), + + // Detokenize + InvalidDetokenizeData("%s0 Validation error. Invalid detokenize data. Specify valid detokenize data."), + EmptyDetokenizeData("%s0 Validation error. Invalid data tokens. Specify at least one data token."), + EmptyTokenInDetokenizeData("%s0 Validation error. Invalid data tokens. Specify a valid data token."), + + // Get + IdsKeyError("%s0 Validation error. 'ids' key is missing from the payload. Specify an 'ids' key."), + EmptyIds("%s0 Validation error. 'ids' can't be empty. Specify at least one id."), + EmptyIdInIds("%s0 Validation error. Invalid id in 'ids'. Specify a valid id."), + EmptyFields("%s0 Validation error. Fields are empty in get payload. Specify at least one field."), + EmptyFieldInFields("%s0 Validation error. Invalid field in 'fields'. Specify a valid field."), + RedactionKeyError("%s0 Validation error. 'redaction' key is missing from the payload. Specify a 'redaction' key."), + RedactionWithTokensNotSupported("%s0 Validation error. 'redaction' can't be used when 'returnTokens' is specified. Remove 'redaction' from payload if 'returnTokens' is specified."), + TokensGetColumnNotSupported("%s0 Validation error. Column name and/or column values can't be used when 'returnTokens' is specified. Remove unique column values or 'returnTokens' from the payload."), + EmptyOffset("%s0 Validation error. 'offset' can't be empty. Specify an offset."), + EmptyLimit("%s0 Validation error. 'limit' can't be empty. Specify a limit."), + UniqueColumnOrIdsKeyError("%s0 Validation error. 'ids' or 'columnName' key is missing from the payload. Specify the ids or unique 'columnName' in payload."), + BothIdsAndColumnDetailsSpecified("%s0 Validation error. Both Skyflow IDs and column details can't be specified. Either specify Skyflow IDs or unique column details."), + ColumnNameKeyError("%s0 Validation error. 'columnName' isn't specified whereas 'columnValues' are specified. Either add 'columnName' or remove 'columnValues'."), + EmptyColumnName("%s0 Validation error. 'columnName' can't be empty. Specify a column name."), + ColumnValuesKeyErrorGet("%s0 Validation error. 'columnValues' aren't specified whereas 'columnName' is specified. Either add 'columnValues' or remove 'columnName'."), + EmptyColumnValues("%s0 Validation error. 'columnValues' can't be empty. Specify at least one column value"), + EmptyValueInColumnValues("%s0 Validation error. Invalid value in column values. Specify a valid column value."), + + TokenKeyError("%s0 Validation error. 'token' key is missing from the payload. Specify a 'token' key."), + PartialSuccess("%s0 Validation error. Check 'SkyflowError.data' for details."), + + // Update + DataKeyError("%s0 Validation error. 'data' key is missing from the payload. Specify a 'data' key."), + EmptyData("%s0 Validation error. 'data' can't be empty. Specify data."), + SkyflowIdKeyError("%s0 Validation error. 'skyflow_id' is missing from the data payload. Specify a 'skyflow_id'."), + InvalidSkyflowIdType("%s0 Validation error. Invalid type for 'skyflow_id' in data payload. Specify 'skyflow_id' as a string."), + EmptySkyflowId("%s0 Validation error. 'skyflow_id' can't be empty. Specify a skyflow id."), + + // Query + QueryKeyError("%s0 Validation error. 'query' key is missing from the payload. Specify a 'query' key."), + EmptyQuery("%s0 Validation error. 'query' can't be empty. Specify a query"), + + // Tokenize + ColumnValuesKeyErrorTokenize("%s0 Validation error. 'columnValues' key is missing from the payload. Specify a 'columnValues' key."), + EmptyColumnGroupInColumnValue("%s0 Validation error. Invalid column group in column value. Specify a valid column group."), + + // Connection + InvalidRequestHeaders("%s0 Validation error. Request headers aren't valid. Specify valid request headers."), + EmptyRequestHeaders("%s0 Validation error. Request headers are empty. Specify valid request headers."), + InvalidPathParams("%s0 Validation error. Path parameters aren't valid. Specify valid path parameters."), + EmptyPathParams("%s0 Validation error. Path parameters are empty. Specify valid path parameters."), + InvalidQueryParams("%s0 Validation error. Query parameters aren't valid. Specify valid query parameters."), + EmptyQueryParams("%s0 Validation error. Query parameters are empty. Specify valid query parameters."), + 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."), + + // 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."), + + //Detect Files + InvalidNullFileInDeIdentifyFile("%s0 Validation error. The file field is required and must not be null. Specify a valid file object."), + InvalidFilePath("%s0 Validation error. The file path is invalid. Specify a valid file path."), + BothFileAndFilePathProvided("%s0 Validation error. Both file and filePath are provided. Specify either file object or filePath, not both."), + FileNotFoundToDeidentify("%s0 Validation error. The file to deidentify was not found at the specified path. Verify the file path and try again."), + FileNotReadableToDeidentify("%s0 Validation error. The file to deidentify is not readable. Check the file permissions and try again."), + InvalidPixelDensityToDeidentifyFile("%s0 Validation error. Should be a positive integer. Specify a valid pixel density."), + InvalidMaxResolution("%s0 Validation error. Should be a positive integer. Specify a valid max resolution."), + OutputDirectoryNotFound("%s0 Validation error. The output directory for deidentified files was not found at the specified path. Verify the output directory path and try again."), + InvalidPermission("%s0 Validation error. The output directory for deidentified files is not writable. Check the directory permissions and try again."), + InvalidWaitTime("%s0 Validation error. The wait time for deidentify file operation should be a positive integer. Specify a valid wait time."), + WaitTimeExceedsLimit("%s0 Validation error. The wait time for deidentify file operation exceeds the maximum limit of 64 seconds. Specify a wait time less than or equal to 60 seconds."), + InvalidOrEmptyRunId("%s0 Validation error. The run ID is invalid or empty. Specify a valid run ID."), + 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."), + 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."), + // Generic + ErrorOccurred("%s0 API error. Error occurred.") + ; + private final String message; + + ErrorMessage(String message) { + this.message = message.replace("%s0", Constants.SDK_PREFIX); + } + + public String getMessage() { + return message; + } +} diff --git a/common/src/main/java/com/skyflow/common/errors/HttpStatus.java b/common/src/main/java/com/skyflow/common/errors/HttpStatus.java new file mode 100644 index 00000000..571a93e5 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/HttpStatus.java @@ -0,0 +1,15 @@ +package com.skyflow.common.errors; + +public enum HttpStatus { + BAD_REQUEST("Bad Request"); + + private final String httpStatus; + + HttpStatus(String httpStatus) { + this.httpStatus = httpStatus; + } + + public String getHttpStatus() { + return httpStatus; + } +} diff --git a/common/src/main/java/com/skyflow/common/errors/NotFoundError.java b/common/src/main/java/com/skyflow/common/errors/NotFoundError.java new file mode 100644 index 00000000..abc4523a --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/NotFoundError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.errors; + +import com.skyflow.common.core.ApiClientApiException; +import java.util.Map; +import okhttp3.Response; + +public final class NotFoundError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final Map body; + + public NotFoundError(Map body) { + super("NotFoundError", 404, body); + this.body = body; + } + + public NotFoundError(Map body, Response rawResponse) { + super("NotFoundError", 404, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Map body() { + return this.body; + } +} diff --git a/common/src/main/java/com/skyflow/common/errors/SkyflowException.java b/common/src/main/java/com/skyflow/common/errors/SkyflowException.java new file mode 100644 index 00000000..8f07689b --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/SkyflowException.java @@ -0,0 +1,135 @@ +package com.skyflow.common.errors; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.skyflow.common.utils.Constants; + +import java.util.List; +import java.util.Map; + +public class SkyflowException extends Exception { + private String requestId; + private Integer grpcCode; + private Integer httpCode; + private String message; + private String httpStatus; + private JsonArray details; + private JsonObject responseBody; + + public SkyflowException(String message) { + super(message); + this.message = message; + } + + public SkyflowException(Throwable cause) { + super(cause); + this.message = cause.getMessage(); + } + + public SkyflowException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public SkyflowException(int code, String message) { + super(message); + this.httpCode = code; + this.message = message; + this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); + this.details = new JsonArray(); + } + + public SkyflowException(int httpCode, Throwable cause, Map> responseHeaders, String responseBody) { + super(cause); + this.httpCode = httpCode > 0 ? httpCode : 400; + try { + setRequestId(responseHeaders); + setResponseBody(responseBody, responseHeaders); + } catch (Exception e) { + this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); + String fullMessage = responseBody != null ? responseBody : + (cause.getLocalizedMessage() != null ? cause.getMessage() : ErrorMessage.ErrorOccurred.getMessage()); + this.message = fullMessage.split("HTTP response code:")[0].trim(); + } + } + + private void setResponseBody(String responseBody, Map> responseHeaders) { + this.responseBody = JsonParser.parseString(responseBody).getAsJsonObject(); + if (this.responseBody.get("error") != null) { + setGrpcCode(); + setHttpStatus(); + setMessage(); + setDetails(responseHeaders); + } + } + + public String getRequestId() { + return requestId; + } + + private void setRequestId(Map> responseHeaders) { + List ids = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY); + this.requestId = ids == null ? null : ids.get(0); + } + + private void setMessage() { + JsonElement messageElement = ((JsonObject) responseBody.get("error")).get("message"); + this.message = messageElement == null ? null : messageElement.getAsString(); + } + + private void setGrpcCode() { + JsonElement grpcElement = ((JsonObject) responseBody.get("error")).get("grpc_code"); + this.grpcCode = grpcElement == null ? null : grpcElement.getAsInt(); + } + + private void setHttpStatus() { + JsonElement statusElement = ((JsonObject) responseBody.get("error")).get("http_status"); + this.httpStatus = statusElement == null ? null : statusElement.getAsString(); + } + + public int getHttpCode() { + return httpCode; + } + + public JsonArray getDetails() { + return details; + } + + private void setDetails(Map> responseHeaders) { + JsonElement detailsElement = ((JsonObject) responseBody.get("error")).get("details"); + List errorFromClientHeader = responseHeaders.get(Constants.ERROR_FROM_CLIENT_HEADER_KEY); + if (detailsElement != null) { + this.details = detailsElement.getAsJsonArray(); + } + if (errorFromClientHeader != null) { + this.details = this.details == null ? new JsonArray() : this.details; + String errorFromClient = errorFromClientHeader.get(0); + JsonObject detailObject = new JsonObject(); + detailObject.addProperty("errorFromClient", errorFromClient); + this.details.add(detailObject); + } + } + + public Integer getGrpcCode() { + return grpcCode; + } + + public String getHttpStatus() { + return httpStatus; + } + + @Override + public String getMessage() { + return message; + } + + @Override + public String toString() { + return String.format( + "%n requestId: %s%n grpcCode: %s%n httpCode: %s%n httpStatus: %s%n message: %s%n details: %s", + this.requestId, this.grpcCode, this.httpCode, this.httpStatus, this.message, this.details + ); + } +} diff --git a/common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java b/common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java new file mode 100644 index 00000000..9625d45b --- /dev/null +++ b/common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.errors; + +import com.skyflow.common.core.ApiClientApiException; +import java.util.Map; +import okhttp3.Response; + +public final class UnauthorizedError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final Map body; + + public UnauthorizedError(Map body) { + super("UnauthorizedError", 401, body); + this.body = body; + } + + public UnauthorizedError(Map body, Response rawResponse) { + super("UnauthorizedError", 401, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Map body() { + return this.body; + } +} diff --git a/common/src/main/java/com/skyflow/common/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/common/logs/ErrorLogs.java new file mode 100644 index 00000000..b0ee077e --- /dev/null +++ b/common/src/main/java/com/skyflow/common/logs/ErrorLogs.java @@ -0,0 +1,140 @@ +package com.skyflow.common.logs; + +public enum ErrorLogs { + // Client initialization + VAULT_CONFIG_EXISTS("Vault config with vault ID %s1 already exists."), + VAULT_CONFIG_DOES_NOT_EXIST("Vault config with vault ID %s1 doesn't exist."), + VAULT_ID_IS_REQUIRED("Invalid vault config. Vault ID is required."), + EMPTY_VAULT_ID("Invalid vault config. Vault ID can not be empty."), + CLUSTER_ID_IS_REQUIRED("Invalid vault config. Cluster ID is required."), + EMPTY_CLUSTER_ID("Invalid vault config. Cluster ID can not be empty."), + CONNECTION_CONFIG_EXISTS("Connection config with connection ID %s1 already exists."), + CONNECTION_CONFIG_DOES_NOT_EXIST("Connection config with connection ID %s1 doesn't exist."), + CONNECTION_ID_IS_REQUIRED("Invalid connection config. Connection ID is required."), + EMPTY_CONNECTION_ID("Invalid connection config. Connection ID can not be empty."), + CONNECTION_URL_IS_REQUIRED("Invalid connection config. Connection URL is required."), + EMPTY_CONNECTION_URL("Invalid connection config. Connection URL can not be empty."), + INVALID_CONNECTION_URL("Invalid connection config. Connection URL is not a valid URL."), + MULTIPLE_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Only one of 'path', 'credentialsString', 'token' or 'apiKey' is allowed."), + NO_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Any one of 'path', 'credentialsString', 'token' or 'apiKey' is required."), + EMPTY_CREDENTIALS_PATH("Invalid credentials. Credentials path can not be empty."), + EMPTY_CREDENTIALS_STRING("Invalid credentials. Credentials string can not be empty."), + EMPTY_TOKEN_VALUE("Invalid credentials. Token can not be empty."), + EMPTY_API_KEY_VALUE("Invalid credentials. Api key can not be empty."), + INVALID_API_KEY("Invalid credentials. Api key is invalid."), + EMPTY_ROLES("Invalid credentials. Roles can not be empty."), + EMPTY_OR_NULL_ROLE_IN_ROLES("Invalid credentials. Role can not be null or empty in roles at index %s1."), + EMPTY_OR_NULL_CONTEXT("Invalid credentials. Context can not be empty."), + + // Bearer token generation + INVALID_BEARER_TOKEN("Bearer token is invalid or expired."), + INVALID_CREDENTIALS_FILE("Credentials file is either null or an invalid file."), + INVALID_CREDENTIALS_STRING("Credentials string is either null or empty."), + INVALID_CREDENTIALS_FILE_FORMAT("Credentials file is not in a valid JSON format."), + CREDENTIALS_FILE_NOT_FOUND("Credentials file not found at specified path."), + INVALID_CREDENTIALS_STRING_FORMAT("Credentials string is not in a valid JSON string format."), + PRIVATE_KEY_IS_REQUIRED("Private key is required."), + CLIENT_ID_IS_REQUIRED("Client ID is required."), + KEY_ID_IS_REQUIRED("Key ID is required."), + TOKEN_URI_IS_REQUIRED("Token URI is required."), + INVALID_TOKEN_URI("Invalid value for token URI in credentials."), + JWT_INVALID_FORMAT("Private key is not in a valid format."), + INVALID_ALGORITHM("Algorithm for parsing private key is invalid or does not exist."), + INVALID_KEY_SPEC("Unable to parse RSA private key."), + BEARER_TOKEN_REJECTED("Bearer token request resulted in failure."), + SIGNED_DATA_TOKENS_REJECTED("Signed data tokens request resulted in failure."), + + // Vault api interfaces + TABLE_IS_REQUIRED("Invalid %s1 request. Table is required."), + EMPTY_TABLE_NAME("Invalid %s1 request. Table name can not be empty."), + VALUES_IS_REQUIRED("Invalid %s1 request. Values are required."), + EMPTY_VALUES("Invalid %s1 request. Values can not be empty."), + EMPTY_OR_NULL_VALUE_IN_VALUES("Invalid %s1 request. Value can not be null or empty in values for key \"%s2\"."), + EMPTY_OR_NULL_KEY_IN_VALUES("Invalid %s1 request. Key can not be null or empty in values"), + EMPTY_UPSERT("Invalid %s1 request. Upsert can not be empty."), + HOMOGENOUS_NOT_SUPPORTED_WITH_UPSERT("Invalid %s1 request. Homogenous is not supported when upsert is passed."), + TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE("Invalid %s1 request. Tokens are not allowed when tokenMode is DISABLE."), + TOKENS_REQUIRED_WITH_TOKEN_MODE("Invalid %s1 request. Tokens are required when tokenMode is %s2."), + EMPTY_TOKENS("Invalid %s1 request. Tokens can not be empty."), + EMPTY_OR_NULL_VALUE_IN_TOKENS("Invalid %s1 request. Value can not be null or empty in tokens for key \"%s2\"."), + EMPTY_OR_NULL_KEY_IN_TOKENS("Invalid %s1 request. Key can not be null or empty in tokens."), + INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT("Invalid %s1 request. For tokenMode as ENABLE_STRICT, tokens should be passed for all fields."), + MISMATCH_OF_FIELDS_AND_TOKENS("Invalid %s1 request. Keys for values and tokens are not matching."), + INSERT_RECORDS_REJECTED("Insert request resulted in failure."), + DETOKENIZE_DATA_REQUIRED("Invalid %s1 request. Detokenize data is required."), + EMPTY_DETOKENIZE_DATA("Invalid %s1 request. Detokenize data can not be empty."), + EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA("Invalid %s1 request. Token can not be null or empty in detokenize data at index %s2."), + REDACTION_IS_REQUIRED("Invalid %s1 request. Redaction is required."), + DETOKENIZE_REQUEST_REJECTED("Detokenize request resulted in failure."), + IDS_IS_REQUIRED("Invalid %s1 request. Ids are required."), + EMPTY_IDS("Invalid %s1 request. Ids can not be empty."), + EMPTY_OR_NULL_ID_IN_IDS("Invalid %s1 request. Id can not be null or empty in ids at index %s2."), + EMPTY_FIELDS("Invalid %s1 request. Fields can not be empty."), + EMPTY_OR_NULL_FIELD_IN_FIELDS("Invalid %s1 request. Field can not be null or empty in fields at index %s2."), + TOKENIZATION_NOT_SUPPORTED_WITH_REDACTION("Invalid %s1 request. Return tokens is not supported when redaction is applied."), + TOKENIZATION_SUPPORTED_ONLY_WITH_IDS("Invalid %s1 request. Return tokens is not supported when column name and values are passed."), + EMPTY_OFFSET("Invalid %s1 request. Offset can not be empty."), + EMPTY_LIMIT("Invalid %s1 request. Limit can not be empty."), + NEITHER_IDS_NOR_COLUMN_NAME_PASSED("Invalid %s1 request. Neither ids nor column name and values are passed."), + BOTH_IDS_AND_COLUMN_NAME_PASSED("Invalid %s1 request. Both ids and column name and values are passed."), + COLUMN_NAME_IS_REQUIRED("Invalid %s1 request. Column name is required when column values are passed."), + EMPTY_COLUMN_NAME("Invalid %s1 request. Column name can not be empty."), + COLUMN_VALUES_IS_REQUIRED_GET("Invalid %s1 request. Column values are required when column name is passed."), + EMPTY_COLUMN_VALUES("Invalid %s1 request. Column values can not be empty."), + EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES("Invalid %s1 request. Column value can not by null or empty in column values at index %s2."), + GET_REQUEST_REJECTED("Get request resulted in failure."), + DATA_IS_REQUIRED("Invalid %s1 request. Data is required."), + EMPTY_DATA("Invalid %s1 request. Data can not be empty."), + SKYFLOW_ID_IS_REQUIRED("Invalid %s1 request. Skyflow Id is required."), + INVALID_SKYFLOW_ID_TYPE("Invalid %s1 request. Skyflow Id should of type String."), + EMPTY_SKYFLOW_ID("Invalid %s1 request. Skyflow Id can not be empty."), + UPDATE_REQUEST_REJECTED("Update request resulted in failure."), + QUERY_IS_REQUIRED("Invalid %s1 request. Query is required."), + EMPTY_QUERY("Invalid %s1 request. Query can not be empty."), + QUERY_REQUEST_REJECTED("Query request resulted in failure."), + COLUMN_VALUES_IS_REQUIRED_TOKENIZE("Invalid %s1 request. ColumnValues are required."), + EMPTY_OR_NULL_COLUMN_GROUP_IN_COLUMN_VALUES("Invalid %s1 request. Column group can not be null or empty in column values at index %s2."), + TOKENIZE_REQUEST_REJECTED("Tokenize request resulted in failure."), + DELETE_REQUEST_REJECTED("Delete request resulted in failure."), + + // invoke connection interface + INVOKE_CONNECTION_INVALID_CONNECTION_URL("Invalid %s1 request. Connection URL is not a valid URL."), + EMPTY_REQUEST_HEADERS("Invalid %s1 request. Request headers can not be empty."), + INVALID_REQUEST_HEADERS("Invalid %s1 request. Request header can not be null or empty in request headers."), + EMPTY_PATH_PARAMS("Invalid %s1 request. Path params can not be empty."), + INVALID_PATH_PARAM("Invalid %s1 request. Path parameter can not be null or empty in path params."), + EMPTY_QUERY_PARAMS("Invalid %s1 request. Query params can not be empty."), + INVALID_QUERY_PARAM("Invalid %s1 request. Query parameter can not be null or empty in query params."), + EMPTY_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), + INVALID_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), + INVOKE_CONNECTION_REQUEST_REJECTED("Invoke connection 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."), + DEIDENTIFY_TEXT_REQUEST_REJECTED("DeIdentify text request resulted in failure."), + INVALID_TEXT_IN_REIDENTIFY("Invalid %s1 request. The text field is required and must be a non-empty string. Specify a valid text."), + REIDENTIFY_TEXT_REQUEST_REJECTED("ReIdentify text request resulted in failure."), + DEIDENTIFY_FILE_REQUEST_REJECTED("DeIdentify file request resulted in failure."), + GET_DETECT_RUN_REQUEST_REJECTED("Get detect run request resulted in failure."), + INVALID_NULL_FILE_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file field is required and must not be null. Specify a valid file."), + FILE_NOT_FOUND_TO_DEIDENTIFY("Invalid %s1 request. The file field is required and must not be empty. Specify a valid file."), + FILE_NOT_READABLE_TO_DEIDENTIFY("Invalid %s1 request. The file is not readable. Please check the file permissions or path."), + INVALID_PIXEL_DENSITY_TO_DEIDENTIFY_FILE("Invalid %s1 request. Pixel density must be a positive integer greater than 0. Specify a valid pixel density."), + INVALID_MAX_RESOLUTION("Invalid %s1 request. Max resolution must be a positive integer greater than 0. Specify a valid max resolution."), + INVALID_BLEEP_TO_DEIDENTIFY_AUDIO("Invalid %s1 request. Specify a valid bleep as AudioBleep"), + OUTPUT_DIRECTORY_NOT_FOUND("Invalid %s1 request. The output directory does not exist. Please specify a valid output directory."), + INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY("Invalid %s1 request. The output directory is not writable. Please check the permissions or specify a valid output directory."), + EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file and file path fields are both empty. Specify a valid file object or file path."), + ; + + private final String log; + + ErrorLogs(String log) { + this.log = log; + } + + public final String getLog() { + return log; + } +} diff --git a/common/src/main/java/com/skyflow/common/logs/InfoLogs.java b/common/src/main/java/com/skyflow/common/logs/InfoLogs.java new file mode 100644 index 00000000..337db094 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/logs/InfoLogs.java @@ -0,0 +1,105 @@ +package com.skyflow.common.logs; + +public enum InfoLogs { + // Client initialization + CLIENT_INITIALIZED("Initialized skyflow client."), + VALIDATING_VAULT_CONFIG("Validating vault config."), + VALIDATING_CONNECTION_CONFIG("Validating connection config."), + UNABLE_TO_GENERATE_SDK_METRIC("Unable to generate %s1 metric."), + VAULT_CONTROLLER_INITIALIZED("Initialized vault controller with vault ID %s1."), + DETECT_CONTROLLER_INITIALIZED("Initialized detect controller with vault ID %s1."), + CONNECTION_CONTROLLER_INITIALIZED("Initialized connection controller with connection ID %s1."), + LOGGER_SETUP_DONE("Set up logger."), + CURRENT_LOG_LEVEL("Current log level is %s1."), + + // Bearer token generation + EMPTY_BEARER_TOKEN("Bearer token is empty."), + BEARER_TOKEN_EXPIRED("Bearer token is expired."), + GET_BEARER_TOKEN_TRIGGERED("getBearerToken method triggered."), + GET_BEARER_TOKEN_SUCCESS("Bearer token generated."), + GET_SIGNED_DATA_TOKENS_TRIGGERED("getSignedDataTokens method triggered."), + GET_SIGNED_DATA_TOKEN_SUCCESS("Signed data tokens generated."), + REUSE_BEARER_TOKEN("Reusing bearer token."), + REUSE_API_KEY("Reusing api key."), + GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED("generateBearerTokenFromCredentials method triggered."), + GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED("generateBearerTokenFromCredentialString method triggered."), + GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED("generateSignedTokensFromCredentialsFile method triggered."), + GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_STRING_TRIGGERED("generateSignedTokensFromCredentialsString method triggered."), + + // Insert interface + INSERT_TRIGGERED("Insert method triggered."), + VALIDATE_INSERT_REQUEST("Validating insert request."), + INSERT_REQUEST_RESOLVED("Insert request resolved."), + INSERT_SUCCESS("Data inserted."), + + // Detokenize interface + DETOKENIZE_TRIGGERED("Detokenize method triggered."), + VALIDATE_DETOKENIZE_REQUEST("Validating detokenize request."), + DETOKENIZE_REQUEST_RESOLVED("Detokenize request resolved."), + DETOKENIZE_PARTIAL_SUCCESS("Data detokenized partially."), + DETOKENIZE_SUCCESS("Data detokenized."), + + // Get interface + GET_TRIGGERED("Get method triggered."), + VALIDATE_GET_REQUEST("Validating get request."), + GET_REQUEST_RESOLVED("Get request resolved."), + GET_SUCCESS("Data revealed."), + + // Update interface + UPDATE_TRIGGERED("Update method triggered."), + VALIDATE_UPDATE_REQUEST("Validating update request."), + UPDATE_REQUEST_RESOLVED("Update request resolved."), + UPDATE_SUCCESS("Data updated."), + + // Delete interface + DELETE_TRIGGERED("Delete method triggered."), + VALIDATING_DELETE_REQUEST("Validating delete request."), + DELETE_REQUEST_RESOLVED("Delete request resolved."), + DELETE_SUCCESS("Data deleted."), + + // Query interface + QUERY_TRIGGERED("Query method triggered."), + VALIDATING_QUERY_REQUEST("Validating query request."), + QUERY_REQUEST_RESOLVED("Query request resolved."), + QUERY_SUCCESS("Query executed."), + + // Tokenize interface + TOKENIZE_TRIGGERED("Tokenize method triggered."), + VALIDATING_TOKENIZE_REQUEST("Validating tokenize request."), + TOKENIZE_REQUEST_RESOLVED("Tokenize request resolved."), + TOKENIZE_SUCCESS("Data tokenized."), + + + // Invoke connection interface + INVOKE_CONNECTION_TRIGGERED("Invoke connection method triggered."), + VALIDATING_INVOKE_CONNECTION_REQUEST("Validating invoke connection request."), + INVOKE_CONNECTION_REQUEST_RESOLVED("Invoke connection request resolved."), + + // detect + VALIDATE_DEIDENTIFY_TEXT_REQUEST("Validating deidentify text request."), + DEIDENTIFY_TEXT_SUCCESS("Text data de-identified."), + DEIDENTIFY_TEXT_TRIGGERED("DeIdentify text method triggered."), + DEIDENTIFY_TEXT_REQUEST_RESOLVED("DeIdentify text request resolved."), + VALIDATE_REIDENTIFY_TEXT_REQUEST("Validating reidentify text request."), + REIDENTIFY_TEXT_TRIGGERED("ReIdentify text method triggered."), + REIDENTIFY_TEXT_REQUEST_RESOLVED("ReIdentify text request resolved."), + DEIDENTIFY_FILE_TRIGGERED("DeIdentify file method triggered."), + VALIDATE_DEIDENTIFY_FILE_REQUEST("Validating deidentify file request."), + DEIDENTIFY_FILE_REQUEST_RESOLVED("DeIdentify file request resolved."), + DEIDENTIFY_FILE_SUCCESS("File deidentified successfully."), + GET_DETECT_RUN_TRIGGERED("Get detect run method triggered."), + VALIDATE_GET_DETECT_RUN_REQUEST("Validating get detect run request."), + REIDENTIFY_TEXT_SUCCESS("Text data re-identified."), + ; + + + private final String log; + + InfoLogs(String log) { + this.log = log; + } + + public final String getLog() { + return log; + } +} diff --git a/common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java new file mode 100644 index 00000000..250d0659 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.resources.authentication; + +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.RequestOptions; +import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.common.types.V1GetAuthTokenResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncAuthenticationClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAuthenticationClient rawClient; + + public AsyncAuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAuthenticationClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAuthenticationClient withRawResponse() { + return this.rawClient; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture authenticationServiceGetAuthToken(V1GetAuthTokenRequest request) { + return this.rawClient.authenticationServiceGetAuthToken(request).thenApply(response -> response.body()); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + return this.rawClient + .authenticationServiceGetAuthToken(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java new file mode 100644 index 00000000..ece2bb6a --- /dev/null +++ b/common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.resources.authentication; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.skyflow.common.core.ApiClientApiException; +import com.skyflow.common.core.ApiClientException; +import com.skyflow.common.core.ApiClientHttpResponse; +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.MediaTypes; +import com.skyflow.common.core.ObjectMappers; +import com.skyflow.common.core.RequestOptions; +import com.skyflow.common.errors.BadRequestError; +import com.skyflow.common.errors.NotFoundError; +import com.skyflow.common.errors.UnauthorizedError; +import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.common.types.V1GetAuthTokenResponse; +import java.io.IOException; +import java.util.Map; +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 AsyncRawAuthenticationClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture> authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request) { + return authenticationServiceGetAuthToken(request, null); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture> authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sa/oauth/token") + .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(), V1GetAuthTokenResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + 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/common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java new file mode 100644 index 00000000..b806d785 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.resources.authentication; + +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.RequestOptions; +import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.common.types.V1GetAuthTokenResponse; + +public class AuthenticationClient { + protected final ClientOptions clientOptions; + + private final RawAuthenticationClient rawClient; + + public AuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAuthenticationClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuthenticationClient withRawResponse() { + return this.rawClient; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public V1GetAuthTokenResponse authenticationServiceGetAuthToken(V1GetAuthTokenRequest request) { + return this.rawClient.authenticationServiceGetAuthToken(request).body(); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public V1GetAuthTokenResponse authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + return this.rawClient + .authenticationServiceGetAuthToken(request, requestOptions) + .body(); + } +} diff --git a/common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java new file mode 100644 index 00000000..f6b7ab2d --- /dev/null +++ b/common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.resources.authentication; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.skyflow.common.core.ApiClientApiException; +import com.skyflow.common.core.ApiClientException; +import com.skyflow.common.core.ApiClientHttpResponse; +import com.skyflow.common.core.ClientOptions; +import com.skyflow.common.core.MediaTypes; +import com.skyflow.common.core.ObjectMappers; +import com.skyflow.common.core.RequestOptions; +import com.skyflow.common.errors.BadRequestError; +import com.skyflow.common.errors.NotFoundError; +import com.skyflow.common.errors.UnauthorizedError; +import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.common.types.V1GetAuthTokenResponse; +import java.io.IOException; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuthenticationClient { + protected final ClientOptions clientOptions; + + public RawAuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public ApiClientHttpResponse authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request) { + return authenticationServiceGetAuthToken(request, null); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public ApiClientHttpResponse authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sa/oauth/token") + .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(), V1GetAuthTokenResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + 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/common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java b/common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java new file mode 100644 index 00000000..ca0f086f --- /dev/null +++ b/common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java @@ -0,0 +1,335 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.resources.authentication.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.common.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 = V1GetAuthTokenRequest.Builder.class) +public final class V1GetAuthTokenRequest { + private final String grantType; + + private final String assertion; + + private final Optional subjectToken; + + private final Optional subjectTokenType; + + private final Optional requestedTokenUse; + + private final Optional scope; + + private final Map additionalProperties; + + private V1GetAuthTokenRequest( + String grantType, + String assertion, + Optional subjectToken, + Optional subjectTokenType, + Optional requestedTokenUse, + Optional scope, + Map additionalProperties) { + this.grantType = grantType; + this.assertion = assertion; + this.subjectToken = subjectToken; + this.subjectTokenType = subjectTokenType; + this.requestedTokenUse = requestedTokenUse; + this.scope = scope; + this.additionalProperties = additionalProperties; + } + + /** + * @return Grant type of the request. Set this to urn:ietf:params:oauth:grant-type:jwt-bearer. + */ + @JsonProperty("grant_type") + public String getGrantType() { + return grantType; + } + + /** + * @return User-signed JWT token that contains the following fields: <br/> <ul><li><code>iss</code>: Issuer of the JWT.</li><li><code>key</code>: Unique identifier for the key.</li><li><code>aud</code>: Recipient the JWT is intended for.</li><li><code>exp</code>: Time the JWT expires.</li><li><code>sub</code>: Subject of the JWT.</li><li><code>ctx</code>: (Optional) Value for <a href='/context-aware-overview/'>Context-aware authorization</a>.</li></ul> + */ + @JsonProperty("assertion") + public String getAssertion() { + return assertion; + } + + /** + * @return Subject token. + */ + @JsonProperty("subject_token") + public Optional getSubjectToken() { + return subjectToken; + } + + /** + * @return Subject token type. + */ + @JsonProperty("subject_token_type") + public Optional getSubjectTokenType() { + return subjectTokenType; + } + + /** + * @return Token use type. Either delegation or impersonation. + */ + @JsonProperty("requested_token_use") + public Optional getRequestedTokenUse() { + return requestedTokenUse; + } + + /** + * @return Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>". + */ + @JsonProperty("scope") + public Optional getScope() { + return scope; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1GetAuthTokenRequest && equalTo((V1GetAuthTokenRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1GetAuthTokenRequest other) { + return grantType.equals(other.grantType) + && assertion.equals(other.assertion) + && subjectToken.equals(other.subjectToken) + && subjectTokenType.equals(other.subjectTokenType) + && requestedTokenUse.equals(other.requestedTokenUse) + && scope.equals(other.scope); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.grantType, + this.assertion, + this.subjectToken, + this.subjectTokenType, + this.requestedTokenUse, + this.scope); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static GrantTypeStage builder() { + return new Builder(); + } + + public interface GrantTypeStage { + /** + * Grant type of the request. Set this to `urn:ietf:params:oauth:grant-type:jwt-bearer`. + */ + AssertionStage grantType(@NotNull String grantType); + + Builder from(V1GetAuthTokenRequest other); + } + + public interface AssertionStage { + /** + * User-signed JWT token that contains the following fields:
  • iss: Issuer of the JWT.
  • key: Unique identifier for the key.
  • aud: Recipient the JWT is intended for.
  • exp: Time the JWT expires.
  • sub: Subject of the JWT.
  • ctx: (Optional) Value for Context-aware authorization.
+ */ + _FinalStage assertion(@NotNull String assertion); + } + + public interface _FinalStage { + V1GetAuthTokenRequest build(); + + /** + *

Subject token.

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

Subject token type.

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

Token use type. Either delegation or impersonation.

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

+ */ + _FinalStage scope(Optional scope); + + _FinalStage scope(String scope); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements GrantTypeStage, AssertionStage, _FinalStage { + private String grantType; + + private String assertion; + + private Optional scope = Optional.empty(); + + private Optional requestedTokenUse = Optional.empty(); + + private Optional subjectTokenType = Optional.empty(); + + private Optional subjectToken = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(V1GetAuthTokenRequest other) { + grantType(other.getGrantType()); + assertion(other.getAssertion()); + subjectToken(other.getSubjectToken()); + subjectTokenType(other.getSubjectTokenType()); + requestedTokenUse(other.getRequestedTokenUse()); + scope(other.getScope()); + return this; + } + + /** + * Grant type of the request. Set this to `urn:ietf:params:oauth:grant-type:jwt-bearer`.

Grant type of the request. Set this to urn:ietf:params:oauth:grant-type:jwt-bearer.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("grant_type") + public AssertionStage grantType(@NotNull String grantType) { + this.grantType = Objects.requireNonNull(grantType, "grantType must not be null"); + return this; + } + + /** + * User-signed JWT token that contains the following fields:
  • iss: Issuer of the JWT.
  • key: Unique identifier for the key.
  • aud: Recipient the JWT is intended for.
  • exp: Time the JWT expires.
  • sub: Subject of the JWT.
  • ctx: (Optional) Value for Context-aware authorization.

User-signed JWT token that contains the following fields: <br/> <ul><li><code>iss</code>: Issuer of the JWT.</li><li><code>key</code>: Unique identifier for the key.</li><li><code>aud</code>: Recipient the JWT is intended for.</li><li><code>exp</code>: Time the JWT expires.</li><li><code>sub</code>: Subject of the JWT.</li><li><code>ctx</code>: (Optional) Value for <a href='/context-aware-overview/'>Context-aware authorization</a>.</li></ul>

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Token use type. Either delegation or impersonation.

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

Token use type. Either delegation or impersonation.

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

Subject token type.

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

Subject token type.

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

Subject token.

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

Subject token.

+ */ + @java.lang.Override + @JsonSetter(value = "subject_token", nulls = Nulls.SKIP) + public _FinalStage subjectToken(Optional subjectToken) { + this.subjectToken = subjectToken; + return this; + } + + @java.lang.Override + public V1GetAuthTokenRequest build() { + return new V1GetAuthTokenRequest( + grantType, + assertion, + subjectToken, + subjectTokenType, + requestedTokenUse, + scope, + additionalProperties); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java new file mode 100644 index 00000000..b7a00648 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java @@ -0,0 +1,229 @@ +package com.skyflow.common.serviceaccount.util; + +import com.google.gson.*; +import com.skyflow.common.ApiClient; +import com.skyflow.common.ApiClientBuilder; +import com.skyflow.common.core.ApiClientApiException; +import com.skyflow.common.resources.authentication.AuthenticationClient; +import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.common.types.V1GetAuthTokenResponse; +import com.skyflow.common.errors.ErrorCode; +import com.skyflow.common.errors.ErrorMessage; +import com.skyflow.common.errors.SkyflowException; +import com.skyflow.common.logs.ErrorLogs; +import com.skyflow.common.logs.InfoLogs; +import com.skyflow.common.utils.Constants; +import com.skyflow.common.utils.Utils; +import com.skyflow.common.utils.logger.LogUtil; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.net.MalformedURLException; +import java.security.PrivateKey; +import java.util.ArrayList; +import java.util.Date; +import java.util.Objects; + +public class BearerToken { + private static final Gson gson = new GsonBuilder().serializeNulls().create(); + private static final ApiClientBuilder apiClientBuilder = new ApiClientBuilder(); + private final File credentialsFile; + private final String credentialsString; + private final String ctx; + private final ArrayList roles; + private final String credentialsType; + + private BearerToken(BearerTokenBuilder builder) { + this.credentialsFile = builder.credentialsFile; + this.credentialsString = builder.credentialsString; + this.ctx = builder.ctx; + this.roles = builder.roles; + this.credentialsType = builder.credentialsType; + } + + public static BearerTokenBuilder builder() { + return new BearerTokenBuilder(); + } + + private static V1GetAuthTokenResponse generateBearerTokenFromCredentials( + File credentialsFile, String context, ArrayList roles + ) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED.getLog()); + try { + if (credentialsFile == null) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); + } + FileReader reader = new FileReader(String.valueOf(credentialsFile)); + JsonObject serviceAccountCredentials = JsonParser.parseReader(reader).getAsJsonObject(); + return getBearerTokenFromCredentials(serviceAccountCredentials, context, roles); + } catch (JsonSyntaxException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath())); + } catch (FileNotFoundException e) { + LogUtil.printErrorLog(ErrorLogs.CREDENTIALS_FILE_NOT_FOUND.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + ErrorMessage.FileNotFound.getMessage(), credentialsFile.getPath())); + } + } + + private static V1GetAuthTokenResponse generateBearerTokenFromCredentialString( + String credentials, String context, ArrayList roles + ) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED.getLog()); + try { + if (credentials == null || credentials.isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); + } + JsonObject serviceAccountCredentials = JsonParser.parseString(credentials).getAsJsonObject(); + return getBearerTokenFromCredentials(serviceAccountCredentials, context, roles); + } catch (JsonSyntaxException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING_FORMAT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.CredentialsStringInvalidJson.getMessage()); + } + } + + private static V1GetAuthTokenResponse getBearerTokenFromCredentials( + JsonObject credentials, String context, ArrayList roles + ) throws SkyflowException { + try { + JsonElement privateKey = credentials.get("privateKey"); + if (privateKey == null) { + LogUtil.printErrorLog(ErrorLogs.PRIVATE_KEY_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingPrivateKey.getMessage()); + } + + JsonElement clientID = credentials.get("clientID"); + if (clientID == null) { + LogUtil.printErrorLog(ErrorLogs.CLIENT_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingClientId.getMessage()); + } + + JsonElement keyID = credentials.get("keyID"); + if (keyID == null) { + LogUtil.printErrorLog(ErrorLogs.KEY_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingKeyId.getMessage()); + } + + JsonElement tokenURI = credentials.get("tokenURI"); + if (tokenURI == null) { + LogUtil.printErrorLog(ErrorLogs.TOKEN_URI_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingTokenUri.getMessage()); + } + + PrivateKey pvtKey = Utils.getPrivateKeyFromPem(privateKey.getAsString()); + String signedUserJWT = getSignedToken( + clientID.getAsString(), keyID.getAsString(), tokenURI.getAsString(), pvtKey, context + ); + + String basePath = Utils.getBaseURL(tokenURI.getAsString()); + apiClientBuilder.url(basePath); + ApiClient apiClient = apiClientBuilder.token("token").build(); + AuthenticationClient authenticationApi = apiClient.authentication(); + + V1GetAuthTokenRequest._FinalStage authTokenBuilder = V1GetAuthTokenRequest.builder().grantType(Constants.GRANT_TYPE).assertion(signedUserJWT); + + if (roles != null) { + String scopedRoles = getScopeUsingRoles(roles); + authTokenBuilder.scope(scopedRoles); + } + return authenticationApi.authenticationServiceGetAuthToken(authTokenBuilder.build()); + } catch (MalformedURLException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_TOKEN_URI.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTokenUri.getMessage()); + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.BEARER_TOKEN_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + } + + private static String getSignedToken( + String clientID, String keyID, String tokenURI, PrivateKey pvtKey, String context + ) { + final Date createdDate = new Date(); + final Date expirationDate = new Date(createdDate.getTime() + (3600 * 1000)); + return Jwts.builder() + .claim("iss", clientID) + .claim("key", keyID) + .claim("aud", tokenURI) + .claim("sub", clientID) + .claim("ctx", context) + .setExpiration(expirationDate) + .signWith(SignatureAlgorithm.RS256, pvtKey) + .compact(); + } + + private static String getScopeUsingRoles(ArrayList roles) { + StringBuilder scope = new StringBuilder(); + if (roles != null) { + for (String role : roles) { + scope.append(" role:").append(role); + } + } + return scope.toString(); + } + + public synchronized String getBearerToken() throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GET_BEARER_TOKEN_TRIGGERED.getLog()); + V1GetAuthTokenResponse response; + String accessToken = null; + if (this.credentialsFile != null && Objects.equals(this.credentialsType, "FILE")) { + response = generateBearerTokenFromCredentials(this.credentialsFile, this.ctx, this.roles); + accessToken = response.getAccessToken().get(); + } else if (this.credentialsString != null && Objects.equals(this.credentialsType, "STRING")) { + response = generateBearerTokenFromCredentialString(this.credentialsString, this.ctx, this.roles); + accessToken = response.getAccessToken().get(); + } + LogUtil.printInfoLog(InfoLogs.GET_BEARER_TOKEN_SUCCESS.getLog()); + return accessToken; + } + + // Builder class + public static class BearerTokenBuilder { + private File credentialsFile; + private String credentialsString; + private String ctx; + private ArrayList roles; + private String credentialsType; + + private BearerTokenBuilder() { + } + + private void setCredentialsType(String credentialsType) { + this.credentialsType = credentialsType; + } + + public BearerTokenBuilder setCredentials(File credentialsFile) { + setCredentialsType("FILE"); + this.credentialsFile = credentialsFile; + return this; + } + + public BearerTokenBuilder setCredentials(String credentialsString) { + setCredentialsType("STRING"); + this.credentialsString = credentialsString; + return this; + } + + public BearerTokenBuilder setCtx(String ctx) { + this.ctx = ctx; + return this; + } + + public BearerTokenBuilder setRoles(ArrayList roles) { + this.roles = roles; + return this; + } + + public BearerToken build() { + return new BearerToken(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java new file mode 100644 index 00000000..dfdd40bd --- /dev/null +++ b/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java @@ -0,0 +1,29 @@ +package com.skyflow.common.serviceaccount.util; + +import com.google.gson.Gson; +import com.skyflow.common.utils.Constants; + +public class SignedDataTokenResponse { + private static final String prefix = Constants.SIGNED_DATA_TOKEN_PREFIX; + private final String token; + private final String signedToken; + + public SignedDataTokenResponse(String token, String signedToken) { + this.token = token; + this.signedToken = new StringBuilder(prefix).append(signedToken).toString(); + } + + public String getToken() { + return token; + } + + public String getSignedToken() { + return signedToken; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java new file mode 100644 index 00000000..5d7f1e18 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java @@ -0,0 +1,213 @@ +package com.skyflow.common.serviceaccount.util; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import com.skyflow.common.errors.ErrorCode; +import com.skyflow.common.errors.ErrorMessage; +import com.skyflow.common.errors.SkyflowException; +import com.skyflow.common.logs.ErrorLogs; +import com.skyflow.common.logs.InfoLogs; +import com.skyflow.common.utils.Utils; +import com.skyflow.common.utils.logger.LogUtil; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.security.PrivateKey; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +public class SignedDataTokens { + private final File credentialsFile; + private final String credentialsString; + private final String credentialsType; + private final String ctx; + private final ArrayList dataTokens; + private final Integer timeToLive; + + private SignedDataTokens(SignedDataTokensBuilder builder) { + this.credentialsFile = builder.credentialsFile; + this.credentialsString = builder.credentialsString; + this.credentialsType = builder.credentialsType; + this.ctx = builder.ctx; + this.dataTokens = builder.dataTokens; + this.timeToLive = builder.timeToLive; + } + + public static SignedDataTokensBuilder builder() { + return new SignedDataTokensBuilder(); + } + + private static List generateSignedTokenFromCredentialsFile( + File credentialsFile, ArrayList dataTokens, Integer timeToLive, String context + ) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED.getLog()); + List responseToken; + try { + if (credentialsFile == null) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); + } + FileReader reader = new FileReader(String.valueOf(credentialsFile)); + JsonObject serviceAccountCredentials = JsonParser.parseReader(reader).getAsJsonObject(); + responseToken = generateSignedTokensFromCredentials(serviceAccountCredentials, dataTokens, timeToLive, context); + } catch (JsonSyntaxException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath())); + } catch (FileNotFoundException e) { + LogUtil.printErrorLog(ErrorLogs.CREDENTIALS_FILE_NOT_FOUND.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + ErrorMessage.FileNotFound.getMessage(), credentialsFile.getPath())); + } + return responseToken; + } + + private static List generateSignedTokensFromCredentialsString( + String credentials, ArrayList dataTokens, Integer timeToLive, String context + ) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_STRING_TRIGGERED.getLog()); + List responseToken; + try { + if (credentials == null || credentials.isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); + } + JsonObject serviceAccountCredentials = JsonParser.parseString(credentials).getAsJsonObject(); + responseToken = generateSignedTokensFromCredentials(serviceAccountCredentials, dataTokens, timeToLive, context); + } catch (JsonSyntaxException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING_FORMAT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.CredentialsStringInvalidJson.getMessage()); + } + return responseToken; + } + + private static List generateSignedTokensFromCredentials( + JsonObject credentials, ArrayList dataTokens, Integer timeToLive, String context + ) throws SkyflowException { + List signedDataTokens = null; + try { + JsonElement privateKey = credentials.get("privateKey"); + if (privateKey == null) { + LogUtil.printErrorLog(ErrorLogs.PRIVATE_KEY_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingPrivateKey.getMessage()); + } + + JsonElement clientID = credentials.get("clientID"); + if (clientID == null) { + LogUtil.printErrorLog(ErrorLogs.CLIENT_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingClientId.getMessage()); + } + + JsonElement keyID = credentials.get("keyID"); + if (keyID == null) { + LogUtil.printErrorLog(ErrorLogs.KEY_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingKeyId.getMessage()); + } + PrivateKey pvtKey = Utils.getPrivateKeyFromPem(privateKey.getAsString()); + signedDataTokens = getSignedToken( + clientID.getAsString(), keyID.getAsString(), pvtKey, dataTokens, timeToLive, context); + } catch (RuntimeException e) { + LogUtil.printErrorLog(ErrorLogs.SIGNED_DATA_TOKENS_REJECTED.getLog()); + throw new SkyflowException(e); + } + return signedDataTokens; + } + + private static List getSignedToken( + String clientID, String keyID, PrivateKey pvtKey, + ArrayList dataTokens, Integer timeToLive, String context + ) { + final Date createdDate = new Date(); + final Date expirationDate; + + if (timeToLive != null) { + expirationDate = new Date(createdDate.getTime() + (timeToLive * 1000)); + } else { + expirationDate = new Date(createdDate.getTime() + 60000); // Valid for 60 seconds + } + + List list = new ArrayList<>(); + for (String dataToken : dataTokens) { + String eachSignedDataToken = Jwts.builder() + .claim("iss", "sdk") + .claim("iat", (createdDate.getTime() / 1000)) + .claim("key", keyID) + .claim("sub", clientID) + .claim("ctx", context) + .claim("tok", dataToken) + .setExpiration(expirationDate) + .signWith(SignatureAlgorithm.RS256, pvtKey) + .compact(); + SignedDataTokenResponse responseObject = new SignedDataTokenResponse(dataToken, eachSignedDataToken); + list.add(responseObject); + } + return list; + } + + public synchronized List getSignedDataTokens() throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GET_SIGNED_DATA_TOKENS_TRIGGERED.getLog()); + List signedToken = new ArrayList<>(); + if (this.credentialsFile != null && Objects.equals(this.credentialsType, "FILE")) { + signedToken = generateSignedTokenFromCredentialsFile(this.credentialsFile, this.dataTokens, this.timeToLive, this.ctx); + } else if (this.credentialsString != null && Objects.equals(this.credentialsType, "STRING")) { + signedToken = generateSignedTokensFromCredentialsString(this.credentialsString, this.dataTokens, this.timeToLive, this.ctx); + } + LogUtil.printInfoLog(InfoLogs.GET_SIGNED_DATA_TOKEN_SUCCESS.getLog()); + return signedToken; + } + + public static class SignedDataTokensBuilder { + private ArrayList dataTokens; + private Integer timeToLive; + private File credentialsFile; + private String credentialsString; + private String ctx; + private String credentialsType; + + private SignedDataTokensBuilder() { + } + + private void setCredentialsType(String credentialsType) { + this.credentialsType = credentialsType; + } + + public SignedDataTokensBuilder setCredentials(File credentialsFile) { + setCredentialsType("FILE"); + this.credentialsFile = credentialsFile; + return this; + } + + public SignedDataTokensBuilder setCredentials(String credentialsString) { + setCredentialsType("STRING"); + this.credentialsString = credentialsString; + return this; + } + + public SignedDataTokensBuilder setCtx(String ctx) { + this.ctx = ctx; + return this; + } + + public SignedDataTokensBuilder setDataTokens(ArrayList dataTokens) { + this.dataTokens = dataTokens; + return this; + } + + public SignedDataTokensBuilder setTimeToLive(Integer timeToLive) { + this.timeToLive = timeToLive; + return this; + } + + public SignedDataTokens build() { + return new SignedDataTokens(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java new file mode 100644 index 00000000..c72e3809 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java @@ -0,0 +1,46 @@ +package com.skyflow.common.serviceaccount.util; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import com.skyflow.common.errors.ErrorCode; +import com.skyflow.common.errors.ErrorMessage; +import com.skyflow.common.errors.SkyflowException; +import com.skyflow.common.logs.ErrorLogs; +import com.skyflow.common.logs.InfoLogs; +import com.skyflow.common.utils.logger.LogUtil; +import org.apache.commons.codec.binary.Base64; + +import java.nio.charset.StandardCharsets; +import java.util.Date; + +public class Token { + public static boolean isExpired(String token) { + long expiryTime; + long currentTime; + try { + if (token == null || token.trim().isEmpty()) { + LogUtil.printInfoLog(InfoLogs.EMPTY_BEARER_TOKEN.getLog()); + return true; + } + + currentTime = new Date().getTime() / 1000; + expiryTime = decoded(token).get("exp").getAsLong(); + + } catch (JsonSyntaxException | SkyflowException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); + return true; + } + return currentTime > expiryTime; + } + + static JsonObject decoded(String encodedToken) throws JsonSyntaxException, SkyflowException { + String[] split = encodedToken.split("\\."); + if (split.length < 3) { + LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.JwtDecodeError.getMessage()); + } + byte[] decodedBytes = Base64.decodeBase64(split[1]); + return JsonParser.parseString(new String(decodedBytes, StandardCharsets.UTF_8)).getAsJsonObject(); + } +} diff --git a/common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java b/common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java new file mode 100644 index 00000000..13687f8a --- /dev/null +++ b/common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.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.common.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 = GooglerpcStatus.Builder.class) +public final class GooglerpcStatus { + private final Optional code; + + private final Optional message; + + private final Optional> details; + + private final Map additionalProperties; + + private GooglerpcStatus( + Optional code, + Optional message, + Optional> details, + Map additionalProperties) { + this.code = code; + this.message = message; + this.details = details; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("code") + public Optional getCode() { + return code; + } + + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @JsonProperty("details") + public Optional> getDetails() { + return details; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GooglerpcStatus && equalTo((GooglerpcStatus) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GooglerpcStatus other) { + return code.equals(other.code) && message.equals(other.message) && details.equals(other.details); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.code, this.message, this.details); + } + + @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 code = Optional.empty(); + + private Optional message = Optional.empty(); + + private Optional> details = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GooglerpcStatus other) { + code(other.getCode()); + message(other.getMessage()); + details(other.getDetails()); + return this; + } + + @JsonSetter(value = "code", nulls = Nulls.SKIP) + public Builder code(Optional code) { + this.code = code; + return this; + } + + public Builder code(Integer code) { + this.code = Optional.ofNullable(code); + return this; + } + + @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; + } + + @JsonSetter(value = "details", nulls = Nulls.SKIP) + public Builder details(Optional> details) { + this.details = details; + return this; + } + + public Builder details(List details) { + this.details = Optional.ofNullable(details); + return this; + } + + public GooglerpcStatus build() { + return new GooglerpcStatus(code, message, details, additionalProperties); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/types/ProtobufAny.java b/common/src/main/java/com/skyflow/common/types/ProtobufAny.java new file mode 100644 index 00000000..fec45abf --- /dev/null +++ b/common/src/main/java/com/skyflow/common/types/ProtobufAny.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.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.common.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 = ProtobufAny.Builder.class) +public final class ProtobufAny { + private final Optional type; + + private final Map additionalProperties; + + private ProtobufAny(Optional type, Map additionalProperties) { + this.type = type; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("@type") + public Optional getType() { + return type; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProtobufAny && equalTo((ProtobufAny) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProtobufAny other) { + return type.equals(other.type); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type); + } + + @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 type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ProtobufAny other) { + type(other.getType()); + return this; + } + + @JsonSetter(value = "@type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public ProtobufAny build() { + return new ProtobufAny(type, additionalProperties); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java b/common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java new file mode 100644 index 00000000..4ee50804 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.common.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.common.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 = V1GetAuthTokenResponse.Builder.class) +public final class V1GetAuthTokenResponse { + private final Optional accessToken; + + private final Optional tokenType; + + private final Map additionalProperties; + + private V1GetAuthTokenResponse( + Optional accessToken, Optional tokenType, Map additionalProperties) { + this.accessToken = accessToken; + this.tokenType = tokenType; + this.additionalProperties = additionalProperties; + } + + /** + * @return AccessToken. + */ + @JsonProperty("accessToken") + public Optional getAccessToken() { + return accessToken; + } + + /** + * @return TokenType : Bearer. + */ + @JsonProperty("tokenType") + public Optional getTokenType() { + return tokenType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1GetAuthTokenResponse && equalTo((V1GetAuthTokenResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1GetAuthTokenResponse other) { + return accessToken.equals(other.accessToken) && tokenType.equals(other.tokenType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.accessToken, this.tokenType); + } + + @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 accessToken = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1GetAuthTokenResponse other) { + accessToken(other.getAccessToken()); + tokenType(other.getTokenType()); + return this; + } + + /** + *

AccessToken.

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

TokenType : Bearer.

+ */ + @JsonSetter(value = "tokenType", nulls = Nulls.SKIP) + public Builder tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + public Builder tokenType(String tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + public V1GetAuthTokenResponse build() { + return new V1GetAuthTokenResponse(accessToken, tokenType, additionalProperties); + } + } +} diff --git a/common/src/main/java/com/skyflow/common/utils/Constants.java b/common/src/main/java/com/skyflow/common/utils/Constants.java new file mode 100644 index 00000000..0a778dde --- /dev/null +++ b/common/src/main/java/com/skyflow/common/utils/Constants.java @@ -0,0 +1,31 @@ +package com.skyflow.common.utils; + +public final class Constants { + public static final String SECURE_PROTOCOL = "https://"; + public static final String DEV_DOMAIN = ".vault.skyflowapis.dev"; + public static final String STAGE_DOMAIN = ".vault.skyflowapis.tech"; + public static final String SANDBOX_DOMAIN = ".vault.skyflowapis-preview.com"; + public static final String PROD_DOMAIN = ".vault.skyflowapis.com"; + public static final String PKCS8_PRIVATE_HEADER = "-----BEGIN PRIVATE KEY-----"; + public static final String PKCS8_PRIVATE_FOOTER = "-----END PRIVATE KEY-----"; + public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; + public static final String SIGNED_DATA_TOKEN_PREFIX = "signed_token_"; + public static final String ORDER_ASCENDING = "ASCENDING"; + public static final String API_KEY_REGEX = "^sky-[a-zA-Z0-9]{5}-[a-fA-F0-9]{32}$"; + public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; + public static final String SDK_NAME = "Skyflow Java SDK "; + public static final String SDK_VERSION = "v2"; + public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; + public static final String SDK_METRIC_NAME_VERSION = "sdk_name_version"; + public static final String SDK_METRIC_NAME_VERSION_PREFIX = "skyflow-java@"; + public static final String SDK_METRIC_CLIENT_DEVICE_MODEL = "sdk_client_device_model"; + public static final String SDK_METRIC_CLIENT_OS_DETAILS = "sdk_client_os_details"; + public static final String SDK_METRIC_RUNTIME_DETAILS = "sdk_runtime_details"; + public static final String SDK_METRIC_RUNTIME_DETAILS_PREFIX = "Java@"; + public static final String SDK_AUTH_HEADER_KEY = "x-skyflow-authorization"; + 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"; +} diff --git a/common/src/main/java/com/skyflow/common/utils/Utils.java b/common/src/main/java/com/skyflow/common/utils/Utils.java new file mode 100644 index 00000000..d499775b --- /dev/null +++ b/common/src/main/java/com/skyflow/common/utils/Utils.java @@ -0,0 +1,69 @@ +package com.skyflow.common.utils; + +import com.skyflow.common.errors.ErrorCode; +import com.skyflow.common.errors.ErrorMessage; +import com.skyflow.common.errors.SkyflowException; +import com.skyflow.common.logs.ErrorLogs; +import com.skyflow.common.utils.logger.LogUtil; +import org.apache.commons.codec.binary.Base64; + +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; + +public final class Utils { + public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException { + String PKCS8PrivateHeader = Constants.PKCS8_PRIVATE_HEADER; + String PKCS8PrivateFooter = Constants.PKCS8_PRIVATE_FOOTER; + + String privateKeyContent = pemKey; + PrivateKey privateKey = null; + + if (pemKey.contains(PKCS8PrivateHeader)) { + privateKeyContent = privateKeyContent.replace(PKCS8PrivateHeader, ""); + privateKeyContent = privateKeyContent.replace(PKCS8PrivateFooter, ""); + privateKeyContent = privateKeyContent.replace("\n", ""); + privateKeyContent = privateKeyContent.replace("\r\n", ""); + privateKey = parsePkcs8PrivateKey(Base64.decodeBase64(privateKeyContent)); + } else { + LogUtil.printErrorLog(ErrorLogs.JWT_INVALID_FORMAT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.JwtInvalidFormat.getMessage()); + } + return privateKey; + } + + public static String getBaseURL(String url) throws MalformedURLException { + URL parsedUrl = new URL(url); + String protocol = parsedUrl.getProtocol(); + String host = parsedUrl.getHost(); + return String.format("%s://%s", protocol, host); + } + + public static String parameterizedString(String base, String... args) { + for (int index = 0; index < args.length; index++) { + base = base.replace("%s" + (index + 1), args[index]); + } + return base; + } + + private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws SkyflowException { + KeyFactory keyFactory; + PrivateKey privateKey = null; + try { + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8Bytes); + keyFactory = KeyFactory.getInstance("RSA"); + privateKey = keyFactory.generatePrivate(keySpec); + } catch (NoSuchAlgorithmException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_ALGORITHM.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidAlgorithm.getMessage()); + } catch (InvalidKeySpecException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_KEY_SPEC.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidKeySpec.getMessage()); + } + return privateKey; + } +} diff --git a/common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java b/common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java new file mode 100644 index 00000000..5e2eb136 --- /dev/null +++ b/common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java @@ -0,0 +1,100 @@ +package com.skyflow.common.utils.logger; + +import com.skyflow.common.logs.InfoLogs; +import com.skyflow.common.utils.Constants; +import com.skyflow.common.enums.LogLevel; + +import java.util.logging.*; + +public final class LogUtil { + private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName()); + private static final String SDK_LOG_PREFIX = "[" + Constants.SDK_PREFIX + "] "; + private static boolean IS_LOGGER_SETUP_DONE = false; + + synchronized public static void setupLogger(LogLevel logLevel) { + IS_LOGGER_SETUP_DONE = true; + LogManager.getLogManager().reset(); + LOGGER.setUseParentHandlers(false); + Formatter formatter = new SimpleFormatter() { + private static final String format = "%s: %s %n"; + + // Override format method + @Override + public synchronized String format(LogRecord logRecord) { + return String.format( + format, + loggerLevelToLogLevelMap(logRecord.getLevel()), + logRecord.getMessage() + ); + } + }; + ConsoleHandler consoleHandler = new ConsoleHandler(); + consoleHandler.setFormatter(formatter); + consoleHandler.setLevel(Level.CONFIG); + + LOGGER.addHandler(consoleHandler); + LOGGER.setLevel(logLevelToLoggerLevelMap(logLevel)); + printInfoLog(InfoLogs.LOGGER_SETUP_DONE.getLog()); + } + + public static void printErrorLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.severe(SDK_LOG_PREFIX + message); + else { + setupLogger(LogLevel.ERROR); + LOGGER.severe(SDK_LOG_PREFIX + message); + } + } + + public static void printDebugLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.config(SDK_LOG_PREFIX + message); + } + + public static void printWarningLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.warning(SDK_LOG_PREFIX + message); + } + + public static void printInfoLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.info(SDK_LOG_PREFIX + message); + } + + + private static Level logLevelToLoggerLevelMap(LogLevel logLevel) { + Level loggerLevel; + switch (logLevel) { + case ERROR: + loggerLevel = Level.SEVERE; + break; + case WARN: + loggerLevel = Level.WARNING; + break; + case INFO: + loggerLevel = Level.INFO; + break; + case DEBUG: + loggerLevel = Level.CONFIG; + break; + default: + loggerLevel = Level.OFF; + } + return loggerLevel; + } + + private static LogLevel loggerLevelToLogLevelMap(Level loggerLevel) { + LogLevel logLevel; + if (Level.SEVERE.equals(loggerLevel)) { + logLevel = LogLevel.ERROR; + } else if (Level.WARNING.equals(loggerLevel)) { + logLevel = LogLevel.WARN; + } else if (Level.INFO.equals(loggerLevel)) { + logLevel = LogLevel.INFO; + } else if (Level.CONFIG.equals(loggerLevel)) { + logLevel = LogLevel.DEBUG; + } else + logLevel = LogLevel.OFF; + return logLevel; + } +} diff --git a/common/src/test/java/com/skyflow/api/TestClient.java b/common/src/test/java/com/skyflow/api/TestClient.java new file mode 100644 index 00000000..3f2810e1 --- /dev/null +++ b/common/src/test/java/com/skyflow/api/TestClient.java @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.api; + +public final class TestClient { + public void test() { + // Add tests here and mark this file in .fernignore + assert true; + } +} diff --git a/common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java b/common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java new file mode 100644 index 00000000..e661b48a --- /dev/null +++ b/common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java @@ -0,0 +1,341 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.api.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 com.skyflow.common.core.QueryStringMapper; +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/pom.xml b/pom.xml index df054845..835ffe20 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.skyflow skyflow-java 2.0.0-beta.2 - jar + pom ${project.groupId}:${project.artifactId} Skyflow SDK for the Java programming language @@ -25,6 +25,11 @@ skyflow + + common + v2 + v3 + scm:git:git://github.com:skyflowapi/skyflow-java.git scm:git:ssh://github.com:skyflowapi/skyflow-java.git diff --git a/v2/pom.xml b/v2/pom.xml new file mode 100644 index 00000000..8be437f7 --- /dev/null +++ b/v2/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.skyflow + skyflow-java + 2.0.0-beta.2 + + + v2 + 2.0.0-beta.2 + com.skyflow.v2 + + + 8 + 8 + UTF-8 + + + + + com.skyflow.common + common + 1.0.0 + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + com.skyflow.common:common + + + + + + + + + \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/ConnectionClient.java b/v2/src/main/java/com/skyflow/ConnectionClient.java new file mode 100644 index 00000000..8da10c12 --- /dev/null +++ b/v2/src/main/java/com/skyflow/ConnectionClient.java @@ -0,0 +1,94 @@ +package com.skyflow; + +import com.skyflow.common.serviceaccount.util.Token; +import com.skyflow.config.ConnectionConfig; +import com.skyflow.config.Credentials; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import io.github.cdimascio.dotenv.Dotenv; +import io.github.cdimascio.dotenv.DotenvException; + +public class ConnectionClient { + private final ConnectionConfig connectionConfig; + protected String token; + protected String apiKey; + private Credentials commonCredentials; + private Credentials finalCredentials; + + protected ConnectionClient(ConnectionConfig connectionConfig, Credentials credentials) { + super(); + this.connectionConfig = connectionConfig; + this.commonCredentials = credentials; + } + + protected ConnectionConfig getConnectionConfig() { + return connectionConfig; + } + + protected void setCommonCredentials(Credentials commonCredentials) throws SkyflowException { + this.commonCredentials = commonCredentials; + prioritiseCredentials(); + } + + protected void updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + prioritiseCredentials(); + } + + protected void setBearerToken() throws SkyflowException, com.skyflow.common.errors.SkyflowException { + prioritiseCredentials(); + Validations.validateCredentials(this.finalCredentials); + if (this.finalCredentials.getApiKey() != null) { + setApiKey(); + } else if (Token.isExpired(token)) { + LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); + token = Utils.generateBearerToken(this.finalCredentials); + } else { + LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); + } + } + + private void setApiKey() { + if (apiKey == null) { + apiKey = this.finalCredentials.getApiKey(); + } else { + LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); + } + } + + private void prioritiseCredentials() throws SkyflowException { + try { + Credentials original = this.finalCredentials; + if (this.connectionConfig.getCredentials() != null) { + this.finalCredentials = this.connectionConfig.getCredentials(); + } else if (this.commonCredentials != null) { + this.finalCredentials = this.commonCredentials; + } else { + Dotenv dotenv = Dotenv.load(); + String sysCredentials = dotenv.get(Constants.ENV_CREDENTIALS_KEY_NAME); + if (sysCredentials == null) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyCredentials.getMessage()); + } else { + this.finalCredentials = new Credentials(); + this.finalCredentials.setCredentialsString(sysCredentials); + } + } + if (original != null && !original.equals(this.finalCredentials)) { + token = null; + apiKey = null; + } + } catch (DotenvException e) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyCredentials.getMessage()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/v2/src/main/java/com/skyflow/Skyflow.java b/v2/src/main/java/com/skyflow/Skyflow.java new file mode 100644 index 00000000..8e51da57 --- /dev/null +++ b/v2/src/main/java/com/skyflow/Skyflow.java @@ -0,0 +1,307 @@ +package com.skyflow; + +import com.skyflow.config.ConnectionConfig; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.Env; +import com.skyflow.enums.LogLevel; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.controller.ConnectionController; +import com.skyflow.vault.controller.DetectController; +import com.skyflow.vault.controller.VaultController; + +import java.util.LinkedHashMap; + +public final class Skyflow { + private final SkyflowClientBuilder builder; + + private Skyflow(SkyflowClientBuilder builder) { + this.builder = builder; + LogUtil.printInfoLog(InfoLogs.CLIENT_INITIALIZED.getLog()); + } + + public static SkyflowClientBuilder builder() { + return new SkyflowClientBuilder(); + } + + public Skyflow addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + this.builder.addVaultConfig(vaultConfig); + return this; + } + + public VaultConfig getVaultConfig(String vaultId) { + return this.builder.vaultConfigMap.get(vaultId); + } + + public Skyflow updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + this.builder.updateVaultConfig(vaultConfig); + return this; + } + + public Skyflow removeVaultConfig(String vaultId) throws SkyflowException { + this.builder.removeVaultConfig(vaultId); + return this; + } + + public Skyflow addConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + this.builder.addConnectionConfig(connectionConfig); + return this; + } + + public ConnectionConfig getConnectionConfig(String connectionId) { + return this.builder.connectionConfigMap.get(connectionId); + } + + public Skyflow updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + this.builder.updateConnectionConfig(connectionConfig); + return this; + } + + public Skyflow removeConnectionConfig(String connectionId) throws SkyflowException { + this.builder.removeConnectionConfig(connectionId); + return this; + } + + public Skyflow updateSkyflowCredentials(Credentials credentials) throws SkyflowException { + this.builder.addSkyflowCredentials(credentials); + return this; + } + + public Skyflow updateLogLevel(LogLevel logLevel) { + this.builder.setLogLevel(logLevel); + return this; + } + + public LogLevel getLogLevel() { + return this.builder.logLevel; + } + + public VaultController vault() throws SkyflowException { + Object[] array = this.builder.vaultClientsMap.keySet().toArray(); + if (array.length < 1) { + LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + String vaultId = (String) array[0]; + return this.vault(vaultId); + } + + public VaultController vault(String vaultId) throws SkyflowException { + VaultController controller = this.builder.vaultClientsMap.get(vaultId); + if (controller == null) { + LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return controller; + } + + + public ConnectionController connection() throws SkyflowException { + Object[] array = this.builder.connectionsMap.keySet().toArray(); + if (array.length < 1) { + LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage()); + } + String connectionId = (String) array[0]; + return this.connection(connectionId); + } + + public ConnectionController connection(String connectionId) throws SkyflowException { + ConnectionController controller = this.builder.connectionsMap.get(connectionId); + if (controller == null) { + LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage()); + } + return controller; + } + + public DetectController detect() throws SkyflowException { + Object[] array = this.builder.detectClientsMap.keySet().toArray(); + if (array.length < 1) { + LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + String detectId = (String) array[0]; + return this.detect(detectId); + } + + public DetectController detect(String vaultId) throws SkyflowException { + DetectController controller = this.builder.detectClientsMap.get(vaultId); + if (controller == null) { + LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return controller; + } + + public static final class SkyflowClientBuilder { + private final LinkedHashMap connectionsMap; + private final LinkedHashMap vaultClientsMap; + private final LinkedHashMap detectClientsMap; + private final LinkedHashMap vaultConfigMap; + private final LinkedHashMap connectionConfigMap; + private Credentials skyflowCredentials; + private LogLevel logLevel; + + public SkyflowClientBuilder() { + this.vaultClientsMap = new LinkedHashMap<>(); + this.detectClientsMap = new LinkedHashMap<>(); + this.vaultConfigMap = new LinkedHashMap<>(); + this.connectionsMap = new LinkedHashMap<>(); + this.connectionConfigMap = new LinkedHashMap<>(); + this.skyflowCredentials = null; + this.logLevel = LogLevel.ERROR; + } + + public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); + Validations.validateVaultConfig(vaultConfig); + if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.VAULT_CONFIG_EXISTS.getLog(), vaultConfig.getVaultId() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); + } else { + this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); + this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); + this.detectClientsMap.put(vaultConfig.getVaultId(), new DetectController(vaultConfig, this.skyflowCredentials)); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); + } + return this; + } + + public SkyflowClientBuilder updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); + Validations.validateVaultConfig(vaultConfig); + if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { + VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfig); + this.vaultClientsMap.get(updatedConfig.getVaultId()).updateVaultConfig(); + } else { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultConfig.getVaultId() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return this; + } + + public SkyflowClientBuilder removeVaultConfig(String vaultId) throws SkyflowException { + if (this.vaultClientsMap.containsKey(vaultId)) { + this.vaultClientsMap.remove(vaultId); + this.vaultConfigMap.remove(vaultId); + } else { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultId)); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return this; + } + + public SkyflowClientBuilder addConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.VALIDATING_CONNECTION_CONFIG.getLog()); + Validations.validateConnectionConfig(connectionConfig); + if (this.connectionsMap.containsKey(connectionConfig.getConnectionId())) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.CONNECTION_CONFIG_EXISTS.getLog(), connectionConfig.getConnectionId() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.ConnectionIdAlreadyInConfigList.getMessage()); + } else { + this.connectionConfigMap.put(connectionConfig.getConnectionId(), connectionConfig); + ConnectionController controller = new ConnectionController(connectionConfig, this.skyflowCredentials); + this.connectionsMap.put(connectionConfig.getConnectionId(), controller); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.CONNECTION_CONTROLLER_INITIALIZED.getLog(), connectionConfig.getConnectionId())); + } + return this; + } + + public SkyflowClientBuilder updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.VALIDATING_CONNECTION_CONFIG.getLog()); + Validations.validateConnectionConfig(connectionConfig); + if (this.connectionsMap.containsKey(connectionConfig.getConnectionId())) { + ConnectionConfig updatedConfig = findAndUpdateConnectionConfig(connectionConfig); + this.connectionsMap.get(updatedConfig.getConnectionId()).updateConnectionConfig(connectionConfig); + } else { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog(), connectionConfig.getConnectionId() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.ConnectionIdNotInConfigList.getMessage()); + } + return this; + } + + public SkyflowClientBuilder removeConnectionConfig(String connectionId) throws SkyflowException { + if (this.connectionsMap.containsKey(connectionId)) { + this.connectionsMap.remove(connectionId); + this.connectionConfigMap.remove(connectionId); + } else { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog(), connectionId + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.ConnectionIdNotInConfigList.getMessage()); + } + return this; + } + + public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throws SkyflowException { + Validations.validateCredentials(credentials); + this.skyflowCredentials = credentials; + for (VaultController vault : this.vaultClientsMap.values()) { + vault.setCommonCredentials(this.skyflowCredentials); + } + for (DetectController detect : this.detectClientsMap.values()) { + detect.setCommonCredentials(this.skyflowCredentials); + } + for (ConnectionController connection : this.connectionsMap.values()) { + connection.setCommonCredentials(this.skyflowCredentials); + } + return this; + } + + public SkyflowClientBuilder setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; + LogUtil.setupLogger(this.logLevel); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.CURRENT_LOG_LEVEL.getLog(), String.valueOf(logLevel) + )); + return this; + } + + public Skyflow build() { + return new Skyflow(this); + } + + private VaultConfig findAndUpdateVaultConfig(VaultConfig vaultConfig) { + VaultConfig previousConfig = this.vaultConfigMap.get(vaultConfig.getVaultId()); + Env env = vaultConfig.getEnv() != null ? vaultConfig.getEnv() : previousConfig.getEnv(); + String clusterId = vaultConfig.getClusterId() != null ? vaultConfig.getClusterId() : previousConfig.getClusterId(); + Credentials credentials = vaultConfig.getCredentials() != null ? vaultConfig.getCredentials() : previousConfig.getCredentials(); + previousConfig.setEnv(env); + previousConfig.setClusterId(clusterId); + previousConfig.setCredentials(credentials); + return previousConfig; + } + + private ConnectionConfig findAndUpdateConnectionConfig(ConnectionConfig connectionConfig) { + ConnectionConfig previousConfig = this.connectionConfigMap.get(connectionConfig.getConnectionId()); + String connectionURL = connectionConfig.getConnectionUrl() != null ? connectionConfig.getConnectionUrl() : previousConfig.getConnectionUrl(); + Credentials credentials = connectionConfig.getCredentials() != null ? connectionConfig.getCredentials() : previousConfig.getCredentials(); + previousConfig.setConnectionUrl(connectionURL); + previousConfig.setCredentials(credentials); + return previousConfig; + } + } +} diff --git a/v2/src/main/java/com/skyflow/VaultClient.java b/v2/src/main/java/com/skyflow/VaultClient.java new file mode 100644 index 00000000..5a4c17b1 --- /dev/null +++ b/v2/src/main/java/com/skyflow/VaultClient.java @@ -0,0 +1,823 @@ +package com.skyflow; + +import com.skyflow.common.serviceaccount.util.Token; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.DetectEntities; +import com.skyflow.enums.DetectOutputTranscriptions; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.ApiClient; +import com.skyflow.generated.rest.ApiClientBuilder; +import com.skyflow.generated.rest.resources.files.FilesClient; +import com.skyflow.generated.rest.resources.files.requests.*; +import com.skyflow.generated.rest.resources.files.types.*; +import com.skyflow.generated.rest.resources.query.QueryClient; +import com.skyflow.generated.rest.resources.records.RecordsClient; +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.strings.StringsClient; +import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; +import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; +import com.skyflow.generated.rest.resources.strings.types.ReidentifyStringRequestFormat; +import com.skyflow.generated.rest.resources.tokens.TokensClient; +import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; +import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; +import com.skyflow.generated.rest.types.*; +import com.skyflow.generated.rest.types.Transformations; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.data.InsertRequest; +import com.skyflow.vault.data.UpdateRequest; +import com.skyflow.vault.detect.*; +import com.skyflow.vault.detect.DeidentifyFileRequest; +import com.skyflow.vault.detect.DeidentifyTextRequest; +import com.skyflow.vault.tokens.ColumnValue; +import com.skyflow.vault.tokens.DetokenizeData; +import com.skyflow.vault.tokens.DetokenizeRequest; +import com.skyflow.vault.tokens.TokenizeRequest; +import io.github.cdimascio.dotenv.Dotenv; +import io.github.cdimascio.dotenv.DotenvException; + +import java.util.*; +import java.util.stream.Collectors; + + +public class VaultClient { + private final VaultConfig vaultConfig; + private final ApiClientBuilder apiClientBuilder; + private ApiClient apiClient; + private Credentials commonCredentials; + private Credentials finalCredentials; + private String token; + private String apiKey; + + protected VaultClient(VaultConfig vaultConfig, Credentials credentials) { + super(); + this.vaultConfig = vaultConfig; + this.commonCredentials = credentials; + this.apiClientBuilder = new ApiClientBuilder(); + this.apiClient = null; + updateVaultURL(); + } + + protected RecordsClient getRecordsApi() { + return this.apiClient.records(); + } + + protected TokensClient getTokensApi() { + return this.apiClient.tokens(); + } + + protected StringsClient getDetectTextApi() { + return this.apiClient.strings(); + } + + protected FilesClient getDetectFileAPi(){ + return this.apiClient.files(); + } + + protected QueryClient getQueryApi() { + return this.apiClient.query(); + } + + protected VaultConfig getVaultConfig() { + return vaultConfig; + } + + protected void setCommonCredentials(Credentials commonCredentials) throws SkyflowException { + this.commonCredentials = commonCredentials; + prioritiseCredentials(); + } + + protected void updateVaultConfig() throws SkyflowException { + updateVaultURL(); + prioritiseCredentials(); + } + + protected V1DetokenizePayload getDetokenizePayload(DetokenizeRequest request) { + List recordRequests = new ArrayList<>(); + + for (DetokenizeData detokenizeDataRecord : request.getDetokenizeData()) { + V1DetokenizeRecordRequest recordRequest = V1DetokenizeRecordRequest.builder() + .token(detokenizeDataRecord.getToken()) + .redaction(detokenizeDataRecord.getRedactionType().getRedaction()) + .build(); + recordRequests.add(recordRequest); + } + + return V1DetokenizePayload.builder() + .continueOnError(request.getContinueOnError()) + .downloadUrl(request.getDownloadURL()) + .detokenizationParameters(recordRequests) + .build(); + } + + protected RecordServiceInsertRecordBody getBulkInsertRequestBody(InsertRequest request) { + List> values = request.getValues(); + List> tokens = request.getTokens(); + List records = new ArrayList<>(); + + for (int index = 0; index < values.size(); index++) { + V1FieldRecords.Builder recordBuilder = V1FieldRecords.builder().fields(values.get(index)); + if (tokens != null && index < tokens.size()) { + recordBuilder.tokens(tokens.get(index)); + } + records.add(recordBuilder.build()); + } + + return RecordServiceInsertRecordBody.builder() + .tokenization(request.getReturnTokens()) + .homogeneous(request.getHomogeneous()) + .upsert(request.getUpsert()) + .byot(request.getTokenMode().getBYOT()) + .records(records) + .build(); + } + + protected RecordServiceBatchOperationBody getBatchInsertRequestBody(InsertRequest request) { + ArrayList> values = request.getValues(); + ArrayList> tokens = request.getTokens(); + List records = new ArrayList<>(); + + for (int index = 0; index < values.size(); index++) { + V1BatchRecord.Builder recordBuilder = V1BatchRecord.builder() + .method(BatchRecordMethod.POST) + .tableName(request.getTable()) + .upsert(request.getUpsert()) + .tokenization(request.getReturnTokens()) + .fields(values.get(index)); + + if (tokens != null && index < tokens.size()) { + recordBuilder.tokens(tokens.get(index)); + } + + records.add(recordBuilder.build()); + } + + return RecordServiceBatchOperationBody.builder() + .continueOnError(true) + .byot(request.getTokenMode().getBYOT()) + .records(records) + .build(); + } + + protected RecordServiceUpdateRecordBody getUpdateRequestBody(UpdateRequest request) { + RecordServiceUpdateRecordBody.Builder updateRequestBodyBuilder = RecordServiceUpdateRecordBody.builder(); + updateRequestBodyBuilder.byot(request.getTokenMode().getBYOT()); + updateRequestBodyBuilder.tokenization(request.getReturnTokens()); + V1FieldRecords.Builder recordBuilder = V1FieldRecords.builder(); + HashMap values = request.getData(); + + if (values != null) { + recordBuilder.fields(values); + } + + HashMap tokens = request.getTokens(); + if (tokens != null) { + recordBuilder.tokens(tokens); + } + + updateRequestBodyBuilder.record(recordBuilder.build()); + + return updateRequestBodyBuilder.build(); + } + + protected V1TokenizePayload getTokenizePayload(TokenizeRequest request) { + List tokenizationParameters = new ArrayList<>(); + + for (ColumnValue columnValue : request.getColumnValues()) { + V1TokenizeRecordRequest.Builder recordBuilder = V1TokenizeRecordRequest.builder(); + String value = columnValue.getValue(); + recordBuilder.value(value); + String columnGroup = columnValue.getColumnGroup(); + recordBuilder.columnGroup(columnGroup); + tokenizationParameters.add(recordBuilder.build()); + } + + V1TokenizePayload.Builder payloadBuilder = V1TokenizePayload.builder(); + + if (!tokenizationParameters.isEmpty()) { + payloadBuilder.tokenizationParameters(tokenizationParameters); + } + + return payloadBuilder.build(); + } + + protected void setBearerToken() throws SkyflowException { + prioritiseCredentials(); + Validations.validateCredentials(this.finalCredentials); + if (this.finalCredentials.getApiKey() != null) { + LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); + token=this.finalCredentials.getApiKey(); + } else if (Token.isExpired(token)) { + LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); + try { + token = Utils.generateBearerToken(this.finalCredentials); + } catch (com.skyflow.common.errors.SkyflowException e) { + throw new RuntimeException(e); + } + } else { + LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); + } + this.apiClientBuilder.token(token); + this.apiClient = this.apiClientBuilder.build(); + } + + protected DeidentifyTextResponse getDeIdentifyTextResponse(DeidentifyStringResponse deidentifyStringResponse) { + List entities = deidentifyStringResponse.getEntities() != null + ? deidentifyStringResponse.getEntities().stream() + .map(this::convertDetectedEntityToEntityInfo) + .collect(Collectors.toList()) + : null; + + return new DeidentifyTextResponse( + deidentifyStringResponse.getProcessedText(), + entities, + deidentifyStringResponse.getWordCount(), + deidentifyStringResponse.getCharacterCount() + ); + } + + protected DeidentifyStringRequest getDeidentifyStringRequest(DeidentifyTextRequest deIdentifyTextRequest, String vaultId) throws SkyflowException { + List entities = deIdentifyTextRequest.getEntities(); + + List mappedEntityTypes = null; + if (entities != null) { + mappedEntityTypes = deIdentifyTextRequest.getEntities().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList()); + } + + TokenFormat tokenFormat = deIdentifyTextRequest.getTokenFormat(); + + Optional> vaultToken = Optional.empty(); + Optional> entityTypes = Optional.empty(); + Optional> entityUniqueCounter = Optional.empty(); + Optional> allowRegex = Optional.ofNullable(deIdentifyTextRequest.getAllowRegexList()); + Optional> restrictRegex = Optional.ofNullable(deIdentifyTextRequest.getRestrictRegexList()); + Optional transformations = Optional.ofNullable(getTransformations(deIdentifyTextRequest.getTransformations())); + + if (tokenFormat != null) { + if (tokenFormat.getVaultToken() != null && !tokenFormat.getVaultToken().isEmpty()) { + vaultToken = Optional.of(tokenFormat.getVaultToken().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) { + entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { + entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + } + + TokenType tokenType = TokenType.builder() + .vaultToken(vaultToken) + .entityOnly(entityTypes) + .entityUnqCounter(entityUniqueCounter) + .build(); + + + return DeidentifyStringRequest.builder() + .vaultId(vaultId) + .text(deIdentifyTextRequest.getText()) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + protected ReidentifyStringRequest getReidentifyStringRequest(ReidentifyTextRequest reidentifyTextRequest, String vaultId) throws SkyflowException { + List maskEntities = null; + List redactedEntities = null; + List plaintextEntities = null; + + if (reidentifyTextRequest.getMaskedEntities() != null) { + maskEntities = reidentifyTextRequest.getMaskedEntities().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList()); + } + + if (reidentifyTextRequest.getPlainTextEntities() != null) { + plaintextEntities = reidentifyTextRequest.getPlainTextEntities().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList()); + } + + if (reidentifyTextRequest.getRedactedEntities() != null) { + redactedEntities = reidentifyTextRequest.getRedactedEntities().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList()); + } + + ReidentifyStringRequestFormat reidentifyStringRequestFormat = ReidentifyStringRequestFormat.builder() + .masked(maskEntities) + .plaintext(plaintextEntities) + .redacted(redactedEntities) + .build(); + + + return ReidentifyStringRequest.builder() + .text(reidentifyTextRequest.getText()) + .vaultId(vaultId) + .format(reidentifyStringRequestFormat) + .build(); + } + + + private EntityInfo convertDetectedEntityToEntityInfo(DetectedEntity detectedEntity) { + TextIndex textIndex = new TextIndex( + detectedEntity.getLocation().get().getStartIndex().orElse(0), + detectedEntity.getLocation().get().getEndIndex().orElse(0) + ); + TextIndex processedIndex = new TextIndex( + detectedEntity.getLocation().get().getStartIndexProcessed().orElse(0), + detectedEntity.getLocation().get().getEndIndexProcessed().orElse(0) + ); + + Map entityScores = detectedEntity.getEntityScores() + .map(doubleMap -> doubleMap.entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue + ))) + .orElse(Collections.emptyMap()); + + + return new EntityInfo( + detectedEntity.getToken().orElse(""), + detectedEntity.getValue().orElse(""), + textIndex, + processedIndex, + detectedEntity.getEntityType().orElse(""), + entityScores); + } + + + private Transformations getTransformations(com.skyflow.vault.detect.Transformations transformations) { + if (transformations == null || transformations.getShiftDates() == null) { + return null; + } + + List entityTypes = null; + if (!transformations.getShiftDates().getEntities().isEmpty()) { + entityTypes = transformations.getShiftDates().getEntities().stream() + .map(entity -> TransformationsShiftDatesEntityTypesItem.valueOf(entity.name())) + .collect(Collectors.toList()); + } else { + entityTypes = Collections.emptyList(); + } + + return Transformations.builder() + .shiftDates(TransformationsShiftDates.builder() + .maxDays(transformations.getShiftDates().getMax()) + .minDays(transformations.getShiftDates().getMin()) + .entityTypes(entityTypes) + .build()) + .build(); + } + + private List getEntityTypes(List entities){ + List mappedEntityTypes = null; + if (entities != null) { + mappedEntityTypes = entities.stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList()); + } + + return mappedEntityTypes; + } + + protected com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest getDeidentifyTextFileRequest(DeidentifyFileRequest request, String vaultId, String base64Content){ + List mappedEntityTypes = getEntityTypes(request.getEntities()); + + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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()) { + entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { + entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + } + + TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() + .entityOnly(entityTypes) + .entityUnqCounter(entityUniqueCounter) + .build(); + + DeidentifyTextRequestFile file = DeidentifyTextRequestFile.builder() + .base64(base64Content) + .build(); + + // Build the final request + com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest req = + com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + + return req; + } + + + protected DeidentifyAudioRequest getDeidentifyAudioRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String dataFormat) throws SkyflowException { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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()) { + entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { + entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + } + + TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() + .entityOnly(entityTypes) + .entityUnqCounter(entityUniqueCounter) + .build(); + + DeidentifyAudioRequestFile deidentifyAudioRequestFile = DeidentifyAudioRequestFile.builder().base64(base64Content).dataFormat(mapAudioDataFormat(dataFormat)).build(); + DetectOutputTranscriptions transcription = request.getOutputTranscription(); + DeidentifyAudioRequestOutputTranscription outputTranscriptionType = null; + if (transcription != null) { + outputTranscriptionType = DeidentifyAudioRequestOutputTranscription.valueOf(transcription.name()); + } + + return DeidentifyAudioRequest.builder() + .vaultId(vaultId) + .file(deidentifyAudioRequestFile) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .entityTypes(mappedEntityTypes) + .bleepFrequency(request.getBleep() != null ? request.getBleep().getFrequency() : null) + .bleepGain(request.getBleep() != null ? request.getBleep().getGain() : null) + .bleepStartPadding(request.getBleep() != null ? request.getBleep().getStartPadding() : null) + .bleepStopPadding(request.getBleep() != null ? request.getBleep().getStopPadding() : null) + .outputProcessedAudio(request.getOutputProcessedAudio()) + .outputTranscription(outputTranscriptionType) + .tokenType(tokenType) + .transformations(transformations) + .build(); + } + + protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest request, String vaultId, String base64Content) { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + + TokenFormat tokenFormat = request.getTokenFormat(); + Optional> entityTypes = Optional.empty(); + 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()) { + entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { + entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + } + + TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() + .entityOnly(entityTypes) + .entityUnqCounter(entityUniqueCounter) + .build(); + + DeidentifyPdfRequestFile file = DeidentifyPdfRequestFile.builder() + .base64(base64Content) + .build(); + + return DeidentifyPdfRequest.builder() + .vaultId(vaultId) + .file(file) + .density(request.getPixelDensity() != null ? request.getPixelDensity().intValue() : null) + .maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().intValue() : null) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + + TokenFormat tokenFormat = request.getTokenFormat(); + Optional> entityTypes = Optional.empty(); + 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); + + DeidentifyImageRequestFile file = DeidentifyImageRequestFile.builder() + .base64(base64Content) + .dataFormat(DeidentifyImageRequestFileDataFormat.valueOf(format.toUpperCase())) + .build(); + + Optional maskingMethod = Optional.empty(); + if (request.getMaskingMethod() != null) { + maskingMethod = Optional.of(DeidentifyImageRequestMaskingMethod.valueOf(request.getMaskingMethod().name())); + } + + return DeidentifyImageRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .maskingMethod(maskingMethod) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .outputProcessedImage(request.getOutputProcessedImage()) + .outputOcrText(request.getOutputOcrText()) + .build(); + } + + protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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); + + DeidentifyPresentationRequestFile file = DeidentifyPresentationRequestFile.builder() + .base64(base64Content) + .dataFormat(DeidentifyPresentationRequestFileDataFormat.valueOf(format.toUpperCase())) + .build(); + + return DeidentifyPresentationRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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); + + DeidentifySpreadsheetRequestFile file = DeidentifySpreadsheetRequestFile.builder() + .base64(base64Content) + .dataFormat(DeidentifySpreadsheetRequestFileDataFormat.valueOf(format.toUpperCase())) + .build(); + + return DeidentifySpreadsheetRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + protected DeidentifyStructuredTextRequest getDeidentifyStructuredTextRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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); + + DeidentifyStructuredTextRequestFile file = DeidentifyStructuredTextRequestFile.builder() + .base64(base64Content) + .dataFormat(DeidentifyStructuredTextRequestFileDataFormat.valueOf(format.toUpperCase())) + .build(); + + return DeidentifyStructuredTextRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { + List mappedEntityTypes = getEntityTypes(request.getEntities()); + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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); + + DeidentifyDocumentRequestFile file = DeidentifyDocumentRequestFile.builder() + .base64(base64Content) + .dataFormat(DeidentifyDocumentRequestFileDataFormat.valueOf(format.toUpperCase())) + .build(); + + return DeidentifyDocumentRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + protected com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest getDeidentifyGenericFileRequest( + DeidentifyFileRequest request, String vaultId, String base64Content, String fileExtension) { + + List mappedEntityTypes = getEntityTypes(request.getEntities()); + + TokenFormat tokenFormat = request.getTokenFormat(); + + Optional> entityTypes = Optional.empty(); + 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()) { + entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { + entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + } + + TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() + .entityOnly(entityTypes) + .entityUnqCounter(entityUniqueCounter) + .build(); + + DeidentifyFileRequestFile file = + DeidentifyFileRequestFile.builder() + .base64(base64Content) + .dataFormat(fileExtension != null ? DeidentifyFileRequestFileDataFormat.valueOf(fileExtension.toUpperCase()) : null) + .build(); + + return com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest.builder() + .vaultId(vaultId) + .file(file) + .entityTypes(mappedEntityTypes) + .tokenType(tokenType) + .allowRegex(allowRegex) + .restrictRegex(restrictRegex) + .transformations(transformations) + .build(); + } + + private TokenTypeWithoutVault buildTokenType(TokenFormat tokenFormat, + Optional> entityTypes, + Optional> entityUniqueCounter) { + + if (tokenFormat != null) { + if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) { + entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + + if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { + entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() + .map(detectEntity -> EntityType.valueOf(detectEntity.name())) + .collect(Collectors.toList())); + } + } + + return TokenTypeWithoutVault.builder() + .entityOnly(entityTypes) + .entityUnqCounter(entityUniqueCounter) + .build(); + } + + private DeidentifyAudioRequestFileDataFormat mapAudioDataFormat(String dataFormat) throws SkyflowException { + switch (dataFormat) { + case "mp3": + return DeidentifyAudioRequestFileDataFormat.MP_3; + case "wav": + return DeidentifyAudioRequestFileDataFormat.WAV; + default: + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidAudioFileType.getMessage()); + } + } + + private void updateVaultURL() { + String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); + this.apiClientBuilder.url(vaultURL); + } + + private void prioritiseCredentials() throws SkyflowException { + try { + Credentials original = this.finalCredentials; + if (this.vaultConfig.getCredentials() != null) { + this.finalCredentials = this.vaultConfig.getCredentials(); + } else if (this.commonCredentials != null) { + this.finalCredentials = this.commonCredentials; + } else { + Dotenv dotenv = Dotenv.load(); + String sysCredentials = dotenv.get(Constants.ENV_CREDENTIALS_KEY_NAME); + if (sysCredentials == null) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyCredentials.getMessage()); + } else { + this.finalCredentials = new Credentials(); + this.finalCredentials.setCredentialsString(sysCredentials); + } + } + if (original != null && !original.equals(this.finalCredentials)) { + token = null; + apiKey = null; + } + } catch (DotenvException e) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyCredentials.getMessage()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/v2/src/main/java/com/skyflow/config/ConnectionConfig.java b/v2/src/main/java/com/skyflow/config/ConnectionConfig.java new file mode 100644 index 00000000..c017b181 --- /dev/null +++ b/v2/src/main/java/com/skyflow/config/ConnectionConfig.java @@ -0,0 +1,38 @@ +package com.skyflow.config; + +public class ConnectionConfig { + private String connectionId; + private String connectionUrl; + private Credentials credentials; + + public ConnectionConfig() { + this.connectionId = null; + this.connectionUrl = null; + this.credentials = null; + } + + public String getConnectionId() { + return connectionId; + } + + public void setConnectionId(String connectionId) { + this.connectionId = connectionId; + } + + public String getConnectionUrl() { + return connectionUrl; + } + + public void setConnectionUrl(String connectionUrl) { + this.connectionUrl = connectionUrl; + } + + public Credentials getCredentials() { + return credentials; + } + + public void setCredentials(Credentials credentials) { + this.credentials = credentials; + } + +} diff --git a/v2/src/main/java/com/skyflow/config/Credentials.java b/v2/src/main/java/com/skyflow/config/Credentials.java new file mode 100644 index 00000000..f1865dc7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/config/Credentials.java @@ -0,0 +1,66 @@ +package com.skyflow.config; + +import java.util.ArrayList; + +public class Credentials { + private String path; + private ArrayList roles; + private String context; + private String credentialsString; + private String token; + private String apiKey; + + public Credentials() { + this.path = null; + this.context = null; + this.credentialsString = null; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public ArrayList getRoles() { + return roles; + } + + public void setRoles(ArrayList roles) { + this.roles = roles; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getCredentialsString() { + return credentialsString; + } + + public void setCredentialsString(String credentialsString) { + this.credentialsString = credentialsString; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } +} diff --git a/v2/src/main/java/com/skyflow/config/ManagementConfig.java b/v2/src/main/java/com/skyflow/config/ManagementConfig.java new file mode 100644 index 00000000..a054c8ea --- /dev/null +++ b/v2/src/main/java/com/skyflow/config/ManagementConfig.java @@ -0,0 +1,11 @@ +package com.skyflow.config; + +public class ManagementConfig { + // members + + // constructor + ManagementConfig() { + } + + // getters and setters +} diff --git a/v2/src/main/java/com/skyflow/config/VaultConfig.java b/v2/src/main/java/com/skyflow/config/VaultConfig.java new file mode 100644 index 00000000..4f61af2a --- /dev/null +++ b/v2/src/main/java/com/skyflow/config/VaultConfig.java @@ -0,0 +1,49 @@ +package com.skyflow.config; + +import com.skyflow.enums.Env; + +public class VaultConfig { + private String vaultId; + private String clusterId; + private Env env; + private Credentials credentials; + + public VaultConfig() { + this.vaultId = null; + this.clusterId = null; + this.env = Env.PROD; + this.credentials = null; + } + + public String getVaultId() { + return vaultId; + } + + public void setVaultId(String vaultId) { + this.vaultId = vaultId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public Env getEnv() { + return env; + } + + public void setEnv(Env env) { + this.env = env == null ? Env.PROD : env; + } + + public Credentials getCredentials() { + return credentials; + } + + public void setCredentials(Credentials credentials) { + this.credentials = credentials; + } +} diff --git a/v2/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java b/v2/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java new file mode 100644 index 00000000..e17c6d0c --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java @@ -0,0 +1,16 @@ +package com.skyflow.enums; + +public enum DeidentifyFileStatus { + IN_PROGRESS("IN_PROGRESS"), + SUCCESS("SUCCESS"); + + private final String value; + + DeidentifyFileStatus(String value) { + this.value = value; + } + + public String value() { + return value; + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/enums/DetectEntities.java b/v2/src/main/java/com/skyflow/enums/DetectEntities.java new file mode 100644 index 00000000..f2c21eff --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/DetectEntities.java @@ -0,0 +1,83 @@ +package com.skyflow.enums; + + +public enum DetectEntities { + ACCOUNT_NUMBER("account_number"), + AGE("age"), + ALL("all"), + BANK_ACCOUNT("bank_account"), + BLOOD_TYPE("blood_type"), + CONDITION("condition"), + CORPORATE_ACTION("corporate_action"), + CREDIT_CARD("credit_card"), + CREDIT_CARD_EXPIRATION("credit_card_expiration"), + CVV("cvv"), + DATE("date"), + DATE_INTERVAL("date_interval"), + DOB("dob"), + DOSE("dose"), + DRIVER_LICENSE("driver_license"), + DRUG("drug"), + DURATION("duration"), + EMAIL_ADDRESS("email_address"), + EVENT("event"), + FILENAME("filename"), + FINANCIAL_METRIC("financial_metric"), + GENDER_SEXUALITY("gender_sexuality"), + HEALTHCARE_NUMBER("healthcare_number"), + INJURY("injury"), + IP_ADDRESS("ip_address"), + LANGUAGE("language"), + LOCATION("location"), + LOCATION_ADDRESS("location_address"), + LOCATION_ADDRESS_STREET("location_address_street"), + LOCATION_CITY("location_city"), + LOCATION_COORDINATE("location_coordinate"), + LOCATION_COUNTRY("location_country"), + LOCATION_STATE("location_state"), + LOCATION_ZIP("location_zip"), + MARITAL_STATUS("marital_status"), + MEDICAL_CODE("medical_code"), + MEDICAL_PROCESS("medical_process"), + MONEY("money"), + NAME("name"), + NAME_FAMILY("name_family"), + NAME_GIVEN("name_given"), + NAME_MEDICAL_PROFESSIONAL("name_medical_professional"), + NUMERICAL_PII("numerical_pii"), + OCCUPATION("occupation"), + ORGANIZATION("organization"), + ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), + ORIGIN("origin"), + PASSPORT_NUMBER("passport_number"), + PASSWORD("password"), + PHONE_NUMBER("phone_number"), + PHYSICAL_ATTRIBUTE("physical_attribute"), + POLITICAL_AFFILIATION("political_affiliation"), + PRODUCT("product"), + RELIGION("religion"), + ROUTING_NUMBER("routing_number"), + SSN("ssn"), + STATISTICS("statistics"), + TIME("time"), + TREND("trend"), + URL("url"), + USERNAME("username"), + VEHICLE_ID("vehicle_id"), + ZODIAC_SIGN("zodiac_sign"); + + private final String detectEntities; + + DetectEntities(String detectEntities) { + this.detectEntities = detectEntities; + } + + public String getDetectEntities() { + return detectEntities; + } + + @Override + public String toString() { + return detectEntities; + } +} diff --git a/v2/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java b/v2/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java new file mode 100644 index 00000000..43251c61 --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java @@ -0,0 +1,24 @@ +package com.skyflow.enums; + +public enum DetectOutputTranscriptions { + DIARIZED_TRANSCRIPTION("diarized_transcription"), + MEDICAL_DIARIZED_TRANSCRIPTION("medical_diarized_transcription"), + MEDICAL_TRANSCRIPTION("medical_transcription"), + PLAINTEXT_TRANSCRIPTION("plaintext_transcription"), + TRANSCRIPTION("transcription"); + + private final String detectOutputTranscriptions; + + DetectOutputTranscriptions(String detectOutputTranscriptions) { + this.detectOutputTranscriptions = detectOutputTranscriptions; + } + + public String getDetectOutputTranscriptions() { + return detectOutputTranscriptions; + } + + @Override + public String toString() { + return detectOutputTranscriptions; + } +} diff --git a/v2/src/main/java/com/skyflow/enums/Env.java b/v2/src/main/java/com/skyflow/enums/Env.java new file mode 100644 index 00000000..3d1466e9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/Env.java @@ -0,0 +1,8 @@ +package com.skyflow.enums; + +public enum Env { + DEV, + STAGE, + SANDBOX, + PROD +} diff --git a/v2/src/main/java/com/skyflow/enums/InterfaceName.java b/v2/src/main/java/com/skyflow/enums/InterfaceName.java new file mode 100644 index 00000000..98992f21 --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/InterfaceName.java @@ -0,0 +1,24 @@ +package com.skyflow.enums; + +public enum InterfaceName { + INSERT("insert"), + DETOKENIZE("detokenize"), + GET("get"), + UPDATE("update"), + DELETE("delete"), + QUERY("query"), + TOKENIZE("tokenize"), + FILE_UPLOAD("file upload"), + DETECT("detect"), + INVOKE_CONNECTION("invoke connection"); + + private final String interfaceName; + + InterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public String getName() { + return interfaceName; + } +} diff --git a/v2/src/main/java/com/skyflow/enums/LogLevel.java b/v2/src/main/java/com/skyflow/enums/LogLevel.java new file mode 100644 index 00000000..a605b520 --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/LogLevel.java @@ -0,0 +1,9 @@ +package com.skyflow.enums; + +public enum LogLevel { + OFF, + ERROR, + WARN, + INFO, + DEBUG +} diff --git a/v2/src/main/java/com/skyflow/enums/MaskingMethod.java b/v2/src/main/java/com/skyflow/enums/MaskingMethod.java new file mode 100644 index 00000000..e3ff252c --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/MaskingMethod.java @@ -0,0 +1,21 @@ +package com.skyflow.enums; + +public enum MaskingMethod { + BLACKBOX("blackbox"), + BLUR("blur"); + + private final String maskingMethod; + + MaskingMethod(String maskingMethod) { + this.maskingMethod = maskingMethod; + } + + public String getMaskingMethod() { + return maskingMethod; + } + + @Override + public String toString() { + return maskingMethod; + } +} diff --git a/v2/src/main/java/com/skyflow/enums/RedactionType.java b/v2/src/main/java/com/skyflow/enums/RedactionType.java new file mode 100644 index 00000000..9c76cc7d --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/RedactionType.java @@ -0,0 +1,26 @@ +package com.skyflow.enums; + + +import com.skyflow.generated.rest.types.RedactionEnumRedaction; + +public enum RedactionType { + PLAIN_TEXT(RedactionEnumRedaction.PLAIN_TEXT), + MASKED(RedactionEnumRedaction.MASKED), + DEFAULT(RedactionEnumRedaction.DEFAULT), + REDACTED(RedactionEnumRedaction.REDACTED); + + private final RedactionEnumRedaction redaction; + + RedactionType(RedactionEnumRedaction redaction) { + this.redaction = redaction; + } + + public RedactionEnumRedaction getRedaction() { + return redaction; + } + + @Override + public String toString() { + return String.valueOf(redaction); + } +} diff --git a/v2/src/main/java/com/skyflow/enums/RequestMethod.java b/v2/src/main/java/com/skyflow/enums/RequestMethod.java new file mode 100644 index 00000000..ffa3d949 --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/RequestMethod.java @@ -0,0 +1,22 @@ +package com.skyflow.enums; + +public enum RequestMethod { + GET("GET"), + POST("POST"), + PUT("PUT"), + PATCH("PATCH"), + DELETE("DELETE"), + ; + + private final String requestMethod; + + + RequestMethod(String requestMethod) { + this.requestMethod = requestMethod; + } + + @Override + public String toString() { + return requestMethod; + } +} diff --git a/v2/src/main/java/com/skyflow/enums/TokenMode.java b/v2/src/main/java/com/skyflow/enums/TokenMode.java new file mode 100644 index 00000000..63e9b8a9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/TokenMode.java @@ -0,0 +1,24 @@ +package com.skyflow.enums; + +import com.skyflow.generated.rest.types.V1Byot; + +public enum TokenMode { + DISABLE(V1Byot.DISABLE), + ENABLE(V1Byot.ENABLE), + ENABLE_STRICT(V1Byot.ENABLE_STRICT); + + private final V1Byot byot; + + TokenMode(V1Byot byot) { + this.byot = byot; + } + + public V1Byot getBYOT() { + return byot; + } + + @Override + public String toString() { + return byot.toString(); + } +} diff --git a/v2/src/main/java/com/skyflow/enums/TokenType.java b/v2/src/main/java/com/skyflow/enums/TokenType.java new file mode 100644 index 00000000..4a619e9c --- /dev/null +++ b/v2/src/main/java/com/skyflow/enums/TokenType.java @@ -0,0 +1,27 @@ +package com.skyflow.enums; + +public enum TokenType { + VAULT_TOKEN("vault_token"), + ENTITY_UNIQUE_COUNTER("entity_unq_counter"), + ENTITY_ONLY("entity_only"); + + private final String tokenType; + + TokenType(String tokenType) { + this.tokenType = tokenType; + } + + public String getTokenType() { + return tokenType; + } + + public String getDefault() { + return ENTITY_UNIQUE_COUNTER.getTokenType(); + } + + @Override + public String toString() { + return tokenType; + } +} + diff --git a/v2/src/main/java/com/skyflow/errors/ErrorCode.java b/v2/src/main/java/com/skyflow/errors/ErrorCode.java new file mode 100644 index 00000000..943913c6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/errors/ErrorCode.java @@ -0,0 +1,18 @@ +package com.skyflow.errors; + +public enum ErrorCode { + INVALID_INPUT(400), + INVALID_INDEX(404), + SERVER_ERROR(500), + PARTIAL_SUCCESS(500); + + private final int code; + + ErrorCode(int code) { + this.code = code; + } + + public int getCode() { + return code; + } +} diff --git a/v2/src/main/java/com/skyflow/errors/ErrorMessage.java b/v2/src/main/java/com/skyflow/errors/ErrorMessage.java new file mode 100644 index 00000000..df075bca --- /dev/null +++ b/v2/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -0,0 +1,162 @@ +package com.skyflow.errors; + +import com.skyflow.utils.Constants; + +public enum ErrorMessage { + // Client initialization + VaultIdAlreadyInConfigList("%s0 Validation error. VaultId is present in an existing config. Specify a new vaultId in config."), + VaultIdNotInConfigList("%s0 Validation error. VaultId is missing from the config. Specify the vaultIds from configs."), + ConnectionIdAlreadyInConfigList("%s0 Validation error. ConnectionId is present in an existing config. Specify a connectionId in config."), + ConnectionIdNotInConfigList("%s0 Validation error. ConnectionId is missing from the config. Specify the connectionIds from configs."), + EmptyCredentials("%s0 Validation error. Invalid credentials. Credentials must not be empty."), + + // Vault config + InvalidVaultId("%s0 Initialization failed. Invalid vault ID. Specify a valid vault ID."), + EmptyVaultId("%s0 Initialization failed. Invalid vault ID. Vault ID must not be empty."), + InvalidClusterId("%s0 Initialization failed. Invalid cluster ID. Specify cluster ID."), + EmptyClusterId("%s0 Initialization failed. Invalid cluster ID. Specify a valid cluster ID."), + + // Connection config + InvalidConnectionId("%s0 Initialization failed. Invalid connection ID. Specify a valid connection ID."), + EmptyConnectionId("%s0 Initialization failed. Invalid connection ID. Connection ID must not be empty."), + InvalidConnectionUrl("%s0 Initialization failed. Invalid connection URL. Specify a valid connection URL."), + EmptyConnectionUrl("%s0 Initialization failed. Invalid connection URL. Connection URL must not be empty."), + InvalidConnectionUrlFormat("%s0 Initialization failed. Connection URL is not a valid URL. Specify a valid connection URL."), + + // Credentials + MultipleTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify only one from 'path', 'credentialsString', 'token' or 'apiKey'."), + NoTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify any one from 'path', 'credentialsString', 'token' or 'apiKey'."), + EmptyCredentialFilePath("%s0 Initialization failed. Invalid credentials. Credentials file path must not be empty."), + EmptyCredentialsString("%s0 Initialization failed. Invalid credentials. Credentials string must not be empty."), + EmptyToken("%s0 Initialization failed. Invalid credentials. Token must not be empty."), + EmptyApikey("%s0 Initialization failed. Invalid credentials. Api key must not be empty."), + InvalidApikey("%s0 Initialization failed. Invalid credentials. Specify valid api key."), + EmptyRoles("%s0 Initialization failed. Invalid roles. Specify at least one role."), + EmptyRoleInRoles("%s0 Initialization failed. Invalid role. Specify a valid role."), + EmptyContext("%s0 Initialization failed. Invalid context. Specify a valid context."), + + // Bearer token generation + FileNotFound("%s0 Initialization failed. Credential file not found at %s1. Verify the file path."), + FileInvalidJson("%s0 Initialization failed. File at %s1 is not in valid JSON format. Verify the file contents."), + CredentialsStringInvalidJson("%s0 Initialization failed. Credentials string is not in valid JSON format. Verify the credentials string contents."), + InvalidCredentials("%s0 Initialization failed. Invalid credentials provided. Specify valid credentials."), + MissingPrivateKey("%s0 Initialization failed. Unable to read private key in credentials. Verify your private key."), + MissingClientId("%s0 Initialization failed. Unable to read client ID in credentials. Verify your client ID."), + MissingKeyId("%s0 Initialization failed. Unable to read key ID in credentials. Verify your key ID."), + MissingTokenUri("%s0 Initialization failed. Unable to read token URI in credentials. Verify your token URI."), + InvalidTokenUri("%s0 Initialization failed. Token URI in not a valid URL in credentials. Verify your token URI."), + JwtInvalidFormat("%s0 Initialization failed. Invalid private key format. Verify your credentials."), + InvalidAlgorithm("%s0 Initialization failed. Invalid algorithm to parse private key. Specify valid algorithm."), + InvalidKeySpec("%s0 Initialization failed. Unable to parse RSA private key. Verify your credentials."), + JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."), + MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."), + MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."), + + // Insert + TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."), + EmptyTable("%s0 Validation error. 'table' can't be empty. Specify a table."), + ValuesKeyError("%s0 Validation error. 'values' key is missing from the payload. Specify a 'values' key."), + EmptyValues("%s0 Validation error. 'values' can't be empty. Specify values."), + EmptyKeyInValues("%s0 Validation error. Invalid key in values. Specify a valid key."), + EmptyValueInValues("%s0 Validation error. Invalid value in values. Specify a valid value."), + TokensKeyError("%s0 Validation error. 'tokens' key is missing from the payload. Specify a 'tokens' key."), + EmptyTokens("%s0 Validation error. The 'tokens' field is empty. Specify tokens for one or more fields."), + EmptyKeyInTokens("%s0 Validation error. Invalid key tokens. Specify a valid key."), + EmptyValueInTokens("%s0 Validation error. Invalid value in tokens. Specify a valid value."), + EmptyUpsert("%s0 Validation error. 'upsert' key can't be empty. Specify an upsert column."), + HomogenousNotSupportedWithUpsert("%s0 Validation error. 'homogenous' is not supported with 'upsert'. Specify either 'homogenous' or 'upsert'."), + TokensPassedForTokenModeDisable("%s0 Validation error. 'tokenMode' wasn't specified. Set 'tokenMode' to 'ENABLE' to insert tokens."), + NoTokensWithTokenMode("%s0 Validation error. Tokens weren't specified for records while 'tokenMode' was %s1. Specify tokens."), + MismatchOfFieldsAndTokens("%s0 Validation error. 'fields' and 'tokens' have different columns names. Verify that 'fields' and 'tokens' columns match."), + InsufficientTokensPassedForTokenModeEnableStrict("%s0 Validation error. 'tokenMode' is set to 'ENABLE_STRICT', but some fields are missing tokens. Specify tokens for all fields."), + BatchInsertPartialSuccess("%s0 Insert operation completed with partial success."), + BatchInsertFailure("%s0 Insert operation failed."), + + // Detokenize + InvalidDetokenizeData("%s0 Validation error. Invalid detokenize data. Specify valid detokenize data."), + EmptyDetokenizeData("%s0 Validation error. Invalid data tokens. Specify at least one data token."), + EmptyTokenInDetokenizeData("%s0 Validation error. Invalid data tokens. Specify a valid data token."), + + // Get + IdsKeyError("%s0 Validation error. 'ids' key is missing from the payload. Specify an 'ids' key."), + EmptyIds("%s0 Validation error. 'ids' can't be empty. Specify at least one id."), + EmptyIdInIds("%s0 Validation error. Invalid id in 'ids'. Specify a valid id."), + EmptyFields("%s0 Validation error. Fields are empty in get payload. Specify at least one field."), + EmptyFieldInFields("%s0 Validation error. Invalid field in 'fields'. Specify a valid field."), + RedactionKeyError("%s0 Validation error. 'redaction' key is missing from the payload. Specify a 'redaction' key."), + RedactionWithTokensNotSupported("%s0 Validation error. 'redaction' can't be used when 'returnTokens' is specified. Remove 'redaction' from payload if 'returnTokens' is specified."), + TokensGetColumnNotSupported("%s0 Validation error. Column name and/or column values can't be used when 'returnTokens' is specified. Remove unique column values or 'returnTokens' from the payload."), + EmptyOffset("%s0 Validation error. 'offset' can't be empty. Specify an offset."), + EmptyLimit("%s0 Validation error. 'limit' can't be empty. Specify a limit."), + UniqueColumnOrIdsKeyError("%s0 Validation error. 'ids' or 'columnName' key is missing from the payload. Specify the ids or unique 'columnName' in payload."), + BothIdsAndColumnDetailsSpecified("%s0 Validation error. Both Skyflow IDs and column details can't be specified. Either specify Skyflow IDs or unique column details."), + ColumnNameKeyError("%s0 Validation error. 'columnName' isn't specified whereas 'columnValues' are specified. Either add 'columnName' or remove 'columnValues'."), + EmptyColumnName("%s0 Validation error. 'columnName' can't be empty. Specify a column name."), + ColumnValuesKeyErrorGet("%s0 Validation error. 'columnValues' aren't specified whereas 'columnName' is specified. Either add 'columnValues' or remove 'columnName'."), + EmptyColumnValues("%s0 Validation error. 'columnValues' can't be empty. Specify at least one column value"), + EmptyValueInColumnValues("%s0 Validation error. Invalid value in column values. Specify a valid column value."), + + TokenKeyError("%s0 Validation error. 'token' key is missing from the payload. Specify a 'token' key."), + PartialSuccess("%s0 Validation error. Check 'SkyflowError.data' for details."), + + // Update + DataKeyError("%s0 Validation error. 'data' key is missing from the payload. Specify a 'data' key."), + EmptyData("%s0 Validation error. 'data' can't be empty. Specify data."), + SkyflowIdKeyError("%s0 Validation error. 'skyflow_id' is missing from the data payload. Specify a 'skyflow_id'."), + InvalidSkyflowIdType("%s0 Validation error. Invalid type for 'skyflow_id' in data payload. Specify 'skyflow_id' as a string."), + EmptySkyflowId("%s0 Validation error. 'skyflow_id' can't be empty. Specify a skyflow id."), + + // Query + QueryKeyError("%s0 Validation error. 'query' key is missing from the payload. Specify a 'query' key."), + EmptyQuery("%s0 Validation error. 'query' can't be empty. Specify a query"), + + // Tokenize + ColumnValuesKeyErrorTokenize("%s0 Validation error. 'columnValues' key is missing from the payload. Specify a 'columnValues' key."), + EmptyColumnGroupInColumnValue("%s0 Validation error. Invalid column group in column value. Specify a valid column group."), + + // Connection + InvalidRequestHeaders("%s0 Validation error. Request headers aren't valid. Specify valid request headers."), + EmptyRequestHeaders("%s0 Validation error. Request headers are empty. Specify valid request headers."), + InvalidPathParams("%s0 Validation error. Path parameters aren't valid. Specify valid path parameters."), + EmptyPathParams("%s0 Validation error. Path parameters are empty. Specify valid path parameters."), + InvalidQueryParams("%s0 Validation error. Query parameters aren't valid. Specify valid query parameters."), + EmptyQueryParams("%s0 Validation error. Query parameters are empty. Specify valid query parameters."), + 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."), + + // 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."), + + //Detect Files + InvalidNullFileInDeIdentifyFile("%s0 Validation error. The file field is required and must not be null. Specify a valid file object."), + InvalidFilePath("%s0 Validation error. The file path is invalid. Specify a valid file path."), + BothFileAndFilePathProvided("%s0 Validation error. Both file and filePath are provided. Specify either file object or filePath, not both."), + FileNotFoundToDeidentify("%s0 Validation error. The file to deidentify was not found at the specified path. Verify the file path and try again."), + FileNotReadableToDeidentify("%s0 Validation error. The file to deidentify is not readable. Check the file permissions and try again."), + InvalidPixelDensityToDeidentifyFile("%s0 Validation error. Should be a positive integer. Specify a valid pixel density."), + InvalidMaxResolution("%s0 Validation error. Should be a positive integer. Specify a valid max resolution."), + OutputDirectoryNotFound("%s0 Validation error. The output directory for deidentified files was not found at the specified path. Verify the output directory path and try again."), + InvalidPermission("%s0 Validation error. The output directory for deidentified files is not writable. Check the directory permissions and try again."), + InvalidWaitTime("%s0 Validation error. The wait time for deidentify file operation should be a positive integer. Specify a valid wait time."), + WaitTimeExceedsLimit("%s0 Validation error. The wait time for deidentify file operation exceeds the maximum limit of 64 seconds. Specify a wait time less than or equal to 60 seconds."), + InvalidOrEmptyRunId("%s0 Validation error. The run ID is invalid or empty. Specify a valid run ID."), + 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."), + 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."), + // Generic + ErrorOccurred("%s0 API error. Error occurred.") + ; + private final String message; + + ErrorMessage(String message) { + this.message = message.replace("%s0", Constants.SDK_PREFIX); + } + + public String getMessage() { + return message; + } +} diff --git a/v2/src/main/java/com/skyflow/errors/HttpStatus.java b/v2/src/main/java/com/skyflow/errors/HttpStatus.java new file mode 100644 index 00000000..2cdadbb0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/errors/HttpStatus.java @@ -0,0 +1,15 @@ +package com.skyflow.errors; + +public enum HttpStatus { + BAD_REQUEST("Bad Request"); + + private final String httpStatus; + + HttpStatus(String httpStatus) { + this.httpStatus = httpStatus; + } + + public String getHttpStatus() { + return httpStatus; + } +} diff --git a/v2/src/main/java/com/skyflow/errors/SkyflowException.java b/v2/src/main/java/com/skyflow/errors/SkyflowException.java new file mode 100644 index 00000000..32c71f39 --- /dev/null +++ b/v2/src/main/java/com/skyflow/errors/SkyflowException.java @@ -0,0 +1,135 @@ +package com.skyflow.errors; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.skyflow.utils.Constants; + +import java.util.List; +import java.util.Map; + +public class SkyflowException extends Exception { + private String requestId; + private Integer grpcCode; + private Integer httpCode; + private String message; + private String httpStatus; + private JsonArray details; + private JsonObject responseBody; + + public SkyflowException(String message) { + super(message); + this.message = message; + } + + public SkyflowException(Throwable cause) { + super(cause); + this.message = cause.getMessage(); + } + + public SkyflowException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public SkyflowException(int code, String message) { + super(message); + this.httpCode = code; + this.message = message; + this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); + this.details = new JsonArray(); + } + + public SkyflowException(int httpCode, Throwable cause, Map> responseHeaders, String responseBody) { + super(cause); + this.httpCode = httpCode > 0 ? httpCode : 400; + try { + setRequestId(responseHeaders); + setResponseBody(responseBody, responseHeaders); + } catch (Exception e) { + this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); + String fullMessage = responseBody != null ? responseBody : + (cause.getLocalizedMessage() != null ? cause.getMessage() : ErrorMessage.ErrorOccurred.getMessage()); + this.message = fullMessage.split("HTTP response code:")[0].trim(); + } + } + + private void setResponseBody(String responseBody, Map> responseHeaders) { + this.responseBody = JsonParser.parseString(responseBody).getAsJsonObject(); + if (this.responseBody.get("error") != null) { + setGrpcCode(); + setHttpStatus(); + setMessage(); + setDetails(responseHeaders); + } + } + + public String getRequestId() { + return requestId; + } + + private void setRequestId(Map> responseHeaders) { + List ids = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY); + this.requestId = ids == null ? null : ids.get(0); + } + + private void setMessage() { + JsonElement messageElement = ((JsonObject) responseBody.get("error")).get("message"); + this.message = messageElement == null ? null : messageElement.getAsString(); + } + + private void setGrpcCode() { + JsonElement grpcElement = ((JsonObject) responseBody.get("error")).get("grpc_code"); + this.grpcCode = grpcElement == null ? null : grpcElement.getAsInt(); + } + + private void setHttpStatus() { + JsonElement statusElement = ((JsonObject) responseBody.get("error")).get("http_status"); + this.httpStatus = statusElement == null ? null : statusElement.getAsString(); + } + + public int getHttpCode() { + return httpCode; + } + + public JsonArray getDetails() { + return details; + } + + private void setDetails(Map> responseHeaders) { + JsonElement detailsElement = ((JsonObject) responseBody.get("error")).get("details"); + List errorFromClientHeader = responseHeaders.get(Constants.ERROR_FROM_CLIENT_HEADER_KEY); + if (detailsElement != null) { + this.details = detailsElement.getAsJsonArray(); + } + if (errorFromClientHeader != null) { + this.details = this.details == null ? new JsonArray() : this.details; + String errorFromClient = errorFromClientHeader.get(0); + JsonObject detailObject = new JsonObject(); + detailObject.addProperty("errorFromClient", errorFromClient); + this.details.add(detailObject); + } + } + + public Integer getGrpcCode() { + return grpcCode; + } + + public String getHttpStatus() { + return httpStatus; + } + + @Override + public String getMessage() { + return message; + } + + @Override + public String toString() { + return String.format( + "%n requestId: %s%n grpcCode: %s%n httpCode: %s%n httpStatus: %s%n message: %s%n details: %s", + this.requestId, this.grpcCode, this.httpCode, this.httpStatus, this.message, this.details + ); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/ApiClient.java b/v2/src/main/java/com/skyflow/generated/rest/ApiClient.java new file mode 100644 index 00000000..296a553f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/ApiClient.java @@ -0,0 +1,92 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Suppliers; +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.query.QueryClient; +import com.skyflow.generated.rest.resources.records.RecordsClient; +import com.skyflow.generated.rest.resources.strings.StringsClient; +import com.skyflow.generated.rest.resources.tokens.TokensClient; +import java.util.function.Supplier; + +public class ApiClient { + protected final ClientOptions clientOptions; + + protected final Supplier auditClient; + + protected final Supplier binLookupClient; + + protected final Supplier recordsClient; + + protected final Supplier tokensClient; + + protected final Supplier queryClient; + + protected final Supplier authenticationClient; + + protected final Supplier deprecatedClient; + + protected final Supplier stringsClient; + + protected final Supplier filesClient; + + public ApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.auditClient = Suppliers.memoize(() -> new AuditClient(clientOptions)); + this.binLookupClient = Suppliers.memoize(() -> new BinLookupClient(clientOptions)); + this.recordsClient = Suppliers.memoize(() -> new RecordsClient(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.stringsClient = Suppliers.memoize(() -> new StringsClient(clientOptions)); + this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions)); + } + + public AuditClient audit() { + return this.auditClient.get(); + } + + public BinLookupClient binLookup() { + return this.binLookupClient.get(); + } + + public RecordsClient records() { + return this.recordsClient.get(); + } + + public TokensClient tokens() { + return this.tokensClient.get(); + } + + public QueryClient query() { + return this.queryClient.get(); + } + + public AuthenticationClient authentication() { + return this.authenticationClient.get(); + } + + public DeprecatedClient deprecated() { + return this.deprecatedClient.get(); + } + + public StringsClient strings() { + return this.stringsClient.get(); + } + + public FilesClient files() { + return this.filesClient.get(); + } + + public static ApiClientBuilder builder() { + return new ApiClientBuilder(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java b/v2/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java new file mode 100644 index 00000000..b361812a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Environment; +import okhttp3.OkHttpClient; + +public final class ApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private String token = null; + + private Environment environment = Environment.PRODUCTION; + + /** + * Sets token + */ + public ApiClientBuilder token(String token) { + this.token = token; + return this; + } + + public ApiClientBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public ApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public ApiClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public ApiClientBuilder maxRetries(int maxRetries) { + this.clientOptionsBuilder.maxRetries(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public ApiClientBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public ApiClient build() { + if (token == null) { + throw new RuntimeException("Please provide token"); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + clientOptionsBuilder.environment(this.environment); + return new ApiClient(clientOptionsBuilder.build()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java b/v2/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java new file mode 100644 index 00000000..d36c8141 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java @@ -0,0 +1,92 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Suppliers; +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.query.AsyncQueryClient; +import com.skyflow.generated.rest.resources.records.AsyncRecordsClient; +import com.skyflow.generated.rest.resources.strings.AsyncStringsClient; +import com.skyflow.generated.rest.resources.tokens.AsyncTokensClient; +import java.util.function.Supplier; + +public class AsyncApiClient { + protected final ClientOptions clientOptions; + + protected final Supplier auditClient; + + protected final Supplier binLookupClient; + + protected final Supplier recordsClient; + + protected final Supplier tokensClient; + + protected final Supplier queryClient; + + protected final Supplier authenticationClient; + + protected final Supplier deprecatedClient; + + protected final Supplier stringsClient; + + protected final Supplier filesClient; + + public AsyncApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.auditClient = Suppliers.memoize(() -> new AsyncAuditClient(clientOptions)); + this.binLookupClient = Suppliers.memoize(() -> new AsyncBinLookupClient(clientOptions)); + this.recordsClient = Suppliers.memoize(() -> new AsyncRecordsClient(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.stringsClient = Suppliers.memoize(() -> new AsyncStringsClient(clientOptions)); + this.filesClient = Suppliers.memoize(() -> new AsyncFilesClient(clientOptions)); + } + + public AsyncAuditClient audit() { + return this.auditClient.get(); + } + + public AsyncBinLookupClient binLookup() { + return this.binLookupClient.get(); + } + + public AsyncRecordsClient records() { + return this.recordsClient.get(); + } + + public AsyncTokensClient tokens() { + return this.tokensClient.get(); + } + + public AsyncQueryClient query() { + return this.queryClient.get(); + } + + public AsyncAuthenticationClient authentication() { + return this.authenticationClient.get(); + } + + public AsyncDeprecatedClient deprecated() { + return this.deprecatedClient.get(); + } + + public AsyncStringsClient strings() { + return this.stringsClient.get(); + } + + public AsyncFilesClient files() { + return this.filesClient.get(); + } + + public static AsyncApiClientBuilder builder() { + return new AsyncApiClientBuilder(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java b/v2/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java new file mode 100644 index 00000000..8e4b8474 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Environment; +import okhttp3.OkHttpClient; + +public final class AsyncApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private String token = null; + + private Environment environment = Environment.PRODUCTION; + + /** + * Sets token + */ + public AsyncApiClientBuilder token(String token) { + this.token = token; + return this; + } + + public AsyncApiClientBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public AsyncApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public AsyncApiClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public AsyncApiClientBuilder maxRetries(int maxRetries) { + this.clientOptionsBuilder.maxRetries(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public AsyncApiClientBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public AsyncApiClient build() { + if (token == null) { + throw new RuntimeException("Please provide token"); + } + this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); + clientOptionsBuilder.environment(this.environment); + return new AsyncApiClient(clientOptionsBuilder.build()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java b/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java new file mode 100644 index 00000000..4fab1d41 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class ApiClientApiException extends ApiClientException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + private final Map> headers; + + public ApiClientApiException(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + } + + public ApiClientApiException(String message, int statusCode, Object body, Response rawResponse) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + /** + * @return the headers + */ + public Map> headers() { + return this.headers; + } + + @Override + public String toString() { + return "ApiClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + + "}"; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java b/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java new file mode 100644 index 00000000..7987eba6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +/** + * This class serves as the base exception for all errors in the SDK. + */ +public class ApiClientException extends RuntimeException { + public ApiClientException(String message) { + super(message); + } + + public ApiClientException(String message, Exception e) { + super(message, e); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java b/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java new file mode 100644 index 00000000..9c81f1f5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + +public final class ApiClientHttpResponse { + + private final T body; + + private final Map> headers; + + public ApiClientHttpResponse(T body, Response rawResponse) { + this.body = body; + + Map> headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + this.headers = headers; + } + + public T body() { + return this.body; + } + + public Map> headers() { + return headers; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java b/v2/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java new file mode 100644 index 00000000..badaddd3 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final int timeout; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + int timeout) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("X-Fern-Language", "JAVA"); + put("X-Fern-SDK-Name", "com.skyflow.fern:api-sdk"); + put("X-Fern-SDK-Version", "0.0.219"); + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.timeout = timeout; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int maxRetries = 2; + + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { + this.timeout = timeout; + return this; + } + + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + public ClientOptions build() { + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor(this.maxRetries)); + } + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java b/v2/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java new file mode 100644 index 00000000..6be10979 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQueries; + +/** + * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. + */ +class DateTimeDeserializer extends JsonDeserializer { + private static final SimpleModule MODULE; + + static { + MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); + } + + /** + * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. + * + * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. + */ + public static SimpleModule getModule() { + return MODULE; + } + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonToken token = parser.currentToken(); + if (token == JsonToken.VALUE_NUMBER_INT) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); + } else { + TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( + parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); + + if (temporal.query(TemporalQueries.offset()) == null) { + return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); + } else { + return OffsetDateTime.from(temporal); + } + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/Environment.java b/v2/src/main/java/com/skyflow/generated/rest/core/Environment.java new file mode 100644 index 00000000..c0adb233 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/Environment.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +public final class Environment { + public static final Environment PRODUCTION = new Environment("https://identifier.vault.skyflowapis.com"); + + public static final Environment SANDBOX = new Environment("https://identifier.vault.skyflowapis-preview.com"); + + private final String url; + + private Environment(String url) { + this.url = url; + } + + public String getUrl() { + return this.url; + } + + public static Environment custom(String url) { + return new Environment(url); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/FileStream.java b/v2/src/main/java/com/skyflow/generated/rest/core/FileStream.java new file mode 100644 index 00000000..6b459431 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/FileStream.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a file stream with associated metadata for file uploads. + */ +public class FileStream { + private final InputStream inputStream; + private final String fileName; + private final MediaType contentType; + + /** + * Constructs a FileStream with the given input stream and optional metadata. + * + * @param inputStream The input stream of the file content. Must not be null. + * @param fileName The name of the file, or null if unknown. + * @param contentType The MIME type of the file content, or null if unknown. + * @throws NullPointerException if inputStream is null + */ + public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { + this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); + this.fileName = fileName; + this.contentType = contentType; + } + + public FileStream(InputStream inputStream) { + this(inputStream, null, null); + } + + public InputStream getInputStream() { + return inputStream; + } + + @Nullable + public String getFileName() { + return fileName; + } + + @Nullable + public MediaType getContentType() { + return contentType; + } + + /** + * Creates a RequestBody suitable for use with OkHttp client. + * + * @return A RequestBody instance representing this file stream. + */ + public RequestBody toRequestBody() { + return new InputStreamRequestBody(contentType, inputStream); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java b/v2/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java new file mode 100644 index 00000000..545f6088 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.internal.Util; +import okio.BufferedSink; +import okio.Okio; +import okio.Source; +import org.jetbrains.annotations.Nullable; + +/** + * A custom implementation of OkHttp's RequestBody that wraps an InputStream. + * This class allows streaming of data from an InputStream directly to an HTTP request body, + * which is useful for file uploads or sending large amounts of data without loading it all into memory. + */ +public class InputStreamRequestBody extends RequestBody { + private final InputStream inputStream; + private final MediaType contentType; + + /** + * Constructs an InputStreamRequestBody with the specified content type and input stream. + * + * @param contentType the MediaType of the content, or null if not known + * @param inputStream the InputStream containing the data to be sent + * @throws NullPointerException if inputStream is null + */ + public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { + this.contentType = contentType; + this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); + } + + /** + * Returns the content type of this request body. + * + * @return the MediaType of the content, or null if not specified + */ + @Nullable + @Override + public MediaType contentType() { + return contentType; + } + + /** + * Returns the content length of this request body, if known. + * This method attempts to determine the length using the InputStream's available() method, + * which may not always accurately reflect the total length of the stream. + * + * @return the content length, or -1 if the length is unknown + * @throws IOException if an I/O error occurs + */ + @Override + public long contentLength() throws IOException { + return inputStream.available() == 0 ? -1 : inputStream.available(); + } + + /** + * Writes the content of the InputStream to the given BufferedSink. + * This method is responsible for transferring the data from the InputStream to the network request. + * + * @param sink the BufferedSink to write the content to + * @throws IOException if an I/O error occurs during writing + */ + @Override + public void writeTo(BufferedSink sink) throws IOException { + Source source = null; + try { + source = Okio.source(inputStream); + sink.writeAll(source); + } finally { + Util.closeQuietly(Objects.requireNonNull(source)); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java b/v2/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java new file mode 100644 index 00000000..11714cb8 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/Nullable.java b/v2/src/main/java/com/skyflow/generated/rest/core/Nullable.java new file mode 100644 index 00000000..5929c12d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/Nullable.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.Optional; +import java.util.function.Function; + +public final class Nullable { + + private final Either, Null> value; + + private Nullable() { + this.value = Either.left(Optional.empty()); + } + + private Nullable(T value) { + if (value == null) { + this.value = Either.right(Null.INSTANCE); + } else { + this.value = Either.left(Optional.of(value)); + } + } + + public static Nullable ofNull() { + return new Nullable<>(null); + } + + public static Nullable of(T value) { + return new Nullable<>(value); + } + + public static Nullable empty() { + return new Nullable<>(); + } + + public static Nullable ofOptional(Optional value) { + if (value.isPresent()) { + return of(value.get()); + } else { + return empty(); + } + } + + public boolean isNull() { + return this.value.isRight(); + } + + public boolean isEmpty() { + return this.value.isLeft() && !this.value.getLeft().isPresent(); + } + + public T get() { + if (this.isNull()) { + return null; + } + + return this.value.getLeft().get(); + } + + public Nullable map(Function mapper) { + if (this.isNull()) { + return Nullable.ofNull(); + } + + return Nullable.ofOptional(this.value.getLeft().map(mapper)); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Nullable)) { + return false; + } + + if (((Nullable) other).isNull() && this.isNull()) { + return true; + } + + return this.value.getLeft().equals(((Nullable) other).value.getLeft()); + } + + private static final class Either { + private L left = null; + private R right = null; + + private Either(L left, R right) { + if (left != null && right != null) { + throw new IllegalArgumentException("Left and right argument cannot both be non-null."); + } + + if (left == null && right == null) { + throw new IllegalArgumentException("Left and right argument cannot both be null."); + } + + if (left != null) { + this.left = left; + } + + if (right != null) { + this.right = right; + } + } + + public static Either left(L left) { + return new Either<>(left, null); + } + + public static Either right(R right) { + return new Either<>(null, right); + } + + public boolean isLeft() { + return this.left != null; + } + + public boolean isRight() { + return this.right != null; + } + + public L getLeft() { + if (!this.isLeft()) { + throw new IllegalArgumentException("Cannot get left from right Either."); + } + return this.left; + } + + public R getRight() { + if (!this.isRight()) { + throw new IllegalArgumentException("Cannot get right from left Either."); + } + return this.right; + } + } + + private static final class Null { + private static final Null INSTANCE = new Null(); + + private Null() {} + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java b/v2/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java new file mode 100644 index 00000000..98c33be4 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.Optional; + +public final class NullableNonemptyFilter { + @Override + public boolean equals(Object o) { + boolean isOptionalEmpty = isOptionalEmpty(o); + + return isOptionalEmpty; + } + + private boolean isOptionalEmpty(Object o) { + return o instanceof Optional && !((Optional) o).isPresent(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java b/v2/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java new file mode 100644 index 00000000..3b7894e0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.IOException; + +public final class ObjectMappers { + public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .addModule(new JavaTimeModule()) + .addModule(DateTimeDeserializer.getModule()) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + private ObjectMappers() {} + + public static String stringify(Object o) { + try { + return JSON_MAPPER + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .writerWithDefaultPrettyPrinter() + .writeValueAsString(o); + } catch (IOException e) { + return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java b/v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java new file mode 100644 index 00000000..e9e18fb9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import okhttp3.MultipartBody; + +public class QueryStringMapper { + + private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; + + public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + httpUrl.addQueryParameter(key, valueNode.textValue()); + } else { + httpUrl.addQueryParameter(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); + } else { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); + } + } + } + + public static void addFormDataPart( + MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + multipartBody.addFormDataPart(key, valueNode.textValue()); + } else { + multipartBody.addFormDataPart(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().textValue()); + } else { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().toString()); + } + } + } + + public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator> fields = object.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + + String key = "[" + field.getKey() + "]"; + + if (field.getValue().isObject()) { + List> flatField = + flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); + addAll(flat, flatField, key); + } else if (field.getValue().isArray()) { + List> flatField = + flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); + addAll(flat, flatField, ""); + } else { + flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); + } + } + + return flat; + } + + private static List> flattenArray( + ArrayNode array, String key, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator elements = array.elements(); + + int index = 0; + while (elements.hasNext()) { + JsonNode element = elements.next(); + + String indexKey = key + "[" + index + "]"; + + if (arraysAsRepeats) { + indexKey = key; + } + + if (element.isObject()) { + List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else if (element.isArray()) { + List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else { + flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); + } + + index++; + } + + return flat; + } + + private static void addAll( + List> target, List> source, String prefix) { + for (Map.Entry entry : source) { + Map.Entry entryToAdd = + new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); + target.add(entryToAdd); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java b/v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java new file mode 100644 index 00000000..c5728721 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java @@ -0,0 +1,339 @@ +/** + * 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/v2/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java b/v2/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java new file mode 100644 index 00000000..edc6d0ae --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +public final class RequestOptions { + private final String token; + + private final Optional timeout; + + private final TimeUnit timeoutTimeUnit; + + private final Map headers; + + private final Map> headerSuppliers; + + private RequestOptions( + String token, + Optional timeout, + TimeUnit timeoutTimeUnit, + Map headers, + Map> headerSuppliers) { + this.token = token; + this.timeout = timeout; + this.timeoutTimeUnit = timeoutTimeUnit; + this.headers = headers; + this.headerSuppliers = headerSuppliers; + } + + public Optional getTimeout() { + return timeout; + } + + public TimeUnit getTimeoutTimeUnit() { + return timeoutTimeUnit; + } + + public Map getHeaders() { + Map headers = new HashMap<>(); + if (this.token != null) { + headers.put("Authorization", "Bearer " + this.token); + } + headers.putAll(this.headers); + this.headerSuppliers.forEach((key, supplier) -> { + headers.put(key, supplier.get()); + }); + return headers; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private String token = null; + + private Optional timeout = Optional.empty(); + + private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + public Builder token(String token) { + this.token = token; + return this; + } + + public Builder timeout(Integer timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { + this.timeout = Optional.of(timeout); + this.timeoutTimeUnit = timeoutTimeUnit; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + public RequestOptions build() { + return new RequestOptions(token, timeout, timeoutTimeUnit, headers, headerSuppliers); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java b/v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java new file mode 100644 index 00000000..d8df7715 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.io.FilterInputStream; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the stream is closed. + * + * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. + * It retrieves the InputStream from the Response and overrides the close method to close + * both the InputStream and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyInputStream extends FilterInputStream { + private final Response response; + + /** + * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp + * Response object. + * + * @param response the OkHttp Response object from which the InputStream is retrieved + * @throws IOException if an I/O error occurs while retrieving the InputStream + */ + public ResponseBodyInputStream(Response response) throws IOException { + super(response.body().byteStream()); + this.response = response; + } + + /** + * Closes the InputStream and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the stream is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the stream is closed + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java b/v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java new file mode 100644 index 00000000..ed894407 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.io.FilterReader; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the reader is closed. + * + * This class extends FilterReader and takes an OkHttp Response object as a parameter. + * It retrieves the Reader from the Response and overrides the close method to close + * both the Reader and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyReader extends FilterReader { + private final Response response; + + /** + * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. + * + * @param response the OkHttp Response object from which the Reader is retrieved + * @throws IOException if an I/O error occurs while retrieving the Reader + */ + public ResponseBodyReader(Response response) throws IOException { + super(response.body().charStream()); + this.response = response; + } + + /** + * Closes the Reader and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the reader is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the reader is closed + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java b/v2/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java new file mode 100644 index 00000000..eda7d265 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java @@ -0,0 +1,78 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.io.IOException; +import java.time.Duration; +import java.util.Optional; +import java.util.Random; +import okhttp3.Interceptor; +import okhttp3.Response; + +public class RetryInterceptor implements Interceptor { + + private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private final ExponentialBackoff backoff; + private final Random random = new Random(); + + public RetryInterceptor(int maxRetries) { + this.backoff = new ExponentialBackoff(maxRetries); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Response response = chain.proceed(chain.request()); + + if (shouldRetry(response.code())) { + return retryChain(response, chain); + } + + return response; + } + + private Response retryChain(Response response, Chain chain) throws IOException { + Optional nextBackoff = this.backoff.nextBackoff(); + while (nextBackoff.isPresent()) { + try { + Thread.sleep(nextBackoff.get().toMillis()); + } catch (InterruptedException e) { + throw new IOException("Interrupted while trying request", e); + } + response.close(); + response = chain.proceed(chain.request()); + if (shouldRetry(response.code())) { + nextBackoff = this.backoff.nextBackoff(); + } else { + return response; + } + } + + return response; + } + + private static boolean shouldRetry(int statusCode) { + return statusCode == 408 || statusCode == 429 || statusCode >= 500; + } + + private final class ExponentialBackoff { + + private final int maxNumRetries; + + private int retryNumber = 0; + + ExponentialBackoff(int maxNumRetries) { + this.maxNumRetries = maxNumRetries; + } + + public Optional nextBackoff() { + retryNumber += 1; + if (retryNumber > maxNumRetries) { + return Optional.empty(); + } + + int upperBound = (int) Math.pow(2, retryNumber); + return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/Stream.java b/v2/src/main/java/com/skyflow/generated/rest/core/Stream.java new file mode 100644 index 00000000..f037712a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/Stream.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.io.Reader; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Scanner; + +/** + * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing + * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. + *

+ * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a + * {@code Scanner} to block during iteration if the next object is not available. + * + * @param The type of objects in the stream. + */ +public final class Stream implements Iterable { + /** + * The {@link Class} of the objects in the stream. + */ + private final Class valueType; + /** + * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. + */ + private final Scanner scanner; + + /** + * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. + * + * @param valueType The class of the objects in the stream. + * @param reader The reader that provides the streamed data. + * @param delimiter The delimiter used to separate elements in the stream. + */ + public Stream(Class valueType, Reader reader, String delimiter) { + this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.valueType = valueType; + } + + /** + * Returns an iterator over the elements in this stream that blocks during iteration when the next object is + * not yet available. + * + * @return An iterator that can be used to traverse the elements in the stream. + */ + @Override + public Iterator iterator() { + return new Iterator() { + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Removing elements from {@code Stream} is not supported. + * + * @throws UnsupportedOperationException Always, as removal is not supported. + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/core/Suppliers.java b/v2/src/main/java/com/skyflow/generated/rest/core/Suppliers.java new file mode 100644 index 00000000..307d5852 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/core/Suppliers.java @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.core; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public final class Suppliers { + private Suppliers() {} + + public static Supplier memoize(Supplier delegate) { + AtomicReference value = new AtomicReference<>(); + return () -> { + T val = value.get(); + if (val == null) { + val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); + } + return val; + }; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java b/v2/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java new file mode 100644 index 00000000..80ae5e7c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.errors; + +import com.skyflow.generated.rest.core.ApiClientApiException; +import okhttp3.Response; + +public final class BadRequestError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public BadRequestError(Object body) { + super("BadRequestError", 400, body); + this.body = body; + } + + public BadRequestError(Object body, Response rawResponse) { + super("BadRequestError", 400, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @Override + public Object body() { + return this.body; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java b/v2/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java new file mode 100644 index 00000000..ffeed9d7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.errors; + +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.types.ErrorResponse; +import okhttp3.Response; + +public final class InternalServerError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final ErrorResponse body; + + public InternalServerError(ErrorResponse body) { + super("InternalServerError", 500, body); + this.body = body; + } + + public InternalServerError(ErrorResponse body, Response rawResponse) { + super("InternalServerError", 500, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @Override + public ErrorResponse body() { + return this.body; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java b/v2/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java new file mode 100644 index 00000000..1d0a6ad0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.errors; + +import com.skyflow.generated.rest.core.ApiClientApiException; +import okhttp3.Response; + +public final class NotFoundError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public NotFoundError(Object body) { + super("NotFoundError", 404, body); + this.body = body; + } + + public NotFoundError(Object body, Response rawResponse) { + super("NotFoundError", 404, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @Override + public Object body() { + return this.body; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java b/v2/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java new file mode 100644 index 00000000..3bc254bc --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.errors; + +import com.skyflow.generated.rest.core.ApiClientApiException; +import okhttp3.Response; + +public final class UnauthorizedError extends ApiClientApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public UnauthorizedError(Object body) { + super("UnauthorizedError", 401, body); + this.body = body; + } + + public UnauthorizedError(Object body, Response rawResponse) { + super("UnauthorizedError", 401, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @Override + public Object body() { + return this.body; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java new file mode 100644 index 00000000..0064558d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.audit.requests.AuditServiceListAuditEventsRequest; +import com.skyflow.generated.rest.types.V1AuditResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncAuditClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAuditClient rawClient; + + public AsyncAuditClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAuditClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAuditClient withRawResponse() { + return this.rawClient; + } + + /** + * Lists audit events that match query parameters. + */ + public CompletableFuture auditServiceListAuditEvents(AuditServiceListAuditEventsRequest request) { + return this.rawClient.auditServiceListAuditEvents(request).thenApply(response -> response.body()); + } + + /** + * Lists audit events that match query parameters. + */ + public CompletableFuture auditServiceListAuditEvents( + AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { + return this.rawClient + .auditServiceListAuditEvents(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java new file mode 100644 index 00000000..e1516eaf --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java @@ -0,0 +1,284 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.rest.core.*; +import com.skyflow.generated.rest.errors.NotFoundError; +import com.skyflow.generated.rest.resources.audit.requests.AuditServiceListAuditEventsRequest; +import com.skyflow.generated.rest.types.V1AuditResponse; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; + +public class AsyncRawAuditClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Lists audit events that match query parameters. + */ + public CompletableFuture> auditServiceListAuditEvents( + AuditServiceListAuditEventsRequest request) { + return auditServiceListAuditEvents(request, null); + } + + /** + * Lists audit events that match query parameters. + */ + public CompletableFuture> auditServiceListAuditEvents( + AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/audit/events"); + if (request.getFilterOpsContextChangeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.changeID", + request.getFilterOpsContextChangeId().get(), + false); + } + if (request.getFilterOpsContextRequestId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.requestID", + request.getFilterOpsContextRequestId().get(), + false); + } + if (request.getFilterOpsContextTraceId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.traceID", + request.getFilterOpsContextTraceId().get(), + false); + } + if (request.getFilterOpsContextSessionId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.sessionID", + request.getFilterOpsContextSessionId().get(), + false); + } + if (request.getFilterOpsContextActor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.actor", + request.getFilterOpsContextActor().get(), + false); + } + if (request.getFilterOpsContextActorType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.actorType", + request.getFilterOpsContextActorType().get(), + false); + } + if (request.getFilterOpsContextAccessType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.accessType", + request.getFilterOpsContextAccessType().get(), + false); + } + if (request.getFilterOpsContextIpAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.ipAddress", + request.getFilterOpsContextIpAddress().get(), + false); + } + if (request.getFilterOpsContextOrigin().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.origin", + request.getFilterOpsContextOrigin().get(), + false); + } + if (request.getFilterOpsContextAuthMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.authMode", + request.getFilterOpsContextAuthMode().get(), + false); + } + if (request.getFilterOpsContextJwtId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.jwtID", + request.getFilterOpsContextJwtId().get(), + false); + } + if (request.getFilterOpsContextBearerTokenContextId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.bearerTokenContextID", + request.getFilterOpsContextBearerTokenContextId().get(), + false); + } + if (request.getFilterOpsParentAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.parentAccountID", + request.getFilterOpsParentAccountId().get(), + false); + } + QueryStringMapper.addQueryParameter(httpUrl, "filterOps.accountID", request.getFilterOpsAccountId(), false); + if (request.getFilterOpsWorkspaceId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.workspaceID", + request.getFilterOpsWorkspaceId().get(), + false); + } + if (request.getFilterOpsVaultId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.vaultID", request.getFilterOpsVaultId().get(), false); + } + if (request.getFilterOpsResourceIDs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.resourceIDs", + request.getFilterOpsResourceIDs().get(), + false); + } + if (request.getFilterOpsActionType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.actionType", + request.getFilterOpsActionType().get(), + false); + } + if (request.getFilterOpsResourceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.resourceType", + request.getFilterOpsResourceType().get(), + false); + } + if (request.getFilterOpsTags().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.tags", request.getFilterOpsTags().get(), false); + } + if (request.getFilterOpsResponseCode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.responseCode", + request.getFilterOpsResponseCode().get(), + false); + } + if (request.getFilterOpsStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.startTime", + request.getFilterOpsStartTime().get(), + false); + } + if (request.getFilterOpsEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.endTime", request.getFilterOpsEndTime().get(), false); + } + if (request.getFilterOpsApiName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.apiName", request.getFilterOpsApiName().get(), false); + } + if (request.getFilterOpsResponseMessage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.responseMessage", + request.getFilterOpsResponseMessage().get(), + false); + } + if (request.getFilterOpsHttpMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.httpMethod", + request.getFilterOpsHttpMethod().get(), + false); + } + if (request.getFilterOpsHttpUri().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.httpURI", request.getFilterOpsHttpUri().get(), false); + } + if (request.getSortOpsSortBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sortOps.sortBy", request.getSortOpsSortBy().get(), false); + } + if (request.getSortOpsOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sortOps.orderBy", request.getSortOpsOrderBy().get(), false); + } + if (request.getAfterOpsTimestamp().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "afterOps.timestamp", + request.getAfterOpsTimestamp().get(), + false); + } + if (request.getAfterOpsChangeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "afterOps.changeID", request.getAfterOpsChangeId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().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(), V1AuditResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java new file mode 100644 index 00000000..bac81431 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.audit.requests.AuditServiceListAuditEventsRequest; +import com.skyflow.generated.rest.types.V1AuditResponse; + +public class AuditClient { + protected final ClientOptions clientOptions; + + private final RawAuditClient rawClient; + + public AuditClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAuditClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditClient withRawResponse() { + return this.rawClient; + } + + /** + * Lists audit events that match query parameters. + */ + public V1AuditResponse auditServiceListAuditEvents(AuditServiceListAuditEventsRequest request) { + return this.rawClient.auditServiceListAuditEvents(request).body(); + } + + /** + * Lists audit events that match query parameters. + */ + public V1AuditResponse auditServiceListAuditEvents( + AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { + return this.rawClient + .auditServiceListAuditEvents(request, requestOptions) + .body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java new file mode 100644 index 00000000..bfec3bf2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java @@ -0,0 +1,277 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit; + +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.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.audit.requests.AuditServiceListAuditEventsRequest; +import com.skyflow.generated.rest.types.V1AuditResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditClient { + protected final ClientOptions clientOptions; + + public RawAuditClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Lists audit events that match query parameters. + */ + public ApiClientHttpResponse auditServiceListAuditEvents( + AuditServiceListAuditEventsRequest request) { + return auditServiceListAuditEvents(request, null); + } + + /** + * Lists audit events that match query parameters. + */ + public ApiClientHttpResponse auditServiceListAuditEvents( + AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/audit/events"); + if (request.getFilterOpsContextChangeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.changeID", + request.getFilterOpsContextChangeId().get(), + false); + } + if (request.getFilterOpsContextRequestId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.requestID", + request.getFilterOpsContextRequestId().get(), + false); + } + if (request.getFilterOpsContextTraceId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.traceID", + request.getFilterOpsContextTraceId().get(), + false); + } + if (request.getFilterOpsContextSessionId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.sessionID", + request.getFilterOpsContextSessionId().get(), + false); + } + if (request.getFilterOpsContextActor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.actor", + request.getFilterOpsContextActor().get(), + false); + } + if (request.getFilterOpsContextActorType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.actorType", + request.getFilterOpsContextActorType().get(), + false); + } + if (request.getFilterOpsContextAccessType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.accessType", + request.getFilterOpsContextAccessType().get(), + false); + } + if (request.getFilterOpsContextIpAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.ipAddress", + request.getFilterOpsContextIpAddress().get(), + false); + } + if (request.getFilterOpsContextOrigin().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.origin", + request.getFilterOpsContextOrigin().get(), + false); + } + if (request.getFilterOpsContextAuthMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.authMode", + request.getFilterOpsContextAuthMode().get(), + false); + } + if (request.getFilterOpsContextJwtId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.jwtID", + request.getFilterOpsContextJwtId().get(), + false); + } + if (request.getFilterOpsContextBearerTokenContextId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.context.bearerTokenContextID", + request.getFilterOpsContextBearerTokenContextId().get(), + false); + } + if (request.getFilterOpsParentAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.parentAccountID", + request.getFilterOpsParentAccountId().get(), + false); + } + QueryStringMapper.addQueryParameter(httpUrl, "filterOps.accountID", request.getFilterOpsAccountId(), false); + if (request.getFilterOpsWorkspaceId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.workspaceID", + request.getFilterOpsWorkspaceId().get(), + false); + } + if (request.getFilterOpsVaultId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.vaultID", request.getFilterOpsVaultId().get(), false); + } + if (request.getFilterOpsResourceIDs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.resourceIDs", + request.getFilterOpsResourceIDs().get(), + false); + } + if (request.getFilterOpsActionType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.actionType", + request.getFilterOpsActionType().get(), + false); + } + if (request.getFilterOpsResourceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.resourceType", + request.getFilterOpsResourceType().get(), + false); + } + if (request.getFilterOpsTags().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.tags", request.getFilterOpsTags().get(), false); + } + if (request.getFilterOpsResponseCode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.responseCode", + request.getFilterOpsResponseCode().get(), + false); + } + if (request.getFilterOpsStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.startTime", + request.getFilterOpsStartTime().get(), + false); + } + if (request.getFilterOpsEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.endTime", request.getFilterOpsEndTime().get(), false); + } + if (request.getFilterOpsApiName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.apiName", request.getFilterOpsApiName().get(), false); + } + if (request.getFilterOpsResponseMessage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.responseMessage", + request.getFilterOpsResponseMessage().get(), + false); + } + if (request.getFilterOpsHttpMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "filterOps.httpMethod", + request.getFilterOpsHttpMethod().get(), + false); + } + if (request.getFilterOpsHttpUri().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "filterOps.httpURI", request.getFilterOpsHttpUri().get(), false); + } + if (request.getSortOpsSortBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sortOps.sortBy", request.getSortOpsSortBy().get(), false); + } + if (request.getSortOpsOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sortOps.orderBy", request.getSortOpsOrderBy().get(), false); + } + if (request.getAfterOpsTimestamp().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "afterOps.timestamp", + request.getAfterOpsTimestamp().get(), + false); + } + if (request.getAfterOpsChangeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "afterOps.changeID", request.getAfterOpsChangeId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().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(), V1AuditResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java new file mode 100644 index 00000000..8b6686e4 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java @@ -0,0 +1,1589 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.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.audit.types.AuditServiceListAuditEventsRequestFilterOpsActionType; +import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsContextAccessType; +import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsContextActorType; +import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsContextAuthMode; +import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsResourceType; +import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestSortOpsOrderBy; +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 = AuditServiceListAuditEventsRequest.Builder.class) +public final class AuditServiceListAuditEventsRequest { + private final Optional filterOpsContextChangeId; + + private final Optional filterOpsContextRequestId; + + private final Optional filterOpsContextTraceId; + + private final Optional filterOpsContextSessionId; + + private final Optional filterOpsContextActor; + + private final Optional filterOpsContextActorType; + + private final Optional filterOpsContextAccessType; + + private final Optional filterOpsContextIpAddress; + + private final Optional filterOpsContextOrigin; + + private final Optional filterOpsContextAuthMode; + + private final Optional filterOpsContextJwtId; + + private final Optional filterOpsContextBearerTokenContextId; + + private final Optional filterOpsParentAccountId; + + private final String filterOpsAccountId; + + private final Optional filterOpsWorkspaceId; + + private final Optional filterOpsVaultId; + + private final Optional filterOpsResourceIDs; + + private final Optional filterOpsActionType; + + private final Optional filterOpsResourceType; + + private final Optional filterOpsTags; + + private final Optional filterOpsResponseCode; + + private final Optional filterOpsStartTime; + + private final Optional filterOpsEndTime; + + private final Optional filterOpsApiName; + + private final Optional filterOpsResponseMessage; + + private final Optional filterOpsHttpMethod; + + private final Optional filterOpsHttpUri; + + private final Optional sortOpsSortBy; + + private final Optional sortOpsOrderBy; + + private final Optional afterOpsTimestamp; + + private final Optional afterOpsChangeId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private AuditServiceListAuditEventsRequest( + Optional filterOpsContextChangeId, + Optional filterOpsContextRequestId, + Optional filterOpsContextTraceId, + Optional filterOpsContextSessionId, + Optional filterOpsContextActor, + Optional filterOpsContextActorType, + Optional filterOpsContextAccessType, + Optional filterOpsContextIpAddress, + Optional filterOpsContextOrigin, + Optional filterOpsContextAuthMode, + Optional filterOpsContextJwtId, + Optional filterOpsContextBearerTokenContextId, + Optional filterOpsParentAccountId, + String filterOpsAccountId, + Optional filterOpsWorkspaceId, + Optional filterOpsVaultId, + Optional filterOpsResourceIDs, + Optional filterOpsActionType, + Optional filterOpsResourceType, + Optional filterOpsTags, + Optional filterOpsResponseCode, + Optional filterOpsStartTime, + Optional filterOpsEndTime, + Optional filterOpsApiName, + Optional filterOpsResponseMessage, + Optional filterOpsHttpMethod, + Optional filterOpsHttpUri, + Optional sortOpsSortBy, + Optional sortOpsOrderBy, + Optional afterOpsTimestamp, + Optional afterOpsChangeId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.filterOpsContextChangeId = filterOpsContextChangeId; + this.filterOpsContextRequestId = filterOpsContextRequestId; + this.filterOpsContextTraceId = filterOpsContextTraceId; + this.filterOpsContextSessionId = filterOpsContextSessionId; + this.filterOpsContextActor = filterOpsContextActor; + this.filterOpsContextActorType = filterOpsContextActorType; + this.filterOpsContextAccessType = filterOpsContextAccessType; + this.filterOpsContextIpAddress = filterOpsContextIpAddress; + this.filterOpsContextOrigin = filterOpsContextOrigin; + this.filterOpsContextAuthMode = filterOpsContextAuthMode; + this.filterOpsContextJwtId = filterOpsContextJwtId; + this.filterOpsContextBearerTokenContextId = filterOpsContextBearerTokenContextId; + this.filterOpsParentAccountId = filterOpsParentAccountId; + this.filterOpsAccountId = filterOpsAccountId; + this.filterOpsWorkspaceId = filterOpsWorkspaceId; + this.filterOpsVaultId = filterOpsVaultId; + this.filterOpsResourceIDs = filterOpsResourceIDs; + this.filterOpsActionType = filterOpsActionType; + this.filterOpsResourceType = filterOpsResourceType; + this.filterOpsTags = filterOpsTags; + this.filterOpsResponseCode = filterOpsResponseCode; + this.filterOpsStartTime = filterOpsStartTime; + this.filterOpsEndTime = filterOpsEndTime; + this.filterOpsApiName = filterOpsApiName; + this.filterOpsResponseMessage = filterOpsResponseMessage; + this.filterOpsHttpMethod = filterOpsHttpMethod; + this.filterOpsHttpUri = filterOpsHttpUri; + this.sortOpsSortBy = sortOpsSortBy; + this.sortOpsOrderBy = sortOpsOrderBy; + this.afterOpsTimestamp = afterOpsTimestamp; + this.afterOpsChangeId = afterOpsChangeId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID for the audit event. + */ + @JsonProperty("filterOps.context.changeID") + public Optional getFilterOpsContextChangeId() { + return filterOpsContextChangeId; + } + + /** + * @return ID for the request that caused the event. + */ + @JsonProperty("filterOps.context.requestID") + public Optional getFilterOpsContextRequestId() { + return filterOpsContextRequestId; + } + + /** + * @return ID for the request set by the service that received the request. + */ + @JsonProperty("filterOps.context.traceID") + public Optional getFilterOpsContextTraceId() { + return filterOpsContextTraceId; + } + + /** + * @return ID for the session in which the request was sent. + */ + @JsonProperty("filterOps.context.sessionID") + public Optional getFilterOpsContextSessionId() { + return filterOpsContextSessionId; + } + + /** + * @return Member who sent the request. Depending on actorType, this may be a user ID or a service account ID. + */ + @JsonProperty("filterOps.context.actor") + public Optional getFilterOpsContextActor() { + return filterOpsContextActor; + } + + /** + * @return Type of member who sent the request. + */ + @JsonProperty("filterOps.context.actorType") + public Optional getFilterOpsContextActorType() { + return filterOpsContextActorType; + } + + /** + * @return Type of access for the request. + */ + @JsonProperty("filterOps.context.accessType") + public Optional getFilterOpsContextAccessType() { + return filterOpsContextAccessType; + } + + /** + * @return IP Address of the client that made the request. + */ + @JsonProperty("filterOps.context.ipAddress") + public Optional getFilterOpsContextIpAddress() { + return filterOpsContextIpAddress; + } + + /** + * @return HTTP Origin request header (including scheme, hostname, and port) of the request. + */ + @JsonProperty("filterOps.context.origin") + public Optional getFilterOpsContextOrigin() { + return filterOpsContextOrigin; + } + + /** + * @return Authentication mode the actor used. + */ + @JsonProperty("filterOps.context.authMode") + public Optional getFilterOpsContextAuthMode() { + return filterOpsContextAuthMode; + } + + /** + * @return ID of the JWT token. + */ + @JsonProperty("filterOps.context.jwtID") + public Optional getFilterOpsContextJwtId() { + return filterOpsContextJwtId; + } + + /** + * @return Embedded User Context. + */ + @JsonProperty("filterOps.context.bearerTokenContextID") + public Optional getFilterOpsContextBearerTokenContextId() { + return filterOpsContextBearerTokenContextId; + } + + /** + * @return Resources with the specified parent account ID. + */ + @JsonProperty("filterOps.parentAccountID") + public Optional getFilterOpsParentAccountId() { + return filterOpsParentAccountId; + } + + /** + * @return Resources with the specified account ID. + */ + @JsonProperty("filterOps.accountID") + public String getFilterOpsAccountId() { + return filterOpsAccountId; + } + + /** + * @return Resources with the specified workspace ID. + */ + @JsonProperty("filterOps.workspaceID") + public Optional getFilterOpsWorkspaceId() { + return filterOpsWorkspaceId; + } + + /** + * @return Resources with the specified vault ID. + */ + @JsonProperty("filterOps.vaultID") + public Optional getFilterOpsVaultId() { + return filterOpsVaultId; + } + + /** + * @return Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890". + */ + @JsonProperty("filterOps.resourceIDs") + public Optional getFilterOpsResourceIDs() { + return filterOpsResourceIDs; + } + + /** + * @return Events with the specified action type. + */ + @JsonProperty("filterOps.actionType") + public Optional getFilterOpsActionType() { + return filterOpsActionType; + } + + /** + * @return Resources with the specified type. + */ + @JsonProperty("filterOps.resourceType") + public Optional getFilterOpsResourceType() { + return filterOpsResourceType; + } + + /** + * @return Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get". + */ + @JsonProperty("filterOps.tags") + public Optional getFilterOpsTags() { + return filterOpsTags; + } + + /** + * @return HTTP response code of the request. + */ + @JsonProperty("filterOps.responseCode") + public Optional getFilterOpsResponseCode() { + return filterOpsResponseCode; + } + + /** + * @return Start timestamp for the query, in SQL format. + */ + @JsonProperty("filterOps.startTime") + public Optional getFilterOpsStartTime() { + return filterOpsStartTime; + } + + /** + * @return End timestamp for the query, in SQL format. + */ + @JsonProperty("filterOps.endTime") + public Optional getFilterOpsEndTime() { + return filterOpsEndTime; + } + + /** + * @return Name of the API called in the request. + */ + @JsonProperty("filterOps.apiName") + public Optional getFilterOpsApiName() { + return filterOpsApiName; + } + + /** + * @return Response message of the request. + */ + @JsonProperty("filterOps.responseMessage") + public Optional getFilterOpsResponseMessage() { + return filterOpsResponseMessage; + } + + /** + * @return HTTP method of the request. + */ + @JsonProperty("filterOps.httpMethod") + public Optional getFilterOpsHttpMethod() { + return filterOpsHttpMethod; + } + + /** + * @return HTTP URI of the request. + */ + @JsonProperty("filterOps.httpURI") + public Optional getFilterOpsHttpUri() { + return filterOpsHttpUri; + } + + /** + * @return Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase"). + */ + @JsonProperty("sortOps.sortBy") + public Optional getSortOpsSortBy() { + return sortOpsSortBy; + } + + /** + * @return Ascending or descending ordering of results. + */ + @JsonProperty("sortOps.orderBy") + public Optional getSortOpsOrderBy() { + return sortOpsOrderBy; + } + + /** + * @return Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. + */ + @JsonProperty("afterOps.timestamp") + public Optional getAfterOpsTimestamp() { + return afterOpsTimestamp; + } + + /** + * @return Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. + */ + @JsonProperty("afterOps.changeID") + public Optional getAfterOpsChangeId() { + return afterOpsChangeId; + } + + /** + * @return Number of results to return. + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Record position at which to start returning results. + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AuditServiceListAuditEventsRequest + && equalTo((AuditServiceListAuditEventsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AuditServiceListAuditEventsRequest other) { + return filterOpsContextChangeId.equals(other.filterOpsContextChangeId) + && filterOpsContextRequestId.equals(other.filterOpsContextRequestId) + && filterOpsContextTraceId.equals(other.filterOpsContextTraceId) + && filterOpsContextSessionId.equals(other.filterOpsContextSessionId) + && filterOpsContextActor.equals(other.filterOpsContextActor) + && filterOpsContextActorType.equals(other.filterOpsContextActorType) + && filterOpsContextAccessType.equals(other.filterOpsContextAccessType) + && filterOpsContextIpAddress.equals(other.filterOpsContextIpAddress) + && filterOpsContextOrigin.equals(other.filterOpsContextOrigin) + && filterOpsContextAuthMode.equals(other.filterOpsContextAuthMode) + && filterOpsContextJwtId.equals(other.filterOpsContextJwtId) + && filterOpsContextBearerTokenContextId.equals(other.filterOpsContextBearerTokenContextId) + && filterOpsParentAccountId.equals(other.filterOpsParentAccountId) + && filterOpsAccountId.equals(other.filterOpsAccountId) + && filterOpsWorkspaceId.equals(other.filterOpsWorkspaceId) + && filterOpsVaultId.equals(other.filterOpsVaultId) + && filterOpsResourceIDs.equals(other.filterOpsResourceIDs) + && filterOpsActionType.equals(other.filterOpsActionType) + && filterOpsResourceType.equals(other.filterOpsResourceType) + && filterOpsTags.equals(other.filterOpsTags) + && filterOpsResponseCode.equals(other.filterOpsResponseCode) + && filterOpsStartTime.equals(other.filterOpsStartTime) + && filterOpsEndTime.equals(other.filterOpsEndTime) + && filterOpsApiName.equals(other.filterOpsApiName) + && filterOpsResponseMessage.equals(other.filterOpsResponseMessage) + && filterOpsHttpMethod.equals(other.filterOpsHttpMethod) + && filterOpsHttpUri.equals(other.filterOpsHttpUri) + && sortOpsSortBy.equals(other.sortOpsSortBy) + && sortOpsOrderBy.equals(other.sortOpsOrderBy) + && afterOpsTimestamp.equals(other.afterOpsTimestamp) + && afterOpsChangeId.equals(other.afterOpsChangeId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @Override + public int hashCode() { + return Objects.hash( + this.filterOpsContextChangeId, + this.filterOpsContextRequestId, + this.filterOpsContextTraceId, + this.filterOpsContextSessionId, + this.filterOpsContextActor, + this.filterOpsContextActorType, + this.filterOpsContextAccessType, + this.filterOpsContextIpAddress, + this.filterOpsContextOrigin, + this.filterOpsContextAuthMode, + this.filterOpsContextJwtId, + this.filterOpsContextBearerTokenContextId, + this.filterOpsParentAccountId, + this.filterOpsAccountId, + this.filterOpsWorkspaceId, + this.filterOpsVaultId, + this.filterOpsResourceIDs, + this.filterOpsActionType, + this.filterOpsResourceType, + this.filterOpsTags, + this.filterOpsResponseCode, + this.filterOpsStartTime, + this.filterOpsEndTime, + this.filterOpsApiName, + this.filterOpsResponseMessage, + this.filterOpsHttpMethod, + this.filterOpsHttpUri, + this.sortOpsSortBy, + this.sortOpsOrderBy, + this.afterOpsTimestamp, + this.afterOpsChangeId, + this.limit, + this.offset); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FilterOpsAccountIdStage builder() { + return new Builder(); + } + + public interface FilterOpsAccountIdStage { + /** + * Resources with the specified account ID. + */ + _FinalStage filterOpsAccountId(@NotNull String filterOpsAccountId); + + Builder from(AuditServiceListAuditEventsRequest other); + } + + public interface _FinalStage { + AuditServiceListAuditEventsRequest build(); + + /** + *

ID for the audit event.

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

ID for the request that caused the event.

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

ID for the request set by the service that received the request.

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

ID for the session in which the request was sent.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

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

Type of member who sent the request.

+ */ + _FinalStage filterOpsContextActorType( + Optional filterOpsContextActorType); + + _FinalStage filterOpsContextActorType( + AuditServiceListAuditEventsRequestFilterOpsContextActorType filterOpsContextActorType); + + /** + *

Type of access for the request.

+ */ + _FinalStage filterOpsContextAccessType( + Optional filterOpsContextAccessType); + + _FinalStage filterOpsContextAccessType( + AuditServiceListAuditEventsRequestFilterOpsContextAccessType filterOpsContextAccessType); + + /** + *

IP Address of the client that made the request.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

Authentication mode the actor used.

+ */ + _FinalStage filterOpsContextAuthMode( + Optional filterOpsContextAuthMode); + + _FinalStage filterOpsContextAuthMode( + AuditServiceListAuditEventsRequestFilterOpsContextAuthMode filterOpsContextAuthMode); + + /** + *

ID of the JWT token.

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

Embedded User Context.

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

Resources with the specified parent account ID.

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

Resources with the specified workspace ID.

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

Resources with the specified vault ID.

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

Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890".

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

Events with the specified action type.

+ */ + _FinalStage filterOpsActionType( + Optional filterOpsActionType); + + _FinalStage filterOpsActionType(AuditServiceListAuditEventsRequestFilterOpsActionType filterOpsActionType); + + /** + *

Resources with the specified type.

+ */ + _FinalStage filterOpsResourceType( + Optional filterOpsResourceType); + + _FinalStage filterOpsResourceType( + AuditServiceListAuditEventsRequestFilterOpsResourceType filterOpsResourceType); + + /** + *

Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get".

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

HTTP response code of the request.

+ */ + _FinalStage filterOpsResponseCode(Optional filterOpsResponseCode); + + _FinalStage filterOpsResponseCode(Integer filterOpsResponseCode); + + /** + *

Start timestamp for the query, in SQL format.

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

End timestamp for the query, in SQL format.

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

Name of the API called in the request.

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

Response message of the request.

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

HTTP method of the request.

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

HTTP URI of the request.

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

Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase").

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

Ascending or descending ordering of results.

+ */ + _FinalStage sortOpsOrderBy(Optional sortOpsOrderBy); + + _FinalStage sortOpsOrderBy(AuditServiceListAuditEventsRequestSortOpsOrderBy sortOpsOrderBy); + + /** + *

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Number of results to return.

+ */ + _FinalStage limit(Optional limit); + + _FinalStage limit(Long limit); + + /** + *

Record position at which to start returning results.

+ */ + _FinalStage offset(Optional offset); + + _FinalStage offset(Long offset); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FilterOpsAccountIdStage, _FinalStage { + private String filterOpsAccountId; + + private Optional offset = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional afterOpsChangeId = Optional.empty(); + + private Optional afterOpsTimestamp = Optional.empty(); + + private Optional sortOpsOrderBy = Optional.empty(); + + private Optional sortOpsSortBy = Optional.empty(); + + private Optional filterOpsHttpUri = Optional.empty(); + + private Optional filterOpsHttpMethod = Optional.empty(); + + private Optional filterOpsResponseMessage = Optional.empty(); + + private Optional filterOpsApiName = Optional.empty(); + + private Optional filterOpsEndTime = Optional.empty(); + + private Optional filterOpsStartTime = Optional.empty(); + + private Optional filterOpsResponseCode = Optional.empty(); + + private Optional filterOpsTags = Optional.empty(); + + private Optional filterOpsResourceType = + Optional.empty(); + + private Optional filterOpsActionType = Optional.empty(); + + private Optional filterOpsResourceIDs = Optional.empty(); + + private Optional filterOpsVaultId = Optional.empty(); + + private Optional filterOpsWorkspaceId = Optional.empty(); + + private Optional filterOpsParentAccountId = Optional.empty(); + + private Optional filterOpsContextBearerTokenContextId = Optional.empty(); + + private Optional filterOpsContextJwtId = Optional.empty(); + + private Optional filterOpsContextAuthMode = + Optional.empty(); + + private Optional filterOpsContextOrigin = Optional.empty(); + + private Optional filterOpsContextIpAddress = Optional.empty(); + + private Optional filterOpsContextAccessType = + Optional.empty(); + + private Optional filterOpsContextActorType = + Optional.empty(); + + private Optional filterOpsContextActor = Optional.empty(); + + private Optional filterOpsContextSessionId = Optional.empty(); + + private Optional filterOpsContextTraceId = Optional.empty(); + + private Optional filterOpsContextRequestId = Optional.empty(); + + private Optional filterOpsContextChangeId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(AuditServiceListAuditEventsRequest other) { + filterOpsContextChangeId(other.getFilterOpsContextChangeId()); + filterOpsContextRequestId(other.getFilterOpsContextRequestId()); + filterOpsContextTraceId(other.getFilterOpsContextTraceId()); + filterOpsContextSessionId(other.getFilterOpsContextSessionId()); + filterOpsContextActor(other.getFilterOpsContextActor()); + filterOpsContextActorType(other.getFilterOpsContextActorType()); + filterOpsContextAccessType(other.getFilterOpsContextAccessType()); + filterOpsContextIpAddress(other.getFilterOpsContextIpAddress()); + filterOpsContextOrigin(other.getFilterOpsContextOrigin()); + filterOpsContextAuthMode(other.getFilterOpsContextAuthMode()); + filterOpsContextJwtId(other.getFilterOpsContextJwtId()); + filterOpsContextBearerTokenContextId(other.getFilterOpsContextBearerTokenContextId()); + filterOpsParentAccountId(other.getFilterOpsParentAccountId()); + filterOpsAccountId(other.getFilterOpsAccountId()); + filterOpsWorkspaceId(other.getFilterOpsWorkspaceId()); + filterOpsVaultId(other.getFilterOpsVaultId()); + filterOpsResourceIDs(other.getFilterOpsResourceIDs()); + filterOpsActionType(other.getFilterOpsActionType()); + filterOpsResourceType(other.getFilterOpsResourceType()); + filterOpsTags(other.getFilterOpsTags()); + filterOpsResponseCode(other.getFilterOpsResponseCode()); + filterOpsStartTime(other.getFilterOpsStartTime()); + filterOpsEndTime(other.getFilterOpsEndTime()); + filterOpsApiName(other.getFilterOpsApiName()); + filterOpsResponseMessage(other.getFilterOpsResponseMessage()); + filterOpsHttpMethod(other.getFilterOpsHttpMethod()); + filterOpsHttpUri(other.getFilterOpsHttpUri()); + sortOpsSortBy(other.getSortOpsSortBy()); + sortOpsOrderBy(other.getSortOpsOrderBy()); + afterOpsTimestamp(other.getAfterOpsTimestamp()); + afterOpsChangeId(other.getAfterOpsChangeId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + /** + * Resources with the specified account ID.

Resources with the specified account ID.

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

Record position at which to start returning results.

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

Record position at which to start returning results.

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

Number of results to return.

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

Number of results to return.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Ascending or descending ordering of results.

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

Ascending or descending ordering of results.

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

Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase").

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

Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase").

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

HTTP URI of the request.

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

HTTP URI of the request.

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

HTTP method of the request.

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

HTTP method of the request.

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

Response message of the request.

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

Response message of the request.

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

Name of the API called in the request.

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

Name of the API called in the request.

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

End timestamp for the query, in SQL format.

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

End timestamp for the query, in SQL format.

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

Start timestamp for the query, in SQL format.

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

Start timestamp for the query, in SQL format.

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

HTTP response code of the request.

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

HTTP response code of the request.

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

Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get".

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

Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get".

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

Resources with the specified type.

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

Resources with the specified type.

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

Events with the specified action type.

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

Events with the specified action type.

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

Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890".

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

Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890".

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

Resources with the specified vault ID.

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

Resources with the specified vault ID.

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

Resources with the specified workspace ID.

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

Resources with the specified workspace ID.

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

Resources with the specified parent account ID.

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

Resources with the specified parent account ID.

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

Embedded User Context.

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

Embedded User Context.

+ */ + @Override + @JsonSetter(value = "filterOps.context.bearerTokenContextID", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextBearerTokenContextId(Optional filterOpsContextBearerTokenContextId) { + this.filterOpsContextBearerTokenContextId = filterOpsContextBearerTokenContextId; + return this; + } + + /** + *

ID of the JWT token.

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

ID of the JWT token.

+ */ + @Override + @JsonSetter(value = "filterOps.context.jwtID", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextJwtId(Optional filterOpsContextJwtId) { + this.filterOpsContextJwtId = filterOpsContextJwtId; + return this; + } + + /** + *

Authentication mode the actor used.

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

Authentication mode the actor used.

+ */ + @Override + @JsonSetter(value = "filterOps.context.authMode", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextAuthMode( + Optional filterOpsContextAuthMode) { + this.filterOpsContextAuthMode = filterOpsContextAuthMode; + return this; + } + + /** + *

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

+ */ + @Override + @JsonSetter(value = "filterOps.context.origin", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextOrigin(Optional filterOpsContextOrigin) { + this.filterOpsContextOrigin = filterOpsContextOrigin; + return this; + } + + /** + *

IP Address of the client that made the request.

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

IP Address of the client that made the request.

+ */ + @Override + @JsonSetter(value = "filterOps.context.ipAddress", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextIpAddress(Optional filterOpsContextIpAddress) { + this.filterOpsContextIpAddress = filterOpsContextIpAddress; + return this; + } + + /** + *

Type of access for the request.

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

Type of access for the request.

+ */ + @Override + @JsonSetter(value = "filterOps.context.accessType", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextAccessType( + Optional filterOpsContextAccessType) { + this.filterOpsContextAccessType = filterOpsContextAccessType; + return this; + } + + /** + *

Type of member who sent the request.

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

Type of member who sent the request.

+ */ + @Override + @JsonSetter(value = "filterOps.context.actorType", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextActorType( + Optional filterOpsContextActorType) { + this.filterOpsContextActorType = filterOpsContextActorType; + return this; + } + + /** + *

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

+ */ + @Override + @JsonSetter(value = "filterOps.context.actor", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextActor(Optional filterOpsContextActor) { + this.filterOpsContextActor = filterOpsContextActor; + return this; + } + + /** + *

ID for the session in which the request was sent.

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

ID for the session in which the request was sent.

+ */ + @Override + @JsonSetter(value = "filterOps.context.sessionID", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextSessionId(Optional filterOpsContextSessionId) { + this.filterOpsContextSessionId = filterOpsContextSessionId; + return this; + } + + /** + *

ID for the request set by the service that received the request.

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

ID for the request set by the service that received the request.

+ */ + @Override + @JsonSetter(value = "filterOps.context.traceID", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextTraceId(Optional filterOpsContextTraceId) { + this.filterOpsContextTraceId = filterOpsContextTraceId; + return this; + } + + /** + *

ID for the request that caused the event.

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

ID for the request that caused the event.

+ */ + @Override + @JsonSetter(value = "filterOps.context.requestID", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextRequestId(Optional filterOpsContextRequestId) { + this.filterOpsContextRequestId = filterOpsContextRequestId; + return this; + } + + /** + *

ID for the audit event.

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

ID for the audit event.

+ */ + @Override + @JsonSetter(value = "filterOps.context.changeID", nulls = Nulls.SKIP) + public _FinalStage filterOpsContextChangeId(Optional filterOpsContextChangeId) { + this.filterOpsContextChangeId = filterOpsContextChangeId; + return this; + } + + @Override + public AuditServiceListAuditEventsRequest build() { + return new AuditServiceListAuditEventsRequest( + filterOpsContextChangeId, + filterOpsContextRequestId, + filterOpsContextTraceId, + filterOpsContextSessionId, + filterOpsContextActor, + filterOpsContextActorType, + filterOpsContextAccessType, + filterOpsContextIpAddress, + filterOpsContextOrigin, + filterOpsContextAuthMode, + filterOpsContextJwtId, + filterOpsContextBearerTokenContextId, + filterOpsParentAccountId, + filterOpsAccountId, + filterOpsWorkspaceId, + filterOpsVaultId, + filterOpsResourceIDs, + filterOpsActionType, + filterOpsResourceType, + filterOpsTags, + filterOpsResponseCode, + filterOpsStartTime, + filterOpsEndTime, + filterOpsApiName, + filterOpsResponseMessage, + filterOpsHttpMethod, + filterOpsHttpUri, + sortOpsSortBy, + sortOpsOrderBy, + afterOpsTimestamp, + afterOpsChangeId, + limit, + offset, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java new file mode 100644 index 00000000..9611f8ab --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuditServiceListAuditEventsRequestFilterOpsActionType { + NONE("NONE"), + + ASSIGN("ASSIGN"), + + CREATE("CREATE"), + + DELETE("DELETE"), + + EXECUTE("EXECUTE"), + + LIST("LIST"), + + READ("READ"), + + UNASSIGN("UNASSIGN"), + + UPDATE("UPDATE"), + + VALIDATE("VALIDATE"), + + LOGIN("LOGIN"), + + ROTATE("ROTATE"), + + SCHEDULEROTATION("SCHEDULEROTATION"), + + SCHEDULEROTATIONALERT("SCHEDULEROTATIONALERT"), + + IMPORT("IMPORT"), + + GETIMPORTPARAMETERS("GETIMPORTPARAMETERS"), + + PING("PING"), + + GETCLOUDPROVIDER("GETCLOUDPROVIDER"); + + private final String value; + + AuditServiceListAuditEventsRequestFilterOpsActionType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java new file mode 100644 index 00000000..44ac80d9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuditServiceListAuditEventsRequestFilterOpsContextAccessType { + ACCESS_NONE("ACCESS_NONE"), + + API("API"), + + SQL("SQL"), + + OKTA_LOGIN("OKTA_LOGIN"); + + private final String value; + + AuditServiceListAuditEventsRequestFilterOpsContextAccessType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java new file mode 100644 index 00000000..1948ea9c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuditServiceListAuditEventsRequestFilterOpsContextActorType { + NONE("NONE"), + + USER("USER"), + + SERVICE_ACCOUNT("SERVICE_ACCOUNT"); + + private final String value; + + AuditServiceListAuditEventsRequestFilterOpsContextActorType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java new file mode 100644 index 00000000..82c375aa --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuditServiceListAuditEventsRequestFilterOpsContextAuthMode { + AUTH_NONE("AUTH_NONE"), + + OKTA_JWT("OKTA_JWT"), + + SERVICE_ACCOUNT_JWT("SERVICE_ACCOUNT_JWT"), + + PAT_JWT("PAT_JWT"); + + private final String value; + + AuditServiceListAuditEventsRequestFilterOpsContextAuthMode(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java new file mode 100644 index 00000000..864213ec --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java @@ -0,0 +1,80 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuditServiceListAuditEventsRequestFilterOpsResourceType { + NONE_API("NONE_API"), + + ACCOUNT("ACCOUNT"), + + AUDIT("AUDIT"), + + BASE_DATA_TYPE("BASE_DATA_TYPE"), + + FIELD_TEMPLATE("FIELD_TEMPLATE"), + + FILE("FILE"), + + KEY("KEY"), + + POLICY("POLICY"), + + PROTO_PARSE("PROTO_PARSE"), + + RECORD("RECORD"), + + ROLE("ROLE"), + + RULE("RULE"), + + SECRET("SECRET"), + + SERVICE_ACCOUNT("SERVICE_ACCOUNT"), + + TOKEN("TOKEN"), + + USER("USER"), + + VAULT("VAULT"), + + VAULT_TEMPLATE("VAULT_TEMPLATE"), + + WORKSPACE("WORKSPACE"), + + TABLE("TABLE"), + + POLICY_TEMPLATE("POLICY_TEMPLATE"), + + MEMBER("MEMBER"), + + TAG("TAG"), + + CONNECTION("CONNECTION"), + + MIGRATION("MIGRATION"), + + SCHEDULED_JOB("SCHEDULED_JOB"), + + JOB("JOB"), + + COLUMN_NAME("COLUMN_NAME"), + + NETWORK_TOKEN("NETWORK_TOKEN"), + + SUBSCRIPTION("SUBSCRIPTION"); + + private final String value; + + AuditServiceListAuditEventsRequestFilterOpsResourceType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java new file mode 100644 index 00000000..fe3f928e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.audit.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AuditServiceListAuditEventsRequestSortOpsOrderBy { + ASCENDING("ASCENDING"), + + DESCENDING("DESCENDING"); + + private final String value; + + AuditServiceListAuditEventsRequestSortOpsOrderBy(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java new file mode 100644 index 00000000..43ffab73 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.authentication; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncAuthenticationClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAuthenticationClient rawClient; + + public AsyncAuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAuthenticationClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAuthenticationClient withRawResponse() { + return this.rawClient; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture authenticationServiceGetAuthToken(V1GetAuthTokenRequest request) { + return this.rawClient.authenticationServiceGetAuthToken(request).thenApply(response -> response.body()); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + return this.rawClient + .authenticationServiceGetAuthToken(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java new file mode 100644 index 00000000..eca4ab90 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java @@ -0,0 +1,126 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.authentication; + +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.NotFoundError; +import com.skyflow.generated.rest.errors.UnauthorizedError; +import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +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 AsyncRawAuthenticationClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture> authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request) { + return authenticationServiceGetAuthToken(request, null); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public CompletableFuture> authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sa/oauth/token") + .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(), V1GetAuthTokenResponse.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; + } + } 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/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java new file mode 100644 index 00000000..662bfb3d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.authentication; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; + +public class AuthenticationClient { + protected final ClientOptions clientOptions; + + private final RawAuthenticationClient rawClient; + + public AuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAuthenticationClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuthenticationClient withRawResponse() { + return this.rawClient; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public V1GetAuthTokenResponse authenticationServiceGetAuthToken(V1GetAuthTokenRequest request) { + return this.rawClient.authenticationServiceGetAuthToken(request).body(); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public V1GetAuthTokenResponse authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + return this.rawClient + .authenticationServiceGetAuthToken(request, requestOptions) + .body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java new file mode 100644 index 00000000..3d242eff --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.authentication; + +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.NotFoundError; +import com.skyflow.generated.rest.errors.UnauthorizedError; +import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +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 RawAuthenticationClient { + protected final ClientOptions clientOptions; + + public RawAuthenticationClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public ApiClientHttpResponse authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request) { + return authenticationServiceGetAuthToken(request, null); + } + + /** + *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

+ */ + public ApiClientHttpResponse authenticationServiceGetAuthToken( + V1GetAuthTokenRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sa/oauth/token") + .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(), V1GetAuthTokenResponse.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); + } + } 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/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java new file mode 100644 index 00000000..182952bc --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java @@ -0,0 +1,335 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.authentication.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 = V1GetAuthTokenRequest.Builder.class) +public final class V1GetAuthTokenRequest { + private final String grantType; + + private final String assertion; + + private final Optional subjectToken; + + private final Optional subjectTokenType; + + private final Optional requestedTokenUse; + + private final Optional scope; + + private final Map additionalProperties; + + private V1GetAuthTokenRequest( + String grantType, + String assertion, + Optional subjectToken, + Optional subjectTokenType, + Optional requestedTokenUse, + Optional scope, + Map additionalProperties) { + this.grantType = grantType; + this.assertion = assertion; + this.subjectToken = subjectToken; + this.subjectTokenType = subjectTokenType; + this.requestedTokenUse = requestedTokenUse; + this.scope = scope; + this.additionalProperties = additionalProperties; + } + + /** + * @return Grant type of the request. Set this to urn:ietf:params:oauth:grant-type:jwt-bearer. + */ + @JsonProperty("grant_type") + public String getGrantType() { + return grantType; + } + + /** + * @return User-signed JWT token that contains the following fields: <br/> <ul><li><code>iss</code>: Issuer of the JWT.</li><li><code>key</code>: Unique identifier for the key.</li><li><code>aud</code>: Recipient the JWT is intended for.</li><li><code>exp</code>: Time the JWT expires.</li><li><code>sub</code>: Subject of the JWT.</li><li><code>ctx</code>: (Optional) Value for <a href='/context-aware-overview/'>Context-aware authorization</a>.</li></ul> + */ + @JsonProperty("assertion") + public String getAssertion() { + return assertion; + } + + /** + * @return Subject token. + */ + @JsonProperty("subject_token") + public Optional getSubjectToken() { + return subjectToken; + } + + /** + * @return Subject token type. + */ + @JsonProperty("subject_token_type") + public Optional getSubjectTokenType() { + return subjectTokenType; + } + + /** + * @return Token use type. Either delegation or impersonation. + */ + @JsonProperty("requested_token_use") + public Optional getRequestedTokenUse() { + return requestedTokenUse; + } + + /** + * @return Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>". + */ + @JsonProperty("scope") + public Optional getScope() { + return scope; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1GetAuthTokenRequest && equalTo((V1GetAuthTokenRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1GetAuthTokenRequest other) { + return grantType.equals(other.grantType) + && assertion.equals(other.assertion) + && subjectToken.equals(other.subjectToken) + && subjectTokenType.equals(other.subjectTokenType) + && requestedTokenUse.equals(other.requestedTokenUse) + && scope.equals(other.scope); + } + + @Override + public int hashCode() { + return Objects.hash( + this.grantType, + this.assertion, + this.subjectToken, + this.subjectTokenType, + this.requestedTokenUse, + this.scope); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static GrantTypeStage builder() { + return new Builder(); + } + + public interface GrantTypeStage { + /** + * Grant type of the request. Set this to `urn:ietf:params:oauth:grant-type:jwt-bearer`. + */ + AssertionStage grantType(@NotNull String grantType); + + Builder from(V1GetAuthTokenRequest other); + } + + public interface AssertionStage { + /** + * User-signed JWT token that contains the following fields:
  • iss: Issuer of the JWT.
  • key: Unique identifier for the key.
  • aud: Recipient the JWT is intended for.
  • exp: Time the JWT expires.
  • sub: Subject of the JWT.
  • ctx: (Optional) Value for Context-aware authorization.
+ */ + _FinalStage assertion(@NotNull String assertion); + } + + public interface _FinalStage { + V1GetAuthTokenRequest build(); + + /** + *

Subject token.

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

Subject token type.

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

Token use type. Either delegation or impersonation.

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

+ */ + _FinalStage scope(Optional scope); + + _FinalStage scope(String scope); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements GrantTypeStage, AssertionStage, _FinalStage { + private String grantType; + + private String assertion; + + private Optional scope = Optional.empty(); + + private Optional requestedTokenUse = Optional.empty(); + + private Optional subjectTokenType = Optional.empty(); + + private Optional subjectToken = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(V1GetAuthTokenRequest other) { + grantType(other.getGrantType()); + assertion(other.getAssertion()); + subjectToken(other.getSubjectToken()); + subjectTokenType(other.getSubjectTokenType()); + requestedTokenUse(other.getRequestedTokenUse()); + scope(other.getScope()); + return this; + } + + /** + * Grant type of the request. Set this to `urn:ietf:params:oauth:grant-type:jwt-bearer`.

Grant type of the request. Set this to urn:ietf:params:oauth:grant-type:jwt-bearer.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("grant_type") + public AssertionStage grantType(@NotNull String grantType) { + this.grantType = Objects.requireNonNull(grantType, "grantType must not be null"); + return this; + } + + /** + * User-signed JWT token that contains the following fields:
  • iss: Issuer of the JWT.
  • key: Unique identifier for the key.
  • aud: Recipient the JWT is intended for.
  • exp: Time the JWT expires.
  • sub: Subject of the JWT.
  • ctx: (Optional) Value for Context-aware authorization.

User-signed JWT token that contains the following fields: <br/> <ul><li><code>iss</code>: Issuer of the JWT.</li><li><code>key</code>: Unique identifier for the key.</li><li><code>aud</code>: Recipient the JWT is intended for.</li><li><code>exp</code>: Time the JWT expires.</li><li><code>sub</code>: Subject of the JWT.</li><li><code>ctx</code>: (Optional) Value for <a href='/context-aware-overview/'>Context-aware authorization</a>.</li></ul>

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Token use type. Either delegation or impersonation.

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

Token use type. Either delegation or impersonation.

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

Subject token type.

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

Subject token type.

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

Subject token.

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

Subject token.

+ */ + @Override + @JsonSetter(value = "subject_token", nulls = Nulls.SKIP) + public _FinalStage subjectToken(Optional subjectToken) { + this.subjectToken = subjectToken; + return this; + } + + @Override + public V1GetAuthTokenRequest build() { + return new V1GetAuthTokenRequest( + grantType, + assertion, + subjectToken, + subjectTokenType, + requestedTokenUse, + scope, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java new file mode 100644 index 00000000..f10ed979 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java @@ -0,0 +1,52 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.binlookup; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; +import com.skyflow.generated.rest.types.V1BinListResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncBinLookupClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBinLookupClient rawClient; + + public AsyncBinLookupClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBinLookupClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBinLookupClient withRawResponse() { + return this.rawClient; + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public CompletableFuture binListServiceListCardsOfBin() { + return this.rawClient.binListServiceListCardsOfBin().thenApply(response -> response.body()); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public CompletableFuture binListServiceListCardsOfBin(V1BinListRequest request) { + return this.rawClient.binListServiceListCardsOfBin(request).thenApply(response -> response.body()); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public CompletableFuture binListServiceListCardsOfBin( + V1BinListRequest request, RequestOptions requestOptions) { + return this.rawClient + .binListServiceListCardsOfBin(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java new file mode 100644 index 00000000..2a3f5f4f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.binlookup; + +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.NotFoundError; +import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; +import com.skyflow.generated.rest.types.V1BinListResponse; +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 AsyncRawBinLookupClient { + protected final ClientOptions clientOptions; + + public AsyncRawBinLookupClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public CompletableFuture> binListServiceListCardsOfBin() { + return binListServiceListCardsOfBin(V1BinListRequest.builder().build()); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public CompletableFuture> binListServiceListCardsOfBin( + V1BinListRequest request) { + return binListServiceListCardsOfBin(request, null); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public CompletableFuture> binListServiceListCardsOfBin( + V1BinListRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/card_lookup") + .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(), V1BinListResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java new file mode 100644 index 00000000..a7822986 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.binlookup; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; +import com.skyflow.generated.rest.types.V1BinListResponse; + +public class BinLookupClient { + protected final ClientOptions clientOptions; + + private final RawBinLookupClient rawClient; + + public BinLookupClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawBinLookupClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBinLookupClient withRawResponse() { + return this.rawClient; + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public V1BinListResponse binListServiceListCardsOfBin() { + return this.rawClient.binListServiceListCardsOfBin().body(); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public V1BinListResponse binListServiceListCardsOfBin(V1BinListRequest request) { + return this.rawClient.binListServiceListCardsOfBin(request).body(); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public V1BinListResponse binListServiceListCardsOfBin(V1BinListRequest request, RequestOptions requestOptions) { + return this.rawClient + .binListServiceListCardsOfBin(request, requestOptions) + .body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java new file mode 100644 index 00000000..bb08039b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.binlookup; + +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.NotFoundError; +import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; +import com.skyflow.generated.rest.types.V1BinListResponse; +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 RawBinLookupClient { + protected final ClientOptions clientOptions; + + public RawBinLookupClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public ApiClientHttpResponse binListServiceListCardsOfBin() { + return binListServiceListCardsOfBin(V1BinListRequest.builder().build()); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public ApiClientHttpResponse binListServiceListCardsOfBin(V1BinListRequest request) { + return binListServiceListCardsOfBin(request, null); + } + + /** + * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. + */ + public ApiClientHttpResponse binListServiceListCardsOfBin( + V1BinListRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/card_lookup") + .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(), V1BinListResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java new file mode 100644 index 00000000..af827e01 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.binlookup.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.V1VaultSchemaConfig; +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 = V1BinListRequest.Builder.class) +public final class V1BinListRequest { + private final Optional> fields; + + private final Optional bin; + + private final Optional vaultSchemaConfig; + + private final Optional skyflowId; + + private final Map additionalProperties; + + private V1BinListRequest( + Optional> fields, + Optional bin, + Optional vaultSchemaConfig, + Optional skyflowId, + Map additionalProperties) { + this.fields = fields; + this.bin = bin; + this.vaultSchemaConfig = vaultSchemaConfig; + this.skyflowId = skyflowId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Fields to return. If not specified, all fields are returned. + */ + @JsonProperty("fields") + public Optional> getFields() { + return fields; + } + + /** + * @return BIN of the card. + */ + @JsonProperty("BIN") + public Optional getBin() { + return bin; + } + + @JsonProperty("vault_schema_config") + public Optional getVaultSchemaConfig() { + return vaultSchemaConfig; + } + + /** + * @return <code>skyflow_id</code> of the record. + */ + @JsonProperty("skyflow_id") + public Optional getSkyflowId() { + return skyflowId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1BinListRequest && equalTo((V1BinListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1BinListRequest other) { + return fields.equals(other.fields) + && bin.equals(other.bin) + && vaultSchemaConfig.equals(other.vaultSchemaConfig) + && skyflowId.equals(other.skyflowId); + } + + @Override + public int hashCode() { + return Objects.hash(this.fields, this.bin, this.vaultSchemaConfig, this.skyflowId); + } + + @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> fields = Optional.empty(); + + private Optional bin = Optional.empty(); + + private Optional vaultSchemaConfig = Optional.empty(); + + private Optional skyflowId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1BinListRequest other) { + fields(other.getFields()); + bin(other.getBin()); + vaultSchemaConfig(other.getVaultSchemaConfig()); + skyflowId(other.getSkyflowId()); + return this; + } + + /** + *

Fields to return. If not specified, all fields are returned.

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

BIN of the card.

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

<code>skyflow_id</code> of the record.

+ */ + @JsonSetter(value = "skyflow_id", 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; + } + + public V1BinListRequest build() { + return new V1BinListRequest(fields, bin, vaultSchemaConfig, skyflowId, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java new file mode 100644 index 00000000..c1709f7f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java @@ -0,0 +1,89 @@ +/** + * 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/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java new file mode 100644 index 00000000..9c9ec79a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java @@ -0,0 +1,271 @@ +/** + * 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/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java new file mode 100644 index 00000000..820a349b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java @@ -0,0 +1,87 @@ +/** + * 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/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java new file mode 100644 index 00000000..4472487f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java @@ -0,0 +1,222 @@ +/** + * 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/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java new file mode 100644 index 00000000..b94cb3d3 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java @@ -0,0 +1,101 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java new file mode 100644 index 00000000..a8263338 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java @@ -0,0 +1,526 @@ +/** + * 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; + } + + @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); + } + + @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); + } + + @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() {} + + @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. + */ + @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. + */ + @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. + */ + @Override + public _FinalStage storeEntities(Boolean storeEntities) { + this.storeEntities = Optional.ofNullable(storeEntities); + return this; + } + + /** + *

Indicates whether entities should be stored in the vault.

+ */ + @Override + @JsonSetter(value = "store_entities", nulls = Nulls.SKIP) + public _FinalStage storeEntities(Optional storeEntities) { + this.storeEntities = storeEntities; + return this; + } + + @Override + public _FinalStage advancedOptions(V1AdvancedOptions advancedOptions) { + this.advancedOptions = Optional.ofNullable(advancedOptions); + return this; + } + + @Override + @JsonSetter(value = "advanced_options", nulls = Nulls.SKIP) + public _FinalStage advancedOptions(Optional advancedOptions) { + this.advancedOptions = advancedOptions; + return this; + } + + @Override + public _FinalStage accuracy(DetectDataAccuracy accuracy) { + this.accuracy = Optional.ofNullable(accuracy); + return this; + } + + @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. + */ + @Override + public _FinalStage returnEntities(Boolean returnEntities) { + this.returnEntities = Optional.ofNullable(returnEntities); + return this; + } + + /** + *

If true, returns the details for the detected entities.

+ */ + @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. + */ + @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'.

+ */ + @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. + */ + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + /** + *

Regular expressions to ignore when detecting entities.

+ */ + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat) { + this.deidentifyTokenFormat = Optional.ofNullable(deidentifyTokenFormat); + return this; + } + + @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. + */ + @Override + public _FinalStage restrictEntityTypes(List restrictEntityTypes) { + this.restrictEntityTypes = Optional.ofNullable(restrictEntityTypes); + return this; + } + + /** + *

Entities to detect and deidentify.

+ */ + @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. + */ + @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.

+ */ + @Override + @JsonSetter(value = "session_id", nulls = Nulls.SKIP) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @Override + public DetectServiceDetectTextRequest build() { + return new DetectServiceDetectTextRequest( + text, + vaultId, + sessionId, + restrictEntityTypes, + deidentifyTokenFormat, + allowRegex, + restrictRegex, + returnEntities, + accuracy, + advancedOptions, + storeEntities, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java new file mode 100644 index 00000000..a460f3a1 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java @@ -0,0 +1,634 @@ +/** + * 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; + } + + @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); + } + + @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); + } + + @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() {} + + @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. + */ + @Override + @JsonSetter("file") + public DataFormatStage file(@NotNull String file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + @JsonSetter("data_format") + public InputTypeStage dataFormat(@NotNull V1FileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @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. + */ + @Override + @JsonSetter("vault_id") + public _FinalStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + @Override + public _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat) { + this.deidentifyTokenFormat = Optional.ofNullable(deidentifyTokenFormat); + return this; + } + + @Override + @JsonSetter(value = "deidentify_token_format", nulls = Nulls.SKIP) + public _FinalStage deidentifyTokenFormat(Optional deidentifyTokenFormat) { + this.deidentifyTokenFormat = deidentifyTokenFormat; + return this; + } + + @Override + public _FinalStage advancedOptions(V1AdvancedOptions advancedOptions) { + this.advancedOptions = Optional.ofNullable(advancedOptions); + return this; + } + + @Override + @JsonSetter(value = "advanced_options", nulls = Nulls.SKIP) + public _FinalStage advancedOptions(Optional advancedOptions) { + this.advancedOptions = advancedOptions; + return this; + } + + @Override + public _FinalStage pdf(V1PdfConfig pdf) { + this.pdf = Optional.ofNullable(pdf); + return this; + } + + @Override + @JsonSetter(value = "pdf", nulls = Nulls.SKIP) + public _FinalStage pdf(Optional pdf) { + this.pdf = pdf; + return this; + } + + @Override + public _FinalStage image(V1ImageOptions image) { + this.image = Optional.ofNullable(image); + return this; + } + + @Override + @JsonSetter(value = "image", nulls = Nulls.SKIP) + public _FinalStage image(Optional image) { + this.image = image; + return this; + } + + @Override + public _FinalStage audio(V1AudioConfig audio) { + this.audio = Optional.ofNullable(audio); + return this; + } + + @Override + @JsonSetter(value = "audio", nulls = Nulls.SKIP) + public _FinalStage audio(Optional audio) { + this.audio = audio; + return this; + } + + @Override + public _FinalStage accuracy(DetectDataAccuracy accuracy) { + this.accuracy = Optional.ofNullable(accuracy); + return this; + } + + @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. + */ + @Override + public _FinalStage returnEntities(Boolean returnEntities) { + this.returnEntities = Optional.ofNullable(returnEntities); + return this; + } + + /** + *

If true, returns the details for the detected entities.

+ */ + @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. + */ + @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'.

+ */ + @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. + */ + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + /** + *

Regular expressions to ignore when detecting entities.

+ */ + @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. + */ + @Override + public _FinalStage restrictEntityTypes(List restrictEntityTypes) { + this.restrictEntityTypes = Optional.ofNullable(restrictEntityTypes); + return this; + } + + /** + *

Entities to detect and deidentify.

+ */ + @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. + */ + @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.

+ */ + @Override + @JsonSetter(value = "session_id", nulls = Nulls.SKIP) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @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/v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java new file mode 100644 index 00000000..48692d9f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyAudioRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; +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.types.DeidentifyFileResponse; +import com.skyflow.generated.rest.types.DeidentifyStatusResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFilesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFilesClient rawClient; + + public AsyncFilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFilesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFilesClient withRawResponse() { + return this.rawClient; + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public CompletableFuture deidentifyFile(DeidentifyFileRequest request) { + return this.rawClient.deidentifyFile(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public CompletableFuture deidentifyFile( + DeidentifyFileRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyFile(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyDocument(DeidentifyDocumentRequest request) { + return this.rawClient.deidentifyDocument(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyDocument( + DeidentifyDocumentRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyDocument(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyPdf(DeidentifyPdfRequest request) { + return this.rawClient.deidentifyPdf(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyPdf( + DeidentifyPdfRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyPdf(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyImage(DeidentifyImageRequest request) { + return this.rawClient.deidentifyImage(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyImage( + DeidentifyImageRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyImage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyText(DeidentifyTextRequest request) { + return this.rawClient.deidentifyText(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyText( + DeidentifyTextRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyText(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyStructuredText(DeidentifyStructuredTextRequest request) { + return this.rawClient.deidentifyStructuredText(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyStructuredText( + DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyStructuredText(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifySpreadsheet(DeidentifySpreadsheetRequest request) { + return this.rawClient.deidentifySpreadsheet(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifySpreadsheet( + DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifySpreadsheet(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyPresentation(DeidentifyPresentationRequest request) { + return this.rawClient.deidentifyPresentation(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyPresentation( + DeidentifyPresentationRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyPresentation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyAudio(DeidentifyAudioRequest request) { + return this.rawClient.deidentifyAudio(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture deidentifyAudio( + DeidentifyAudioRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyAudio(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the status of the detect run. + */ + public CompletableFuture getRun(String runId, GetRunRequest request) { + return this.rawClient.getRun(runId, request).thenApply(response -> response.body()); + } + + /** + * Returns the status of the detect run. + */ + public CompletableFuture getRun( + String runId, GetRunRequest request, RequestOptions requestOptions) { + return this.rawClient.getRun(runId, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java new file mode 100644 index 00000000..f400bb2a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java @@ -0,0 +1,929 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files; + +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.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.files.requests.DeidentifyAudioRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; +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.types.DeidentifyFileResponse; +import com.skyflow.generated.rest.types.DeidentifyStatusResponse; +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 AsyncRawFilesClient { + protected final ClientOptions clientOptions; + + public AsyncRawFilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public CompletableFuture> deidentifyFile( + DeidentifyFileRequest request) { + return deidentifyFile(request, null); + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public CompletableFuture> deidentifyFile( + DeidentifyFileRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyDocument( + DeidentifyDocumentRequest request) { + return deidentifyDocument(request, null); + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyDocument( + DeidentifyDocumentRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/document") + .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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyPdf( + DeidentifyPdfRequest request) { + return deidentifyPdf(request, null); + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyPdf( + DeidentifyPdfRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/document/pdf") + .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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyImage( + DeidentifyImageRequest request) { + return deidentifyImage(request, null); + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyImage( + DeidentifyImageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/image") + .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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyText( + DeidentifyTextRequest request) { + return deidentifyText(request, null); + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyText( + DeidentifyTextRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyStructuredText( + DeidentifyStructuredTextRequest request) { + return deidentifyStructuredText(request, null); + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyStructuredText( + DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/structured_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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifySpreadsheet( + DeidentifySpreadsheetRequest request) { + return deidentifySpreadsheet(request, null); + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifySpreadsheet( + DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/spreadsheet") + .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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyPresentation( + DeidentifyPresentationRequest request) { + return deidentifyPresentation(request, null); + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyPresentation( + DeidentifyPresentationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/presentation") + .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(), DeidentifyFileResponse.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; + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyAudio( + DeidentifyAudioRequest request) { + return deidentifyAudio(request, null); + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public CompletableFuture> deidentifyAudio( + DeidentifyAudioRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/audio") + .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(), DeidentifyFileResponse.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; + } + + /** + * Returns the status of the detect run. + */ + public CompletableFuture> getRun( + String runId, GetRunRequest request) { + return getRun(runId, request, null); + } + + /** + * Returns the status of the detect run. + */ + public CompletableFuture> getRun( + String runId, GetRunRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/runs") + .addPathSegment(runId); + QueryStringMapper.addQueryParameter(httpUrl, "vault_id", request.getVaultId(), 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(), DeidentifyStatusResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java new file mode 100644 index 00000000..89898d41 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyAudioRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; +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.types.DeidentifyFileResponse; +import com.skyflow.generated.rest.types.DeidentifyStatusResponse; + +public class FilesClient { + protected final ClientOptions clientOptions; + + private final RawFilesClient rawClient; + + public FilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawFilesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFilesClient withRawResponse() { + return this.rawClient; + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) { + return this.rawClient.deidentifyFile(request).body(); + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyFile(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyDocument(DeidentifyDocumentRequest request) { + return this.rawClient.deidentifyDocument(request).body(); + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyDocument(DeidentifyDocumentRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyDocument(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyPdf(DeidentifyPdfRequest request) { + return this.rawClient.deidentifyPdf(request).body(); + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyPdf(DeidentifyPdfRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyPdf(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyImage(DeidentifyImageRequest request) { + return this.rawClient.deidentifyImage(request).body(); + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyImage(DeidentifyImageRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyImage(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyText(DeidentifyTextRequest request) { + return this.rawClient.deidentifyText(request).body(); + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyText(DeidentifyTextRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyText(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyStructuredText(DeidentifyStructuredTextRequest request) { + return this.rawClient.deidentifyStructuredText(request).body(); + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyStructuredText( + DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyStructuredText(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifySpreadsheet(DeidentifySpreadsheetRequest request) { + return this.rawClient.deidentifySpreadsheet(request).body(); + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifySpreadsheet( + DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifySpreadsheet(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyPresentation(DeidentifyPresentationRequest request) { + return this.rawClient.deidentifyPresentation(request).body(); + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyPresentation( + DeidentifyPresentationRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyPresentation(request, requestOptions).body(); + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyAudio(DeidentifyAudioRequest request) { + return this.rawClient.deidentifyAudio(request).body(); + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public DeidentifyFileResponse deidentifyAudio(DeidentifyAudioRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyAudio(request, requestOptions).body(); + } + + /** + * Returns the status of the detect run. + */ + public DeidentifyStatusResponse getRun(String runId, GetRunRequest request) { + return this.rawClient.getRun(runId, request).body(); + } + + /** + * Returns the status of the detect run. + */ + public DeidentifyStatusResponse getRun(String runId, GetRunRequest request, RequestOptions requestOptions) { + return this.rawClient.getRun(runId, request, requestOptions).body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java new file mode 100644 index 00000000..85939625 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java @@ -0,0 +1,714 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files; + +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.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.files.requests.DeidentifyAudioRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; +import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; +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.types.DeidentifyFileResponse; +import com.skyflow.generated.rest.types.DeidentifyStatusResponse; +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 RawFilesClient { + protected final ClientOptions clientOptions; + + public RawFilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public ApiClientHttpResponse deidentifyFile(DeidentifyFileRequest request) { + return deidentifyFile(request, null); + } + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). + */ + public ApiClientHttpResponse deidentifyFile( + DeidentifyFileRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyDocument(DeidentifyDocumentRequest request) { + return deidentifyDocument(request, null); + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyDocument( + DeidentifyDocumentRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/document") + .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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyPdf(DeidentifyPdfRequest request) { + return deidentifyPdf(request, null); + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyPdf( + DeidentifyPdfRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/document/pdf") + .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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyImage(DeidentifyImageRequest request) { + return deidentifyImage(request, null); + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyImage( + DeidentifyImageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/image") + .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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyText(DeidentifyTextRequest request) { + return deidentifyText(request, null); + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyText( + DeidentifyTextRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyStructuredText( + DeidentifyStructuredTextRequest request) { + return deidentifyStructuredText(request, null); + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyStructuredText( + DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/structured_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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifySpreadsheet(DeidentifySpreadsheetRequest request) { + return deidentifySpreadsheet(request, null); + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifySpreadsheet( + DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/spreadsheet") + .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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyPresentation(DeidentifyPresentationRequest request) { + return deidentifyPresentation(request, null); + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyPresentation( + DeidentifyPresentationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/presentation") + .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(), DeidentifyFileResponse.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); + } + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyAudio(DeidentifyAudioRequest request) { + return deidentifyAudio(request, null); + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. + */ + public ApiClientHttpResponse deidentifyAudio( + DeidentifyAudioRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/file/audio") + .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(), DeidentifyFileResponse.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); + } + } + + /** + * Returns the status of the detect run. + */ + public ApiClientHttpResponse getRun(String runId, GetRunRequest request) { + return getRun(runId, request, null); + } + + /** + * Returns the status of the detect run. + */ + public ApiClientHttpResponse getRun( + String runId, GetRunRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/runs") + .addPathSegment(runId); + QueryStringMapper.addQueryParameter(httpUrl, "vault_id", request.getVaultId(), 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(), DeidentifyStatusResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java new file mode 100644 index 00000000..181693c6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java @@ -0,0 +1,582 @@ +/** + * 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.DeidentifyAudioRequestFile; +import com.skyflow.generated.rest.resources.files.types.DeidentifyAudioRequestOutputTranscription; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyAudioRequest.Builder.class) +public final class DeidentifyAudioRequest { + private final String vaultId; + + private final DeidentifyAudioRequestFile file; + + private final Optional outputProcessedAudio; + + private final Optional outputTranscription; + + private final Optional bleepGain; + + private final Optional bleepFrequency; + + private final Optional bleepStartPadding; + + private final Optional bleepStopPadding; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyAudioRequest( + String vaultId, + DeidentifyAudioRequestFile file, + Optional outputProcessedAudio, + Optional outputTranscription, + Optional bleepGain, + Optional bleepFrequency, + Optional bleepStartPadding, + Optional bleepStopPadding, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.outputProcessedAudio = outputProcessedAudio; + this.outputTranscription = outputTranscription; + this.bleepGain = bleepGain; + this.bleepFrequency = bleepFrequency; + this.bleepStartPadding = bleepStartPadding; + this.bleepStopPadding = bleepStopPadding; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyAudioRequestFile getFile() { + return file; + } + + /** + * @return If true, includes processed audio file in the response. + */ + @JsonProperty("output_processed_audio") + public Optional getOutputProcessedAudio() { + return outputProcessedAudio; + } + + /** + * @return Type of transcription to output. + */ + @JsonProperty("output_transcription") + public Optional getOutputTranscription() { + return outputTranscription; + } + + /** + * @return Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it. + */ + @JsonProperty("bleep_gain") + public Optional getBleepGain() { + return bleepGain; + } + + /** + * @return The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch. + */ + @JsonProperty("bleep_frequency") + public Optional getBleepFrequency() { + return bleepFrequency; + } + + /** + * @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_stop_padding") + public Optional getBleepStopPadding() { + return bleepStopPadding; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyAudioRequest && equalTo((DeidentifyAudioRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyAudioRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && outputProcessedAudio.equals(other.outputProcessedAudio) + && outputTranscription.equals(other.outputTranscription) + && bleepGain.equals(other.bleepGain) + && bleepFrequency.equals(other.bleepFrequency) + && bleepStartPadding.equals(other.bleepStartPadding) + && bleepStopPadding.equals(other.bleepStopPadding) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.outputProcessedAudio, + this.outputTranscription, + this.bleepGain, + this.bleepFrequency, + this.bleepStartPadding, + this.bleepStopPadding, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyAudioRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyAudioRequestFile file); + } + + public interface _FinalStage { + DeidentifyAudioRequest build(); + + /** + *

If true, includes processed audio file in the response.

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

Type of transcription to output.

+ */ + _FinalStage outputTranscription(Optional outputTranscription); + + _FinalStage outputTranscription(DeidentifyAudioRequestOutputTranscription outputTranscription); + + /** + *

Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it.

+ */ + _FinalStage bleepGain(Optional bleepGain); + + _FinalStage bleepGain(Double bleepGain); + + /** + *

The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch.

+ */ + _FinalStage bleepFrequency(Optional bleepFrequency); + + _FinalStage bleepFrequency(Double bleepFrequency); + + /** + *

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

+ */ + _FinalStage bleepStartPadding(Optional bleepStartPadding); + + _FinalStage bleepStartPadding(Double bleepStartPadding); + + /** + *

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

+ */ + _FinalStage bleepStopPadding(Optional bleepStopPadding); + + _FinalStage bleepStopPadding(Double bleepStopPadding); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyAudioRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + private Optional bleepStopPadding = Optional.empty(); + + private Optional bleepStartPadding = Optional.empty(); + + private Optional bleepFrequency = Optional.empty(); + + private Optional bleepGain = Optional.empty(); + + private Optional outputTranscription = Optional.empty(); + + private Optional outputProcessedAudio = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyAudioRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + outputProcessedAudio(other.getOutputProcessedAudio()); + outputTranscription(other.getOutputTranscription()); + bleepGain(other.getBleepGain()); + bleepFrequency(other.getBleepFrequency()); + bleepStartPadding(other.getBleepStartPadding()); + bleepStopPadding(other.getBleepStopPadding()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyAudioRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + /** + *

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

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

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

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

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

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

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

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

The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch.

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

The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch.

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

Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it.

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

Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it.

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

Type of transcription to output.

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

Type of transcription to output.

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

If true, includes processed audio file in the response.

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

If true, includes processed audio file in the response.

+ */ + @Override + @JsonSetter(value = "output_processed_audio", nulls = Nulls.SKIP) + public _FinalStage outputProcessedAudio(Optional outputProcessedAudio) { + this.outputProcessedAudio = outputProcessedAudio; + return this; + } + + @Override + public DeidentifyAudioRequest build() { + return new DeidentifyAudioRequest( + vaultId, + file, + outputProcessedAudio, + outputTranscription, + bleepGain, + bleepFrequency, + bleepStartPadding, + bleepStopPadding, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java new file mode 100644 index 00000000..80e8fff1 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java @@ -0,0 +1,310 @@ +/** + * 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.DeidentifyDocumentRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyDocumentRequest.Builder.class) +public final class DeidentifyDocumentRequest { + private final String vaultId; + + private final DeidentifyDocumentRequestFile file; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyDocumentRequest( + String vaultId, + DeidentifyDocumentRequestFile file, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyDocumentRequestFile getFile() { + return file; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyDocumentRequest && equalTo((DeidentifyDocumentRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyDocumentRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyDocumentRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyDocumentRequestFile file); + } + + public interface _FinalStage { + DeidentifyDocumentRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyDocumentRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyDocumentRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyDocumentRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifyDocumentRequest build() { + return new DeidentifyDocumentRequest( + vaultId, + file, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java new file mode 100644 index 00000000..bd8ec3a7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java @@ -0,0 +1,310 @@ +/** + * 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.DeidentifyFileRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyFileRequest.Builder.class) +public final class DeidentifyFileRequest { + private final String vaultId; + + private final DeidentifyFileRequestFile file; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyFileRequest( + String vaultId, + DeidentifyFileRequestFile file, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyFileRequestFile getFile() { + return file; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyFileRequest && equalTo((DeidentifyFileRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyFileRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyFileRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyFileRequestFile file); + } + + public interface _FinalStage { + DeidentifyFileRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyFileRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyFileRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyFileRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifyFileRequest build() { + return new DeidentifyFileRequest( + vaultId, + file, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java new file mode 100644 index 00000000..94159f02 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java @@ -0,0 +1,446 @@ +/** + * 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.DeidentifyImageRequestFile; +import com.skyflow.generated.rest.resources.files.types.DeidentifyImageRequestMaskingMethod; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyImageRequest.Builder.class) +public final class DeidentifyImageRequest { + private final String vaultId; + + private final DeidentifyImageRequestFile file; + + private final Optional outputProcessedImage; + + private final Optional outputOcrText; + + private final Optional maskingMethod; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyImageRequest( + String vaultId, + DeidentifyImageRequestFile file, + Optional outputProcessedImage, + Optional outputOcrText, + Optional maskingMethod, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.outputProcessedImage = outputProcessedImage; + this.outputOcrText = outputOcrText; + this.maskingMethod = maskingMethod; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyImageRequestFile getFile() { + return file; + } + + /** + * @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; + } + + /** + * @return Method to mask the entities in the image. + */ + @JsonProperty("masking_method") + public Optional getMaskingMethod() { + return maskingMethod; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyImageRequest && equalTo((DeidentifyImageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyImageRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && outputProcessedImage.equals(other.outputProcessedImage) + && outputOcrText.equals(other.outputOcrText) + && maskingMethod.equals(other.maskingMethod) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.outputProcessedImage, + this.outputOcrText, + this.maskingMethod, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyImageRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyImageRequestFile file); + } + + public interface _FinalStage { + DeidentifyImageRequest build(); + + /** + *

If true, includes processed image in the output.

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

If true, includes OCR text output in the response.

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

Method to mask the entities in the image.

+ */ + _FinalStage maskingMethod(Optional maskingMethod); + + _FinalStage maskingMethod(DeidentifyImageRequestMaskingMethod maskingMethod); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyImageRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + private Optional maskingMethod = Optional.empty(); + + private Optional outputOcrText = Optional.empty(); + + private Optional outputProcessedImage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyImageRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + outputProcessedImage(other.getOutputProcessedImage()); + outputOcrText(other.getOutputOcrText()); + maskingMethod(other.getMaskingMethod()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyImageRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + /** + *

Method to mask the entities in the image.

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

Method to mask the entities in the image.

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

If true, includes OCR text output in the response.

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

If true, includes OCR text output in the response.

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

If true, includes processed image in the output.

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

If true, includes processed image in the output.

+ */ + @Override + @JsonSetter(value = "output_processed_image", nulls = Nulls.SKIP) + public _FinalStage outputProcessedImage(Optional outputProcessedImage) { + this.outputProcessedImage = outputProcessedImage; + return this; + } + + @Override + public DeidentifyImageRequest build() { + return new DeidentifyImageRequest( + vaultId, + file, + outputProcessedImage, + outputOcrText, + maskingMethod, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java new file mode 100644 index 00000000..624bc497 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java @@ -0,0 +1,400 @@ +/** + * 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.DeidentifyPdfRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyPdfRequest.Builder.class) +public final class DeidentifyPdfRequest { + private final String vaultId; + + private final DeidentifyPdfRequestFile file; + + private final Optional density; + + private final Optional maxResolution; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyPdfRequest( + String vaultId, + DeidentifyPdfRequestFile file, + Optional density, + Optional maxResolution, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.density = density; + this.maxResolution = maxResolution; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyPdfRequestFile getFile() { + return file; + } + + /** + * @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; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyPdfRequest && equalTo((DeidentifyPdfRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyPdfRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && density.equals(other.density) + && maxResolution.equals(other.maxResolution) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.density, + this.maxResolution, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyPdfRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyPdfRequestFile file); + } + + public interface _FinalStage { + DeidentifyPdfRequest build(); + + /** + *

Pixel density at which to process the PDF file.

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

Max resolution at which to process the PDF file.

+ */ + _FinalStage maxResolution(Optional maxResolution); + + _FinalStage maxResolution(Integer maxResolution); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyPdfRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + private Optional maxResolution = Optional.empty(); + + private Optional density = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyPdfRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + density(other.getDensity()); + maxResolution(other.getMaxResolution()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyPdfRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + /** + *

Max resolution at which to process the PDF file.

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

Max resolution at which to process the PDF file.

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

Pixel density at which to process the PDF file.

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

Pixel density at which to process the PDF file.

+ */ + @Override + @JsonSetter(value = "density", nulls = Nulls.SKIP) + public _FinalStage density(Optional density) { + this.density = density; + return this; + } + + @Override + public DeidentifyPdfRequest build() { + return new DeidentifyPdfRequest( + vaultId, + file, + density, + maxResolution, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java new file mode 100644 index 00000000..127becec --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java @@ -0,0 +1,310 @@ +/** + * 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.DeidentifyPresentationRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyPresentationRequest.Builder.class) +public final class DeidentifyPresentationRequest { + private final String vaultId; + + private final DeidentifyPresentationRequestFile file; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyPresentationRequest( + String vaultId, + DeidentifyPresentationRequestFile file, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyPresentationRequestFile getFile() { + return file; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyPresentationRequest && equalTo((DeidentifyPresentationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyPresentationRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyPresentationRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyPresentationRequestFile file); + } + + public interface _FinalStage { + DeidentifyPresentationRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyPresentationRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyPresentationRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyPresentationRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifyPresentationRequest build() { + return new DeidentifyPresentationRequest( + vaultId, + file, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java new file mode 100644 index 00000000..33d1f705 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java @@ -0,0 +1,310 @@ +/** + * 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.DeidentifySpreadsheetRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifySpreadsheetRequest.Builder.class) +public final class DeidentifySpreadsheetRequest { + private final String vaultId; + + private final DeidentifySpreadsheetRequestFile file; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifySpreadsheetRequest( + String vaultId, + DeidentifySpreadsheetRequestFile file, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifySpreadsheetRequestFile getFile() { + return file; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifySpreadsheetRequest && equalTo((DeidentifySpreadsheetRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifySpreadsheetRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifySpreadsheetRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifySpreadsheetRequestFile file); + } + + public interface _FinalStage { + DeidentifySpreadsheetRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifySpreadsheetRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifySpreadsheetRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifySpreadsheetRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifySpreadsheetRequest build() { + return new DeidentifySpreadsheetRequest( + vaultId, + file, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java new file mode 100644 index 00000000..38521a18 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java @@ -0,0 +1,310 @@ +/** + * 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.DeidentifyStructuredTextRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyStructuredTextRequest.Builder.class) +public final class DeidentifyStructuredTextRequest { + private final String vaultId; + + private final DeidentifyStructuredTextRequestFile file; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyStructuredTextRequest( + String vaultId, + DeidentifyStructuredTextRequestFile file, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyStructuredTextRequestFile getFile() { + return file; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyStructuredTextRequest && equalTo((DeidentifyStructuredTextRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyStructuredTextRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyStructuredTextRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyStructuredTextRequestFile file); + } + + public interface _FinalStage { + DeidentifyStructuredTextRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyStructuredTextRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyStructuredTextRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyStructuredTextRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifyStructuredTextRequest build() { + return new DeidentifyStructuredTextRequest( + vaultId, + file, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java new file mode 100644 index 00000000..5c6572b9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java @@ -0,0 +1,310 @@ +/** + * 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.DeidentifyTextRequestFile; +import com.skyflow.generated.rest.types.EntityType; +import com.skyflow.generated.rest.types.TokenTypeWithoutVault; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyTextRequest.Builder.class) +public final class DeidentifyTextRequest { + private final String vaultId; + + private final DeidentifyTextRequestFile file; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyTextRequest( + String vaultId, + DeidentifyTextRequestFile file, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.file = file; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return File to de-identify. Files are specified as Base64-encoded data. + */ + @JsonProperty("file") + public DeidentifyTextRequestFile getFile() { + return file; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyTextRequest && equalTo((DeidentifyTextRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyTextRequest other) { + return vaultId.equals(other.vaultId) + && file.equals(other.file) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.file, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyTextRequest other); + } + + public interface FileStage { + /** + * File to de-identify. Files are specified as Base64-encoded data. + */ + _FinalStage file(@NotNull DeidentifyTextRequestFile file); + } + + public interface _FinalStage { + DeidentifyTextRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenTypeWithoutVault tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, FileStage, _FinalStage { + private String vaultId; + + private DeidentifyTextRequestFile file; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyTextRequest other) { + vaultId(other.getVaultId()); + file(other.getFile()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public FileStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * File to de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("file") + public _FinalStage file(@NotNull DeidentifyTextRequestFile file) { + this.file = Objects.requireNonNull(file, "file must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenTypeWithoutVault tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifyTextRequest build() { + return new DeidentifyTextRequest( + vaultId, + file, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java new file mode 100644 index 00000000..c1a4051c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java @@ -0,0 +1,112 @@ +/** + * 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.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 = GetRunRequest.Builder.class) +public final class GetRunRequest { + private final String vaultId; + + private final Map additionalProperties; + + private GetRunRequest(String vaultId, Map additionalProperties) { + this.vaultId = vaultId; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault. + */ + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetRunRequest && equalTo((GetRunRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetRunRequest other) { + return vaultId.equals(other.vaultId); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static VaultIdStage builder() { + return new Builder(); + } + + public interface VaultIdStage { + /** + * ID of the vault. + */ + _FinalStage vaultId(@NotNull String vaultId); + + Builder from(GetRunRequest other); + } + + public interface _FinalStage { + GetRunRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, _FinalStage { + private String vaultId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(GetRunRequest other) { + vaultId(other.getVaultId()); + return this; + } + + /** + * ID of the vault.

ID of the vault.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("vault_id") + public _FinalStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + @Override + public GetRunRequest build() { + return new GetRunRequest(vaultId, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java new file mode 100644 index 00000000..e45ced48 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.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 = DeidentifyAudioRequestFile.Builder.class) +public final class DeidentifyAudioRequestFile { + private final String base64; + + private final DeidentifyAudioRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifyAudioRequestFile( + String base64, DeidentifyAudioRequestFileDataFormat dataFormat, Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifyAudioRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyAudioRequestFile && equalTo((DeidentifyAudioRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyAudioRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifyAudioRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifyAudioRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifyAudioRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifyAudioRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyAudioRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifyAudioRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifyAudioRequestFile build() { + return new DeidentifyAudioRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java new file mode 100644 index 00000000..1a9ac79a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyAudioRequestFileDataFormat { + MP_3("mp3"), + + WAV("wav"); + + private final String value; + + DeidentifyAudioRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java new file mode 100644 index 00000000..728e3d77 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyAudioRequestOutputTranscription { + DIARIZED_TRANSCRIPTION("diarized_transcription"), + + MEDICAL_DIARIZED_TRANSCRIPTION("medical_diarized_transcription"), + + MEDICAL_TRANSCRIPTION("medical_transcription"), + + PLAINTEXT_TRANSCRIPTION("plaintext_transcription"), + + TRANSCRIPTION("transcription"); + + private final String value; + + DeidentifyAudioRequestOutputTranscription(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java new file mode 100644 index 00000000..1bdeb84a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java @@ -0,0 +1,147 @@ +/** + * 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 = DeidentifyDocumentRequestFile.Builder.class) +public final class DeidentifyDocumentRequestFile { + private final String base64; + + private final DeidentifyDocumentRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifyDocumentRequestFile( + String base64, + DeidentifyDocumentRequestFileDataFormat dataFormat, + Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifyDocumentRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyDocumentRequestFile && equalTo((DeidentifyDocumentRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyDocumentRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifyDocumentRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifyDocumentRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifyDocumentRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifyDocumentRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyDocumentRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifyDocumentRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifyDocumentRequestFile build() { + return new DeidentifyDocumentRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java new file mode 100644 index 00000000..ea1e0930 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyDocumentRequestFileDataFormat { + DOC("doc"), + + DOCX("docx"), + + PDF("pdf"); + + private final String value; + + DeidentifyDocumentRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.java new file mode 100644 index 00000000..08e0bbb1 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.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 = DeidentifyFileRequestFile.Builder.class) +public final class DeidentifyFileRequestFile { + private final String base64; + + private final DeidentifyFileRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifyFileRequestFile( + String base64, DeidentifyFileRequestFileDataFormat dataFormat, Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifyFileRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyFileRequestFile && equalTo((DeidentifyFileRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyFileRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifyFileRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifyFileRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifyFileRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifyFileRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyFileRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifyFileRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifyFileRequestFile build() { + return new DeidentifyFileRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java new file mode 100644 index 00000000..6d42ba53 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyFileRequestFileDataFormat { + BMP("bmp"), + + 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"), + + WAV("wav"), + + XLS("xls"), + + XLSX("xlsx"), + + XML("xml"); + + private final String value; + + DeidentifyFileRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.java new file mode 100644 index 00000000..89a54aaf --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.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 = DeidentifyImageRequestFile.Builder.class) +public final class DeidentifyImageRequestFile { + private final String base64; + + private final DeidentifyImageRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifyImageRequestFile( + String base64, DeidentifyImageRequestFileDataFormat dataFormat, Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifyImageRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyImageRequestFile && equalTo((DeidentifyImageRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyImageRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifyImageRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifyImageRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifyImageRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifyImageRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyImageRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifyImageRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifyImageRequestFile build() { + return new DeidentifyImageRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java new file mode 100644 index 00000000..27e241d6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyImageRequestFileDataFormat { + BMP("bmp"), + + JPEG("jpeg"), + + JPG("jpg"), + + PNG("png"), + + TIF("tif"), + + TIFF("tiff"); + + private final String value; + + DeidentifyImageRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java new file mode 100644 index 00000000..e4a0fd19 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyImageRequestMaskingMethod { + BLACKBOX("blackbox"), + + BLUR("blur"); + + private final String value; + + DeidentifyImageRequestMaskingMethod(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java new file mode 100644 index 00000000..1d9bb8d9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java @@ -0,0 +1,120 @@ +/** + * 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 = DeidentifyPdfRequestFile.Builder.class) +public final class DeidentifyPdfRequestFile { + private final String base64; + + private final Map additionalProperties; + + private DeidentifyPdfRequestFile(String base64, Map additionalProperties) { + this.base64 = base64; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public String getDataFormat() { + return "pdf"; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyPdfRequestFile && equalTo((DeidentifyPdfRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyPdfRequestFile other) { + return base64.equals(other.base64); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64); + } + + @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 de-identify. + */ + _FinalStage base64(@NotNull String base64); + + Builder from(DeidentifyPdfRequestFile other); + } + + public interface _FinalStage { + DeidentifyPdfRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, _FinalStage { + private String base64; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyPdfRequestFile other) { + base64(other.getBase64()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("base64") + public _FinalStage base64(@NotNull String base64) { + this.base64 = Objects.requireNonNull(base64, "base64 must not be null"); + return this; + } + + @Override + public DeidentifyPdfRequestFile build() { + return new DeidentifyPdfRequestFile(base64, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java new file mode 100644 index 00000000..60a013ce --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java @@ -0,0 +1,147 @@ +/** + * 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 = DeidentifyPresentationRequestFile.Builder.class) +public final class DeidentifyPresentationRequestFile { + private final String base64; + + private final DeidentifyPresentationRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifyPresentationRequestFile( + String base64, + DeidentifyPresentationRequestFileDataFormat dataFormat, + Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifyPresentationRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyPresentationRequestFile && equalTo((DeidentifyPresentationRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyPresentationRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifyPresentationRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifyPresentationRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifyPresentationRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifyPresentationRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyPresentationRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifyPresentationRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifyPresentationRequestFile build() { + return new DeidentifyPresentationRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java new file mode 100644 index 00000000..7770a61e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyPresentationRequestFileDataFormat { + PPT("ppt"), + + PPTX("pptx"); + + private final String value; + + DeidentifyPresentationRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java new file mode 100644 index 00000000..b749ebe0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java @@ -0,0 +1,147 @@ +/** + * 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 = DeidentifySpreadsheetRequestFile.Builder.class) +public final class DeidentifySpreadsheetRequestFile { + private final String base64; + + private final DeidentifySpreadsheetRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifySpreadsheetRequestFile( + String base64, + DeidentifySpreadsheetRequestFileDataFormat dataFormat, + Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifySpreadsheetRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifySpreadsheetRequestFile && equalTo((DeidentifySpreadsheetRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifySpreadsheetRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifySpreadsheetRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifySpreadsheetRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifySpreadsheetRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifySpreadsheetRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifySpreadsheetRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifySpreadsheetRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifySpreadsheetRequestFile build() { + return new DeidentifySpreadsheetRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java new file mode 100644 index 00000000..c44e4fb2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifySpreadsheetRequestFileDataFormat { + CSV("csv"), + + XLS("xls"), + + XLSX("xlsx"); + + private final String value; + + DeidentifySpreadsheetRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java new file mode 100644 index 00000000..14b34a29 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java @@ -0,0 +1,148 @@ +/** + * 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 = DeidentifyStructuredTextRequestFile.Builder.class) +public final class DeidentifyStructuredTextRequestFile { + private final String base64; + + private final DeidentifyStructuredTextRequestFileDataFormat dataFormat; + + private final Map additionalProperties; + + private DeidentifyStructuredTextRequestFile( + String base64, + DeidentifyStructuredTextRequestFileDataFormat dataFormat, + Map additionalProperties) { + this.base64 = base64; + this.dataFormat = dataFormat; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public DeidentifyStructuredTextRequestFileDataFormat getDataFormat() { + return dataFormat; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyStructuredTextRequestFile + && equalTo((DeidentifyStructuredTextRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyStructuredTextRequestFile other) { + return base64.equals(other.base64) && dataFormat.equals(other.dataFormat); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64, this.dataFormat); + } + + @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 de-identify. + */ + DataFormatStage base64(@NotNull String base64); + + Builder from(DeidentifyStructuredTextRequestFile other); + } + + public interface DataFormatStage { + /** + * Data format of the file. + */ + _FinalStage dataFormat(@NotNull DeidentifyStructuredTextRequestFileDataFormat dataFormat); + } + + public interface _FinalStage { + DeidentifyStructuredTextRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { + private String base64; + + private DeidentifyStructuredTextRequestFileDataFormat dataFormat; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyStructuredTextRequestFile other) { + base64(other.getBase64()); + dataFormat(other.getDataFormat()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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. + */ + @Override + @JsonSetter("data_format") + public _FinalStage dataFormat(@NotNull DeidentifyStructuredTextRequestFileDataFormat dataFormat) { + this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); + return this; + } + + @Override + public DeidentifyStructuredTextRequestFile build() { + return new DeidentifyStructuredTextRequestFile(base64, dataFormat, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java new file mode 100644 index 00000000..8182b567 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DeidentifyStructuredTextRequestFileDataFormat { + JSON("json"), + + XML("xml"); + + private final String value; + + DeidentifyStructuredTextRequestFileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java new file mode 100644 index 00000000..953a9075 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java @@ -0,0 +1,120 @@ +/** + * 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 = DeidentifyTextRequestFile.Builder.class) +public final class DeidentifyTextRequestFile { + private final String base64; + + private final Map additionalProperties; + + private DeidentifyTextRequestFile(String base64, Map additionalProperties) { + this.base64 = base64; + this.additionalProperties = additionalProperties; + } + + /** + * @return Base64-encoded data of the file to de-identify. + */ + @JsonProperty("base64") + public String getBase64() { + return base64; + } + + /** + * @return Data format of the file. + */ + @JsonProperty("data_format") + public String getDataFormat() { + return "txt"; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyTextRequestFile && equalTo((DeidentifyTextRequestFile) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyTextRequestFile other) { + return base64.equals(other.base64); + } + + @Override + public int hashCode() { + return Objects.hash(this.base64); + } + + @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 de-identify. + */ + _FinalStage base64(@NotNull String base64); + + Builder from(DeidentifyTextRequestFile other); + } + + public interface _FinalStage { + DeidentifyTextRequestFile build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements Base64Stage, _FinalStage { + private String base64; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyTextRequestFile other) { + base64(other.getBase64()); + return this; + } + + /** + * Base64-encoded data of the file to de-identify.

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

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("base64") + public _FinalStage base64(@NotNull String base64) { + this.base64 = Objects.requireNonNull(base64, "base64 must not be null"); + return this; + } + + @Override + public DeidentifyTextRequestFile build() { + return new DeidentifyTextRequestFile(base64, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java new file mode 100644 index 00000000..894c97b5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java @@ -0,0 +1,53 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.query; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; +import com.skyflow.generated.rest.types.V1GetQueryResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncQueryClient { + protected final ClientOptions clientOptions; + + private final AsyncRawQueryClient rawClient; + + public AsyncQueryClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawQueryClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawQueryClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public CompletableFuture queryServiceExecuteQuery(String vaultId) { + return this.rawClient.queryServiceExecuteQuery(vaultId).thenApply(response -> response.body()); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public CompletableFuture queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request) { + return this.rawClient.queryServiceExecuteQuery(vaultId, request).thenApply(response -> response.body()); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public CompletableFuture queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { + return this.rawClient + .queryServiceExecuteQuery(vaultId, request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java new file mode 100644 index 00000000..96e2dc0b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java @@ -0,0 +1,121 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.query; + +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.NotFoundError; +import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; +import com.skyflow.generated.rest.types.V1GetQueryResponse; +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 AsyncRawQueryClient { + protected final ClientOptions clientOptions; + + public AsyncRawQueryClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public CompletableFuture> queryServiceExecuteQuery(String vaultId) { + return queryServiceExecuteQuery( + vaultId, QueryServiceExecuteQueryBody.builder().build()); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public CompletableFuture> queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request) { + return queryServiceExecuteQuery(vaultId, request, null); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public CompletableFuture> queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegments("query") + .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(), V1GetQueryResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java new file mode 100644 index 00000000..39bb709d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.query; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; +import com.skyflow.generated.rest.types.V1GetQueryResponse; + +public class QueryClient { + protected final ClientOptions clientOptions; + + private final RawQueryClient rawClient; + + public QueryClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawQueryClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawQueryClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public V1GetQueryResponse queryServiceExecuteQuery(String vaultId) { + return this.rawClient.queryServiceExecuteQuery(vaultId).body(); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public V1GetQueryResponse queryServiceExecuteQuery(String vaultId, QueryServiceExecuteQueryBody request) { + return this.rawClient.queryServiceExecuteQuery(vaultId, request).body(); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public V1GetQueryResponse queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { + return this.rawClient + .queryServiceExecuteQuery(vaultId, request, requestOptions) + .body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java new file mode 100644 index 00000000..3e5bee51 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.query; + +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.NotFoundError; +import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; +import com.skyflow.generated.rest.types.V1GetQueryResponse; +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 RawQueryClient { + protected final ClientOptions clientOptions; + + public RawQueryClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public ApiClientHttpResponse queryServiceExecuteQuery(String vaultId) { + return queryServiceExecuteQuery( + vaultId, QueryServiceExecuteQueryBody.builder().build()); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public ApiClientHttpResponse queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request) { + return queryServiceExecuteQuery(vaultId, request, null); + } + + /** + * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> + */ + public ApiClientHttpResponse queryServiceExecuteQuery( + String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegments("query") + .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(), V1GetQueryResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java b/v2/src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java new file mode 100644 index 00000000..60565eb5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.query.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 = QueryServiceExecuteQueryBody.Builder.class) +public final class QueryServiceExecuteQueryBody { + private final Optional query; + + private final Map additionalProperties; + + private QueryServiceExecuteQueryBody(Optional query, Map additionalProperties) { + this.query = query; + this.additionalProperties = additionalProperties; + } + + /** + * @return The SQL query to execute.<br><br><b>Supported commands:</b> <ul> <li><code>SELECT</code></li> </ul> <b>Supported operators:</b> <ul> <li><code>></code></li> <li><code><</code></li> <li><code>=</code></li> <li><code>AND</code></li> <li><code>OR</code></li> <li><code>NOT</code></li> <li><code>LIKE</code></li> <li><code>ILIKE</code></li> <li><code>NULL</code></li> <li><code>NOT NULL</code></li> </ul> <b>Supported keywords:</b> <ul> <li><code>FROM</code></li> <li><code>JOIN</code></li> <li><code>INNER JOIN</code></li> <li><code>LEFT OUTER JOIN</code></li> <li><code>LEFT JOIN</code></li> <li><code>RIGHT OUTER JOIN</code></li> <li><code>RIGHT JOIN</code></li> <li><code>FULL OUTER JOIN</code></li> <li><code>FULL JOIN</code></li> <li><code>OFFSET</code></li> <li><code>LIMIT</code></li> <li><code>WHERE</code></li> </ul> <b>Supported functions:</b> <ul> <li><code>AVG()</code></li> <li><code>SUM()</code></li> <li><code>COUNT()</code></li> <li><code>MIN()</code></li> <li><code>MAX()</code></li> <li><code>REDACTION()</code></li> </ul> + */ + @JsonProperty("query") + public Optional getQuery() { + return query; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof QueryServiceExecuteQueryBody && equalTo((QueryServiceExecuteQueryBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(QueryServiceExecuteQueryBody other) { + return query.equals(other.query); + } + + @Override + public int hashCode() { + return Objects.hash(this.query); + } + + @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 query = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(QueryServiceExecuteQueryBody other) { + query(other.getQuery()); + return this; + } + + /** + *

The SQL query to execute.<br><br><b>Supported commands:</b> <ul> <li><code>SELECT</code></li> </ul> <b>Supported operators:</b> <ul> <li><code>></code></li> <li><code><</code></li> <li><code>=</code></li> <li><code>AND</code></li> <li><code>OR</code></li> <li><code>NOT</code></li> <li><code>LIKE</code></li> <li><code>ILIKE</code></li> <li><code>NULL</code></li> <li><code>NOT NULL</code></li> </ul> <b>Supported keywords:</b> <ul> <li><code>FROM</code></li> <li><code>JOIN</code></li> <li><code>INNER JOIN</code></li> <li><code>LEFT OUTER JOIN</code></li> <li><code>LEFT JOIN</code></li> <li><code>RIGHT OUTER JOIN</code></li> <li><code>RIGHT JOIN</code></li> <li><code>FULL OUTER JOIN</code></li> <li><code>FULL JOIN</code></li> <li><code>OFFSET</code></li> <li><code>LIMIT</code></li> <li><code>WHERE</code></li> </ul> <b>Supported functions:</b> <ul> <li><code>AVG()</code></li> <li><code>SUM()</code></li> <li><code>COUNT()</code></li> <li><code>MIN()</code></li> <li><code>MAX()</code></li> <li><code>REDACTION()</code></li> </ul>

+ */ + @JsonSetter(value = "query", nulls = Nulls.SKIP) + public Builder query(Optional query) { + this.query = query; + return this; + } + + public Builder query(String query) { + this.query = Optional.ofNullable(query); + return this; + } + + public QueryServiceExecuteQueryBody build() { + return new QueryServiceExecuteQueryBody(query, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java new file mode 100644 index 00000000..757ee8e4 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java @@ -0,0 +1,956 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records; + +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.records.requests.FileServiceUploadFileRequest; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkDeleteRecordBody; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; +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.types.V1BatchOperationResponse; +import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; +import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; +import com.skyflow.generated.rest.types.V1DeleteFileResponse; +import com.skyflow.generated.rest.types.V1DeleteRecordResponse; +import com.skyflow.generated.rest.types.V1FieldRecords; +import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; +import com.skyflow.generated.rest.types.V1InsertRecordResponse; +import com.skyflow.generated.rest.types.V1UpdateRecordResponse; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRecordsClient { + protected final ClientOptions clientOptions; + + public AsyncRawRecordsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Performs multiple record operations in a single transaction. + */ + public CompletableFuture> recordServiceBatchOperation( + String vaultId) { + return recordServiceBatchOperation( + vaultId, RecordServiceBatchOperationBody.builder().build()); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public CompletableFuture> recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request) { + return recordServiceBatchOperation(vaultId, request, null); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public CompletableFuture> recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .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(), V1BatchOperationResponse.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; + } + + /** + * Gets the specified records from a table. + */ + public CompletableFuture> recordServiceBulkGetRecord( + String vaultId, String objectName) { + return recordServiceBulkGetRecord( + vaultId, objectName, RecordServiceBulkGetRecordRequest.builder().build()); + } + + /** + * Gets the specified records from a table. + */ + public CompletableFuture> recordServiceBulkGetRecord( + String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { + return recordServiceBulkGetRecord(vaultId, objectName, request, null); + } + + /** + * Gets the specified records from a table. + */ + public CompletableFuture> recordServiceBulkGetRecord( + String vaultId, + String objectName, + RecordServiceBulkGetRecordRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName); + if (request.getRedaction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redaction", request.getRedaction().get(), false); + } + if (request.getTokenization().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tokenization", request.getTokenization().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getDownloadUrl().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "downloadURL", request.getDownloadUrl().get(), false); + } + if (request.getColumnName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "column_name", request.getColumnName().get(), false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get(), false); + } + if (request.getSkyflowIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "skyflow_ids", request.getSkyflowIds().get(), true); + } + if (request.getFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "fields", request.getFields().get(), true); + } + if (request.getColumnValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "column_values", request.getColumnValues().get(), true); + } + 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(), V1BulkGetRecordResponse.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; + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public CompletableFuture> recordServiceInsertRecord( + String vaultId, String objectName) { + return recordServiceInsertRecord( + vaultId, objectName, RecordServiceInsertRecordBody.builder().build()); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public CompletableFuture> recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request) { + return recordServiceInsertRecord(vaultId, objectName, request, null); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public CompletableFuture> recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .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(), V1InsertRecordResponse.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; + } + + /** + * Deletes the specified records from a table. + */ + public CompletableFuture> recordServiceBulkDeleteRecord( + String vaultId, String objectName) { + return recordServiceBulkDeleteRecord( + vaultId, objectName, RecordServiceBulkDeleteRecordBody.builder().build()); + } + + /** + * Deletes the specified records from a table. + */ + public CompletableFuture> recordServiceBulkDeleteRecord( + String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { + return recordServiceBulkDeleteRecord(vaultId, objectName, request, null); + } + + /** + * Deletes the specified records from a table. + */ + public CompletableFuture> recordServiceBulkDeleteRecord( + String vaultId, + String objectName, + RecordServiceBulkDeleteRecordBody request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .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("DELETE", 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(), V1BulkDeleteRecordResponse.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; + } + + /** + * Returns the specified record from a table. + */ + public CompletableFuture> recordServiceGetRecord( + String vaultId, String objectName, String id) { + return recordServiceGetRecord( + vaultId, objectName, id, RecordServiceGetRecordRequest.builder().build()); + } + + /** + * Returns the specified record from a table. + */ + public CompletableFuture> recordServiceGetRecord( + String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { + return recordServiceGetRecord(vaultId, objectName, id, request, null); + } + + /** + * Returns the specified record from a table. + */ + public CompletableFuture> recordServiceGetRecord( + String vaultId, + String objectName, + String id, + RecordServiceGetRecordRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id); + if (request.getRedaction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redaction", request.getRedaction().get(), false); + } + if (request.getTokenization().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tokenization", request.getTokenization().get(), false); + } + if (request.getDownloadUrl().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "downloadURL", request.getDownloadUrl().get(), false); + } + if (request.getFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "fields", request.getFields().get(), true); + } + 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(), V1FieldRecords.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; + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public CompletableFuture> recordServiceUpdateRecord( + String vaultId, String objectName, String id) { + return recordServiceUpdateRecord( + vaultId, objectName, id, RecordServiceUpdateRecordBody.builder().build()); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public CompletableFuture> recordServiceUpdateRecord( + String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { + return recordServiceUpdateRecord(vaultId, objectName, id, request, null); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public CompletableFuture> recordServiceUpdateRecord( + String vaultId, + String objectName, + String id, + RecordServiceUpdateRecordBody request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id) + .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("PUT", 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(), V1UpdateRecordResponse.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; + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public CompletableFuture> recordServiceDeleteRecord( + String vaultId, String objectName, String id) { + return recordServiceDeleteRecord(vaultId, objectName, id, null); + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public CompletableFuture> recordServiceDeleteRecord( + String vaultId, String objectName, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(), V1DeleteRecordResponse.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; + } + + /** + * Uploads a file to the specified record. + */ + public CompletableFuture> fileServiceUploadFile( + String vaultId, String objectName, String id, Optional fileColumnName) { + return fileServiceUploadFile( + vaultId, + objectName, + id, + fileColumnName, + FileServiceUploadFileRequest.builder().build()); + } + + /** + * 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); + } + + /** + * Uploads a file to the specified record. + */ + public CompletableFuture> fileServiceUploadFile( + String vaultId, + String objectName, + String id, + Optional fileColumnName, + FileServiceUploadFileRequest request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id) + .addPathSegments("files") + .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; + body.addFormDataPart( + "fileColumnName", + fileColumnName.get().getName(), + RequestBody.create(fileColumnName.get(), fileColumnNameMimeTypeMediaType)); + } + } 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(), V1UpdateRecordResponse.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; + } + + /** + * Deletes a file from the specified record. + */ + public CompletableFuture> fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName) { + return fileServiceDeleteFile(vaultId, tableName, id, columnName, null); + } + + /** + * Deletes a file from the specified record. + */ + public CompletableFuture> fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(tableName) + .addPathSegment(id) + .addPathSegments("files") + .addPathSegment(columnName) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(), V1DeleteFileResponse.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; + } + + /** + * Returns the anti-virus scan status of a file. + */ + public CompletableFuture> fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName) { + return fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, null); + } + + /** + * Returns the anti-virus scan status of a file. + */ + public CompletableFuture> fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(tableName) + .addPathSegment(id) + .addPathSegments("files") + .addPathSegment(columnName) + .addPathSegments("scan-status") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(), V1GetFileScanStatusResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java new file mode 100644 index 00000000..baf98c1d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java @@ -0,0 +1,317 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +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; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; +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.types.V1BatchOperationResponse; +import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; +import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; +import com.skyflow.generated.rest.types.V1DeleteFileResponse; +import com.skyflow.generated.rest.types.V1DeleteRecordResponse; +import com.skyflow.generated.rest.types.V1FieldRecords; +import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; +import com.skyflow.generated.rest.types.V1InsertRecordResponse; +import com.skyflow.generated.rest.types.V1UpdateRecordResponse; +import java.io.File; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncRecordsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRecordsClient rawClient; + + public AsyncRecordsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRecordsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRecordsClient withRawResponse() { + return this.rawClient; + } + + /** + * Performs multiple record operations in a single transaction. + */ + public CompletableFuture recordServiceBatchOperation(String vaultId) { + return this.rawClient.recordServiceBatchOperation(vaultId).thenApply(response -> response.body()); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public CompletableFuture recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request) { + return this.rawClient.recordServiceBatchOperation(vaultId, request).thenApply(response -> response.body()); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public CompletableFuture recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceBatchOperation(vaultId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Gets the specified records from a table. + */ + public CompletableFuture recordServiceBulkGetRecord(String vaultId, String objectName) { + return this.rawClient.recordServiceBulkGetRecord(vaultId, objectName).thenApply(response -> response.body()); + } + + /** + * Gets the specified records from a table. + */ + public CompletableFuture recordServiceBulkGetRecord( + String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { + return this.rawClient + .recordServiceBulkGetRecord(vaultId, objectName, request) + .thenApply(response -> response.body()); + } + + /** + * Gets the specified records from a table. + */ + public CompletableFuture recordServiceBulkGetRecord( + String vaultId, + String objectName, + RecordServiceBulkGetRecordRequest request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceBulkGetRecord(vaultId, objectName, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public CompletableFuture recordServiceInsertRecord(String vaultId, String objectName) { + return this.rawClient.recordServiceInsertRecord(vaultId, objectName).thenApply(response -> response.body()); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public CompletableFuture recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request) { + return this.rawClient + .recordServiceInsertRecord(vaultId, objectName, request) + .thenApply(response -> response.body()); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public CompletableFuture recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceInsertRecord(vaultId, objectName, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Deletes the specified records from a table. + */ + public CompletableFuture recordServiceBulkDeleteRecord( + String vaultId, String objectName) { + return this.rawClient.recordServiceBulkDeleteRecord(vaultId, objectName).thenApply(response -> response.body()); + } + + /** + * Deletes the specified records from a table. + */ + public CompletableFuture recordServiceBulkDeleteRecord( + String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { + return this.rawClient + .recordServiceBulkDeleteRecord(vaultId, objectName, request) + .thenApply(response -> response.body()); + } + + /** + * Deletes the specified records from a table. + */ + public CompletableFuture recordServiceBulkDeleteRecord( + String vaultId, + String objectName, + RecordServiceBulkDeleteRecordBody request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceBulkDeleteRecord(vaultId, objectName, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns the specified record from a table. + */ + public CompletableFuture recordServiceGetRecord(String vaultId, String objectName, String id) { + return this.rawClient.recordServiceGetRecord(vaultId, objectName, id).thenApply(response -> response.body()); + } + + /** + * Returns the specified record from a table. + */ + public CompletableFuture recordServiceGetRecord( + String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { + return this.rawClient + .recordServiceGetRecord(vaultId, objectName, id, request) + .thenApply(response -> response.body()); + } + + /** + * Returns the specified record from a table. + */ + public CompletableFuture recordServiceGetRecord( + String vaultId, + String objectName, + String id, + RecordServiceGetRecordRequest request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceGetRecord(vaultId, objectName, id, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public CompletableFuture recordServiceUpdateRecord( + String vaultId, String objectName, String id) { + return this.rawClient.recordServiceUpdateRecord(vaultId, objectName, id).thenApply(response -> response.body()); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public CompletableFuture recordServiceUpdateRecord( + String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { + return this.rawClient + .recordServiceUpdateRecord(vaultId, objectName, id, request) + .thenApply(response -> response.body()); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public CompletableFuture recordServiceUpdateRecord( + String vaultId, + String objectName, + String id, + RecordServiceUpdateRecordBody request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceUpdateRecord(vaultId, objectName, id, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public CompletableFuture recordServiceDeleteRecord( + String vaultId, String objectName, String id) { + return this.rawClient.recordServiceDeleteRecord(vaultId, objectName, id).thenApply(response -> response.body()); + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public CompletableFuture recordServiceDeleteRecord( + String vaultId, String objectName, String id, RequestOptions requestOptions) { + return this.rawClient + .recordServiceDeleteRecord(vaultId, objectName, id, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Uploads a file to the specified record. + */ + public CompletableFuture fileServiceUploadFile( + String vaultId, String objectName, String id, Optional fileColumnName) { + return this.rawClient + .fileServiceUploadFile(vaultId, objectName, id, fileColumnName) + .thenApply(response -> response.body()); + } + + /** + * Uploads a file to the specified record. + */ + public CompletableFuture fileServiceUploadFile( + String vaultId, + String objectName, + String id, + Optional fileColumnName, + FileServiceUploadFileRequest request) { + return this.rawClient + .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request) + .thenApply(response -> response.body()); + } + + /** + * Uploads a file to the specified record. + */ + public CompletableFuture fileServiceUploadFile( + String vaultId, + String objectName, + String id, + Optional fileColumnName, + FileServiceUploadFileRequest request, + RequestOptions requestOptions) { + return this.rawClient + .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Deletes a file from the specified record. + */ + public CompletableFuture fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName) { + return this.rawClient + .fileServiceDeleteFile(vaultId, tableName, id, columnName) + .thenApply(response -> response.body()); + } + + /** + * Deletes a file from the specified record. + */ + public CompletableFuture fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + return this.rawClient + .fileServiceDeleteFile(vaultId, tableName, id, columnName, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns the anti-virus scan status of a file. + */ + public CompletableFuture fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName) { + return this.rawClient + .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName) + .thenApply(response -> response.body()); + } + + /** + * Returns the anti-virus scan status of a file. + */ + public CompletableFuture fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + return this.rawClient + .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java new file mode 100644 index 00000000..593f5e3d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java @@ -0,0 +1,800 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records; + +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.records.requests.FileServiceUploadFileRequest; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkDeleteRecordBody; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; +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.types.V1BatchOperationResponse; +import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; +import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; +import com.skyflow.generated.rest.types.V1DeleteFileResponse; +import com.skyflow.generated.rest.types.V1DeleteRecordResponse; +import com.skyflow.generated.rest.types.V1FieldRecords; +import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; +import com.skyflow.generated.rest.types.V1InsertRecordResponse; +import com.skyflow.generated.rest.types.V1UpdateRecordResponse; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRecordsClient { + protected final ClientOptions clientOptions; + + public RawRecordsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Performs multiple record operations in a single transaction. + */ + public ApiClientHttpResponse recordServiceBatchOperation(String vaultId) { + return recordServiceBatchOperation( + vaultId, RecordServiceBatchOperationBody.builder().build()); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public ApiClientHttpResponse recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request) { + return recordServiceBatchOperation(vaultId, request, null); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public ApiClientHttpResponse recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .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(), V1BatchOperationResponse.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); + } + } + + /** + * Gets the specified records from a table. + */ + public ApiClientHttpResponse recordServiceBulkGetRecord( + String vaultId, String objectName) { + return recordServiceBulkGetRecord( + vaultId, objectName, RecordServiceBulkGetRecordRequest.builder().build()); + } + + /** + * Gets the specified records from a table. + */ + public ApiClientHttpResponse recordServiceBulkGetRecord( + String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { + return recordServiceBulkGetRecord(vaultId, objectName, request, null); + } + + /** + * Gets the specified records from a table. + */ + public ApiClientHttpResponse recordServiceBulkGetRecord( + String vaultId, + String objectName, + RecordServiceBulkGetRecordRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName); + if (request.getRedaction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redaction", request.getRedaction().get(), false); + } + if (request.getTokenization().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tokenization", request.getTokenization().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getDownloadUrl().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "downloadURL", request.getDownloadUrl().get(), false); + } + if (request.getColumnName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "column_name", request.getColumnName().get(), false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get(), false); + } + if (request.getSkyflowIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "skyflow_ids", request.getSkyflowIds().get(), true); + } + if (request.getFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "fields", request.getFields().get(), true); + } + if (request.getColumnValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "column_values", request.getColumnValues().get(), true); + } + 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(), V1BulkGetRecordResponse.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); + } + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public ApiClientHttpResponse recordServiceInsertRecord(String vaultId, String objectName) { + return recordServiceInsertRecord( + vaultId, objectName, RecordServiceInsertRecordBody.builder().build()); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public ApiClientHttpResponse recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request) { + return recordServiceInsertRecord(vaultId, objectName, request, null); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public ApiClientHttpResponse recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .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(), V1InsertRecordResponse.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); + } + } + + /** + * Deletes the specified records from a table. + */ + public ApiClientHttpResponse recordServiceBulkDeleteRecord( + String vaultId, String objectName) { + return recordServiceBulkDeleteRecord( + vaultId, objectName, RecordServiceBulkDeleteRecordBody.builder().build()); + } + + /** + * Deletes the specified records from a table. + */ + public ApiClientHttpResponse recordServiceBulkDeleteRecord( + String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { + return recordServiceBulkDeleteRecord(vaultId, objectName, request, null); + } + + /** + * Deletes the specified records from a table. + */ + public ApiClientHttpResponse recordServiceBulkDeleteRecord( + String vaultId, + String objectName, + RecordServiceBulkDeleteRecordBody request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .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("DELETE", 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(), V1BulkDeleteRecordResponse.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); + } + } + + /** + * Returns the specified record from a table. + */ + public ApiClientHttpResponse recordServiceGetRecord(String vaultId, String objectName, String id) { + return recordServiceGetRecord( + vaultId, objectName, id, RecordServiceGetRecordRequest.builder().build()); + } + + /** + * Returns the specified record from a table. + */ + public ApiClientHttpResponse recordServiceGetRecord( + String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { + return recordServiceGetRecord(vaultId, objectName, id, request, null); + } + + /** + * Returns the specified record from a table. + */ + public ApiClientHttpResponse recordServiceGetRecord( + String vaultId, + String objectName, + String id, + RecordServiceGetRecordRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id); + if (request.getRedaction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redaction", request.getRedaction().get(), false); + } + if (request.getTokenization().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tokenization", request.getTokenization().get(), false); + } + if (request.getDownloadUrl().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "downloadURL", request.getDownloadUrl().get(), false); + } + if (request.getFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "fields", request.getFields().get(), true); + } + 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(), V1FieldRecords.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); + } + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public ApiClientHttpResponse recordServiceUpdateRecord( + String vaultId, String objectName, String id) { + return recordServiceUpdateRecord( + vaultId, objectName, id, RecordServiceUpdateRecordBody.builder().build()); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public ApiClientHttpResponse recordServiceUpdateRecord( + String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { + return recordServiceUpdateRecord(vaultId, objectName, id, request, null); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public ApiClientHttpResponse recordServiceUpdateRecord( + String vaultId, + String objectName, + String id, + RecordServiceUpdateRecordBody request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id) + .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("PUT", 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(), V1UpdateRecordResponse.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); + } + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public ApiClientHttpResponse recordServiceDeleteRecord( + String vaultId, String objectName, String id) { + return recordServiceDeleteRecord(vaultId, objectName, id, null); + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public ApiClientHttpResponse recordServiceDeleteRecord( + String vaultId, String objectName, String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(), V1DeleteRecordResponse.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); + } + } + + /** + * Uploads a file to the specified record. + */ + public ApiClientHttpResponse fileServiceUploadFile( + String vaultId, String objectName, String id, Optional fileColumnName) { + return fileServiceUploadFile( + vaultId, + objectName, + id, + fileColumnName, + FileServiceUploadFileRequest.builder().build()); + } + + /** + * 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); + } + + /** + * Uploads a file to the specified record. + */ + public ApiClientHttpResponse fileServiceUploadFile( + String vaultId, + String objectName, + String id, + Optional fileColumnName, + FileServiceUploadFileRequest request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(objectName) + .addPathSegment(id) + .addPathSegments("files") + .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; + body.addFormDataPart( + "fileColumnName", + fileColumnName.get().getName(), + RequestBody.create(fileColumnName.get(), fileColumnNameMimeTypeMediaType)); + } + } 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(), V1UpdateRecordResponse.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); + } + } + + /** + * Deletes a file from the specified record. + */ + public ApiClientHttpResponse fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName) { + return fileServiceDeleteFile(vaultId, tableName, id, columnName, null); + } + + /** + * Deletes a file from the specified record. + */ + public ApiClientHttpResponse fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(tableName) + .addPathSegment(id) + .addPathSegments("files") + .addPathSegment(columnName) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(), V1DeleteFileResponse.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); + } + } + + /** + * Returns the anti-virus scan status of a file. + */ + public ApiClientHttpResponse fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName) { + return fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, null); + } + + /** + * Returns the anti-virus scan status of a file. + */ + public ApiClientHttpResponse fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegment(tableName) + .addPathSegment(id) + .addPathSegments("files") + .addPathSegment(columnName) + .addPathSegments("scan-status") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(), V1GetFileScanStatusResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java new file mode 100644 index 00000000..fee9d49b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java @@ -0,0 +1,312 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +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; +import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; +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.types.V1BatchOperationResponse; +import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; +import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; +import com.skyflow.generated.rest.types.V1DeleteFileResponse; +import com.skyflow.generated.rest.types.V1DeleteRecordResponse; +import com.skyflow.generated.rest.types.V1FieldRecords; +import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; +import com.skyflow.generated.rest.types.V1InsertRecordResponse; +import com.skyflow.generated.rest.types.V1UpdateRecordResponse; +import java.io.File; +import java.util.Optional; + +public class RecordsClient { + protected final ClientOptions clientOptions; + + private final RawRecordsClient rawClient; + + public RecordsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawRecordsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRecordsClient withRawResponse() { + return this.rawClient; + } + + /** + * Performs multiple record operations in a single transaction. + */ + public V1BatchOperationResponse recordServiceBatchOperation(String vaultId) { + return this.rawClient.recordServiceBatchOperation(vaultId).body(); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public V1BatchOperationResponse recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request) { + return this.rawClient.recordServiceBatchOperation(vaultId, request).body(); + } + + /** + * Performs multiple record operations in a single transaction. + */ + public V1BatchOperationResponse recordServiceBatchOperation( + String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceBatchOperation(vaultId, request, requestOptions) + .body(); + } + + /** + * Gets the specified records from a table. + */ + public V1BulkGetRecordResponse recordServiceBulkGetRecord(String vaultId, String objectName) { + return this.rawClient.recordServiceBulkGetRecord(vaultId, objectName).body(); + } + + /** + * Gets the specified records from a table. + */ + public V1BulkGetRecordResponse recordServiceBulkGetRecord( + String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { + return this.rawClient + .recordServiceBulkGetRecord(vaultId, objectName, request) + .body(); + } + + /** + * Gets the specified records from a table. + */ + public V1BulkGetRecordResponse recordServiceBulkGetRecord( + String vaultId, + String objectName, + RecordServiceBulkGetRecordRequest request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceBulkGetRecord(vaultId, objectName, request, requestOptions) + .body(); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public V1InsertRecordResponse recordServiceInsertRecord(String vaultId, String objectName) { + return this.rawClient.recordServiceInsertRecord(vaultId, objectName).body(); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public V1InsertRecordResponse recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request) { + return this.rawClient + .recordServiceInsertRecord(vaultId, objectName, request) + .body(); + } + + /** + * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. + */ + public V1InsertRecordResponse recordServiceInsertRecord( + String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceInsertRecord(vaultId, objectName, request, requestOptions) + .body(); + } + + /** + * Deletes the specified records from a table. + */ + public V1BulkDeleteRecordResponse recordServiceBulkDeleteRecord(String vaultId, String objectName) { + return this.rawClient.recordServiceBulkDeleteRecord(vaultId, objectName).body(); + } + + /** + * Deletes the specified records from a table. + */ + public V1BulkDeleteRecordResponse recordServiceBulkDeleteRecord( + String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { + return this.rawClient + .recordServiceBulkDeleteRecord(vaultId, objectName, request) + .body(); + } + + /** + * Deletes the specified records from a table. + */ + public V1BulkDeleteRecordResponse recordServiceBulkDeleteRecord( + String vaultId, + String objectName, + RecordServiceBulkDeleteRecordBody request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceBulkDeleteRecord(vaultId, objectName, request, requestOptions) + .body(); + } + + /** + * Returns the specified record from a table. + */ + public V1FieldRecords recordServiceGetRecord(String vaultId, String objectName, String id) { + return this.rawClient.recordServiceGetRecord(vaultId, objectName, id).body(); + } + + /** + * Returns the specified record from a table. + */ + public V1FieldRecords recordServiceGetRecord( + String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { + return this.rawClient + .recordServiceGetRecord(vaultId, objectName, id, request) + .body(); + } + + /** + * Returns the specified record from a table. + */ + public V1FieldRecords recordServiceGetRecord( + String vaultId, + String objectName, + String id, + RecordServiceGetRecordRequest request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceGetRecord(vaultId, objectName, id, request, requestOptions) + .body(); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public V1UpdateRecordResponse recordServiceUpdateRecord(String vaultId, String objectName, String id) { + return this.rawClient.recordServiceUpdateRecord(vaultId, objectName, id).body(); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public V1UpdateRecordResponse recordServiceUpdateRecord( + String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { + return this.rawClient + .recordServiceUpdateRecord(vaultId, objectName, id, request) + .body(); + } + + /** + * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. + */ + public V1UpdateRecordResponse recordServiceUpdateRecord( + String vaultId, + String objectName, + String id, + RecordServiceUpdateRecordBody request, + RequestOptions requestOptions) { + return this.rawClient + .recordServiceUpdateRecord(vaultId, objectName, id, request, requestOptions) + .body(); + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public V1DeleteRecordResponse recordServiceDeleteRecord(String vaultId, String objectName, String id) { + return this.rawClient.recordServiceDeleteRecord(vaultId, objectName, id).body(); + } + + /** + * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. + */ + public V1DeleteRecordResponse recordServiceDeleteRecord( + String vaultId, String objectName, String id, RequestOptions requestOptions) { + return this.rawClient + .recordServiceDeleteRecord(vaultId, objectName, id, requestOptions) + .body(); + } + + /** + * Uploads a file to the specified record. + */ + public V1UpdateRecordResponse fileServiceUploadFile( + String vaultId, String objectName, String id, Optional fileColumnName) { + return this.rawClient + .fileServiceUploadFile(vaultId, objectName, id, fileColumnName) + .body(); + } + + /** + * Uploads a file to the specified record. + */ + public V1UpdateRecordResponse fileServiceUploadFile( + String vaultId, + String objectName, + String id, + Optional fileColumnName, + FileServiceUploadFileRequest request) { + return this.rawClient + .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request) + .body(); + } + + /** + * Uploads a file to the specified record. + */ + public V1UpdateRecordResponse fileServiceUploadFile( + String vaultId, + String objectName, + String id, + Optional fileColumnName, + FileServiceUploadFileRequest request, + RequestOptions requestOptions) { + return this.rawClient + .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, requestOptions) + .body(); + } + + /** + * Deletes a file from the specified record. + */ + public V1DeleteFileResponse fileServiceDeleteFile(String vaultId, String tableName, String id, String columnName) { + return this.rawClient + .fileServiceDeleteFile(vaultId, tableName, id, columnName) + .body(); + } + + /** + * Deletes a file from the specified record. + */ + public V1DeleteFileResponse fileServiceDeleteFile( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + return this.rawClient + .fileServiceDeleteFile(vaultId, tableName, id, columnName, requestOptions) + .body(); + } + + /** + * Returns the anti-virus scan status of a file. + */ + public V1GetFileScanStatusResponse fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName) { + return this.rawClient + .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName) + .body(); + } + + /** + * Returns the anti-virus scan status of a file. + */ + public V1GetFileScanStatusResponse fileServiceGetFileScanStatus( + String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { + return this.rawClient + .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, requestOptions) + .body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java new file mode 100644 index 00000000..e073b0a1 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java @@ -0,0 +1,59 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.skyflow.generated.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FileServiceUploadFileRequest.Builder.class) +public final class FileServiceUploadFileRequest { + private final Map additionalProperties; + + private FileServiceUploadFileRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FileServiceUploadFileRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FileServiceUploadFileRequest other) { + return this; + } + + public FileServiceUploadFileRequest build() { + return new FileServiceUploadFileRequest(additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java new file mode 100644 index 00000000..48586839 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java @@ -0,0 +1,160 @@ +/** + * 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 com.skyflow.generated.rest.types.V1BatchRecord; +import com.skyflow.generated.rest.types.V1Byot; +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 = RecordServiceBatchOperationBody.Builder.class) +public final class RecordServiceBatchOperationBody { + private final Optional> records; + + private final Optional continueOnError; + + private final Optional byot; + + private final Map additionalProperties; + + private RecordServiceBatchOperationBody( + Optional> records, + Optional continueOnError, + Optional byot, + Map additionalProperties) { + this.records = records; + this.continueOnError = continueOnError; + this.byot = byot; + this.additionalProperties = additionalProperties; + } + + /** + * @return Record operations to perform. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + /** + * @return Continue performing operations on partial errors. + */ + @JsonProperty("continueOnError") + public Optional getContinueOnError() { + return continueOnError; + } + + @JsonProperty("byot") + public Optional getByot() { + return byot; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordServiceBatchOperationBody && equalTo((RecordServiceBatchOperationBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordServiceBatchOperationBody other) { + return records.equals(other.records) + && continueOnError.equals(other.continueOnError) + && byot.equals(other.byot); + } + + @Override + public int hashCode() { + return Objects.hash(this.records, this.continueOnError, this.byot); + } + + @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> records = Optional.empty(); + + private Optional continueOnError = Optional.empty(); + + private Optional byot = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordServiceBatchOperationBody other) { + records(other.getRecords()); + continueOnError(other.getContinueOnError()); + byot(other.getByot()); + return this; + } + + /** + *

Record operations to perform.

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

Continue performing operations on partial errors.

+ */ + @JsonSetter(value = "continueOnError", nulls = Nulls.SKIP) + public Builder continueOnError(Optional continueOnError) { + this.continueOnError = continueOnError; + return this; + } + + public Builder continueOnError(Boolean continueOnError) { + this.continueOnError = Optional.ofNullable(continueOnError); + return this; + } + + @JsonSetter(value = "byot", nulls = Nulls.SKIP) + public Builder byot(Optional byot) { + this.byot = byot; + return this; + } + + public Builder byot(V1Byot byot) { + this.byot = Optional.ofNullable(byot); + return this; + } + + public RecordServiceBatchOperationBody build() { + return new RecordServiceBatchOperationBody(records, continueOnError, byot, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java new file mode 100644 index 00000000..b417adbb --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java @@ -0,0 +1,103 @@ +/** + * 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.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RecordServiceBulkDeleteRecordBody.Builder.class) +public final class RecordServiceBulkDeleteRecordBody { + private final Optional> skyflowIds; + + private final Map additionalProperties; + + private RecordServiceBulkDeleteRecordBody( + Optional> skyflowIds, Map additionalProperties) { + this.skyflowIds = skyflowIds; + this.additionalProperties = additionalProperties; + } + + /** + * @return skyflow_id values of the records to delete. If * is specified, this operation deletes all records in the table. + */ + @JsonProperty("skyflow_ids") + public Optional> getSkyflowIds() { + return skyflowIds; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordServiceBulkDeleteRecordBody && equalTo((RecordServiceBulkDeleteRecordBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordServiceBulkDeleteRecordBody other) { + return skyflowIds.equals(other.skyflowIds); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowIds); + } + + @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> skyflowIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordServiceBulkDeleteRecordBody other) { + skyflowIds(other.getSkyflowIds()); + return this; + } + + /** + *

skyflow_id values of the records to delete. If * is specified, this operation deletes all records in the table.

+ */ + @JsonSetter(value = "skyflow_ids", nulls = Nulls.SKIP) + public Builder skyflowIds(Optional> skyflowIds) { + this.skyflowIds = skyflowIds; + return this; + } + + public Builder skyflowIds(List skyflowIds) { + this.skyflowIds = Optional.ofNullable(skyflowIds); + return this; + } + + public RecordServiceBulkDeleteRecordBody build() { + return new RecordServiceBulkDeleteRecordBody(skyflowIds, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java new file mode 100644 index 00000000..22c9090c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java @@ -0,0 +1,413 @@ +/** + * 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 com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestOrderBy; +import com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestRedaction; +import java.util.Collections; +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 = RecordServiceBulkGetRecordRequest.Builder.class) +public final class RecordServiceBulkGetRecordRequest { + private final Optional> skyflowIds; + + private final Optional> fields; + + private final Optional> columnValues; + + private final Optional redaction; + + private final Optional tokenization; + + private final Optional offset; + + private final Optional limit; + + private final Optional downloadUrl; + + private final Optional columnName; + + private final Optional orderBy; + + private final Map additionalProperties; + + private RecordServiceBulkGetRecordRequest( + Optional> skyflowIds, + Optional> fields, + Optional> columnValues, + Optional redaction, + Optional tokenization, + Optional offset, + Optional limit, + Optional downloadUrl, + Optional columnName, + Optional orderBy, + Map additionalProperties) { + this.skyflowIds = skyflowIds; + this.fields = fields; + this.columnValues = columnValues; + this.redaction = redaction; + this.tokenization = tokenization; + this.offset = offset; + this.limit = limit; + this.downloadUrl = downloadUrl; + this.columnName = columnName; + this.orderBy = orderBy; + this.additionalProperties = additionalProperties; + } + + /** + * @return skyflow_id values of the records to return, with one value per skyflow_ids URL parameter. For example, ?skyflow_ids=abc&skyflow_ids=123.<br /><br />If not specified, returns the first 25 records in the table. + */ + @JsonProperty("skyflow_ids") + public Optional> getSkyflowIds() { + return skyflowIds; + } + + /** + * @return Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields. + */ + @JsonProperty("fields") + public Optional> getFields() { + return fields; + } + + /** + * @return Column values of the records to return, with one value per column_values URL parameter. For example, ?column_values=abc&column_values=123.<br /><br />column_name is mandatory when providing column_values. If you use column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error. + */ + @JsonProperty("column_values") + public Optional> getColumnValues() { + return columnValues; + } + + /** + * @return Redaction level to enforce for the returned records. Subject to policies assigned to the API caller. + */ + @JsonProperty("redaction") + public Optional getRedaction() { + return redaction; + } + + /** + * @return If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified. + */ + @JsonProperty("tokenization") + public Optional getTokenization() { + return tokenization; + } + + /** + * @return Record position at which to start receiving data. + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + /** + * @return Number of record to return. Maximum 25. + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. + */ + @JsonProperty("downloadURL") + public Optional getDownloadUrl() { + return downloadUrl; + } + + /** + * @return Name of the column. It must be configured as unique in the schema. If you provide both column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error. + */ + @JsonProperty("column_name") + public Optional getColumnName() { + return columnName; + } + + /** + * @return Order to return records, based on skyflow_id values. To disable, set to NONE. + */ + @JsonProperty("order_by") + public Optional getOrderBy() { + return orderBy; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordServiceBulkGetRecordRequest && equalTo((RecordServiceBulkGetRecordRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordServiceBulkGetRecordRequest other) { + return skyflowIds.equals(other.skyflowIds) + && fields.equals(other.fields) + && columnValues.equals(other.columnValues) + && redaction.equals(other.redaction) + && tokenization.equals(other.tokenization) + && offset.equals(other.offset) + && limit.equals(other.limit) + && downloadUrl.equals(other.downloadUrl) + && columnName.equals(other.columnName) + && orderBy.equals(other.orderBy); + } + + @Override + public int hashCode() { + return Objects.hash( + this.skyflowIds, + this.fields, + this.columnValues, + this.redaction, + this.tokenization, + this.offset, + this.limit, + this.downloadUrl, + this.columnName, + this.orderBy); + } + + @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> skyflowIds = Optional.empty(); + + private Optional> fields = Optional.empty(); + + private Optional> columnValues = Optional.empty(); + + private Optional redaction = Optional.empty(); + + private Optional tokenization = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + private Optional columnName = Optional.empty(); + + private Optional orderBy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordServiceBulkGetRecordRequest other) { + skyflowIds(other.getSkyflowIds()); + fields(other.getFields()); + columnValues(other.getColumnValues()); + redaction(other.getRedaction()); + tokenization(other.getTokenization()); + offset(other.getOffset()); + limit(other.getLimit()); + downloadUrl(other.getDownloadUrl()); + columnName(other.getColumnName()); + orderBy(other.getOrderBy()); + return this; + } + + /** + *

skyflow_id values of the records to return, with one value per skyflow_ids URL parameter. For example, ?skyflow_ids=abc&skyflow_ids=123.<br /><br />If not specified, returns the first 25 records in the table.

+ */ + @JsonSetter(value = "skyflow_ids", nulls = Nulls.SKIP) + public Builder skyflowIds(Optional> skyflowIds) { + this.skyflowIds = skyflowIds; + return this; + } + + public Builder skyflowIds(List skyflowIds) { + this.skyflowIds = Optional.ofNullable(skyflowIds); + return this; + } + + public Builder skyflowIds(String skyflowIds) { + this.skyflowIds = Optional.of(Collections.singletonList(skyflowIds)); + return this; + } + + /** + *

Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields.

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

Column values of the records to return, with one value per column_values URL parameter. For example, ?column_values=abc&column_values=123.<br /><br />column_name is mandatory when providing column_values. If you use column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error.

+ */ + @JsonSetter(value = "column_values", nulls = Nulls.SKIP) + public Builder columnValues(Optional> columnValues) { + this.columnValues = columnValues; + return this; + } + + public Builder columnValues(List columnValues) { + this.columnValues = Optional.ofNullable(columnValues); + return this; + } + + public Builder columnValues(String columnValues) { + this.columnValues = Optional.of(Collections.singletonList(columnValues)); + return this; + } + + /** + *

Redaction level to enforce for the returned records. Subject to policies assigned to the API caller.

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

If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified.

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

Record position at which to start receiving data.

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

Number of record to return. Maximum 25.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

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

Name of the column. It must be configured as unique in the schema. If you provide both column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error.

+ */ + @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; + } + + /** + *

Order to return records, based on skyflow_id values. To disable, set to NONE.

+ */ + @JsonSetter(value = "order_by", nulls = Nulls.SKIP) + public Builder orderBy(Optional orderBy) { + this.orderBy = orderBy; + return this; + } + + public Builder orderBy(RecordServiceBulkGetRecordRequestOrderBy orderBy) { + this.orderBy = Optional.ofNullable(orderBy); + return this; + } + + public RecordServiceBulkGetRecordRequest build() { + return new RecordServiceBulkGetRecordRequest( + skyflowIds, + fields, + columnValues, + redaction, + tokenization, + offset, + limit, + downloadUrl, + columnName, + orderBy, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java new file mode 100644 index 00000000..eef17665 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java @@ -0,0 +1,202 @@ +/** + * 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 com.skyflow.generated.rest.resources.records.types.RecordServiceGetRecordRequestRedaction; +import java.util.Collections; +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 = RecordServiceGetRecordRequest.Builder.class) +public final class RecordServiceGetRecordRequest { + private final Optional> fields; + + private final Optional redaction; + + private final Optional tokenization; + + private final Optional downloadUrl; + + private final Map additionalProperties; + + private RecordServiceGetRecordRequest( + Optional> fields, + Optional redaction, + Optional tokenization, + Optional downloadUrl, + Map additionalProperties) { + this.fields = fields; + this.redaction = redaction; + this.tokenization = tokenization; + this.downloadUrl = downloadUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields. + */ + @JsonProperty("fields") + public Optional> getFields() { + return fields; + } + + /** + * @return Redaction level to enforce for the returned record. Subject to policies assigned to the API caller. + */ + @JsonProperty("redaction") + public Optional getRedaction() { + return redaction; + } + + /** + * @return If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified. + */ + @JsonProperty("tokenization") + public Optional getTokenization() { + return tokenization; + } + + /** + * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. + */ + @JsonProperty("downloadURL") + public Optional getDownloadUrl() { + return downloadUrl; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordServiceGetRecordRequest && equalTo((RecordServiceGetRecordRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordServiceGetRecordRequest other) { + return fields.equals(other.fields) + && redaction.equals(other.redaction) + && tokenization.equals(other.tokenization) + && downloadUrl.equals(other.downloadUrl); + } + + @Override + public int hashCode() { + return Objects.hash(this.fields, this.redaction, this.tokenization, this.downloadUrl); + } + + @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> fields = Optional.empty(); + + private Optional redaction = Optional.empty(); + + private Optional tokenization = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordServiceGetRecordRequest other) { + fields(other.getFields()); + redaction(other.getRedaction()); + tokenization(other.getTokenization()); + downloadUrl(other.getDownloadUrl()); + return this; + } + + /** + *

Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields.

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

Redaction level to enforce for the returned record. Subject to policies assigned to the API caller.

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

If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

+ */ + @JsonSetter(value = "downloadURL", nulls = Nulls.SKIP) + public Builder downloadUrl(Optional downloadUrl) { + this.downloadUrl = downloadUrl; + return this; + } + + public Builder downloadUrl(Boolean downloadUrl) { + this.downloadUrl = Optional.ofNullable(downloadUrl); + return this; + } + + public RecordServiceGetRecordRequest build() { + return new RecordServiceGetRecordRequest( + fields, redaction, tokenization, downloadUrl, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java new file mode 100644 index 00000000..e1de00f7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java @@ -0,0 +1,221 @@ +/** + * 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 com.skyflow.generated.rest.types.V1Byot; +import com.skyflow.generated.rest.types.V1FieldRecords; +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 = RecordServiceInsertRecordBody.Builder.class) +public final class RecordServiceInsertRecordBody { + private final Optional> records; + + private final Optional tokenization; + + private final Optional upsert; + + private final Optional homogeneous; + + private final Optional byot; + + private final Map additionalProperties; + + private RecordServiceInsertRecordBody( + Optional> records, + Optional tokenization, + Optional upsert, + Optional homogeneous, + Optional byot, + Map additionalProperties) { + this.records = records; + this.tokenization = tokenization; + this.upsert = upsert; + this.homogeneous = homogeneous; + this.byot = byot; + this.additionalProperties = additionalProperties; + } + + /** + * @return Record values and tokens. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + /** + * @return If true, this operation returns tokens for fields with tokenization enabled. + */ + @JsonProperty("tokenization") + public Optional getTokenization() { + return tokenization; + } + + /** + * @return Name of a unique column in the table. Uses upsert operations to check if a record exists based on the unique column's value. If a matching record exists, the record updates with the values you provide. If a matching record doesn't exist, the upsert operation inserts a new record.<br /><br />When you upsert a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed. + */ + @JsonProperty("upsert") + public Optional getUpsert() { + return upsert; + } + + /** + * @return If true, this operation mandates that all the records have the same fields. This parameter does not work with upsert. + */ + @JsonProperty("homogeneous") + public Optional getHomogeneous() { + return homogeneous; + } + + @JsonProperty("byot") + public Optional getByot() { + return byot; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordServiceInsertRecordBody && equalTo((RecordServiceInsertRecordBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordServiceInsertRecordBody other) { + return records.equals(other.records) + && tokenization.equals(other.tokenization) + && upsert.equals(other.upsert) + && homogeneous.equals(other.homogeneous) + && byot.equals(other.byot); + } + + @Override + public int hashCode() { + return Objects.hash(this.records, this.tokenization, this.upsert, this.homogeneous, this.byot); + } + + @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> records = Optional.empty(); + + private Optional tokenization = Optional.empty(); + + private Optional upsert = Optional.empty(); + + private Optional homogeneous = Optional.empty(); + + private Optional byot = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordServiceInsertRecordBody other) { + records(other.getRecords()); + tokenization(other.getTokenization()); + upsert(other.getUpsert()); + homogeneous(other.getHomogeneous()); + byot(other.getByot()); + return this; + } + + /** + *

Record values and tokens.

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

If true, this operation returns tokens for fields with tokenization enabled.

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

Name of a unique column in the table. Uses upsert operations to check if a record exists based on the unique column's value. If a matching record exists, the record updates with the values you provide. If a matching record doesn't exist, the upsert operation inserts a new record.<br /><br />When you upsert a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.

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

If true, this operation mandates that all the records have the same fields. This parameter does not work with upsert.

+ */ + @JsonSetter(value = "homogeneous", nulls = Nulls.SKIP) + public Builder homogeneous(Optional homogeneous) { + this.homogeneous = homogeneous; + return this; + } + + public Builder homogeneous(Boolean homogeneous) { + this.homogeneous = Optional.ofNullable(homogeneous); + return this; + } + + @JsonSetter(value = "byot", nulls = Nulls.SKIP) + public Builder byot(Optional byot) { + this.byot = byot; + return this; + } + + public Builder byot(V1Byot byot) { + this.byot = Optional.ofNullable(byot); + return this; + } + + public RecordServiceInsertRecordBody build() { + return new RecordServiceInsertRecordBody( + records, tokenization, upsert, homogeneous, byot, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java new file mode 100644 index 00000000..e52af2e4 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java @@ -0,0 +1,151 @@ +/** + * 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 com.skyflow.generated.rest.types.V1Byot; +import com.skyflow.generated.rest.types.V1FieldRecords; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RecordServiceUpdateRecordBody.Builder.class) +public final class RecordServiceUpdateRecordBody { + private final Optional record; + + private final Optional tokenization; + + private final Optional byot; + + private final Map additionalProperties; + + private RecordServiceUpdateRecordBody( + Optional record, + Optional tokenization, + Optional byot, + Map additionalProperties) { + this.record = record; + this.tokenization = tokenization; + this.byot = byot; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("record") + public Optional getRecord() { + return record; + } + + /** + * @return If true, this operation returns tokens for fields with tokenization enabled. + */ + @JsonProperty("tokenization") + public Optional getTokenization() { + return tokenization; + } + + @JsonProperty("byot") + public Optional getByot() { + return byot; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordServiceUpdateRecordBody && equalTo((RecordServiceUpdateRecordBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordServiceUpdateRecordBody other) { + return record.equals(other.record) && tokenization.equals(other.tokenization) && byot.equals(other.byot); + } + + @Override + public int hashCode() { + return Objects.hash(this.record, this.tokenization, this.byot); + } + + @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 record = Optional.empty(); + + private Optional tokenization = Optional.empty(); + + private Optional byot = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordServiceUpdateRecordBody other) { + record(other.getRecord()); + tokenization(other.getTokenization()); + byot(other.getByot()); + return this; + } + + @JsonSetter(value = "record", nulls = Nulls.SKIP) + public Builder record(Optional record) { + this.record = record; + return this; + } + + public Builder record(V1FieldRecords record) { + this.record = Optional.ofNullable(record); + return this; + } + + /** + *

If true, this operation returns tokens for fields with tokenization enabled.

+ */ + @JsonSetter(value = "tokenization", nulls = Nulls.SKIP) + public Builder tokenization(Optional tokenization) { + this.tokenization = tokenization; + return this; + } + + public Builder tokenization(Boolean tokenization) { + this.tokenization = Optional.ofNullable(tokenization); + return this; + } + + @JsonSetter(value = "byot", nulls = Nulls.SKIP) + public Builder byot(Optional byot) { + this.byot = byot; + return this; + } + + public Builder byot(V1Byot byot) { + this.byot = Optional.ofNullable(byot); + return this; + } + + public RecordServiceUpdateRecordBody build() { + return new RecordServiceUpdateRecordBody(record, tokenization, byot, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java new file mode 100644 index 00000000..1f25b38d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum RecordServiceBulkGetRecordRequestOrderBy { + ASCENDING("ASCENDING"), + + DESCENDING("DESCENDING"), + + NONE("NONE"); + + private final String value; + + RecordServiceBulkGetRecordRequestOrderBy(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java new file mode 100644 index 00000000..12bbc291 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum RecordServiceBulkGetRecordRequestRedaction { + DEFAULT("DEFAULT"), + + REDACTED("REDACTED"), + + MASKED("MASKED"), + + PLAIN_TEXT("PLAIN_TEXT"); + + private final String value; + + RecordServiceBulkGetRecordRequestRedaction(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java b/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java new file mode 100644 index 00000000..4f546262 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.records.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum RecordServiceGetRecordRequestRedaction { + DEFAULT("DEFAULT"), + + REDACTED("REDACTED"), + + MASKED("MASKED"), + + PLAIN_TEXT("PLAIN_TEXT"); + + private final String value; + + RecordServiceGetRecordRequestRedaction(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java new file mode 100644 index 00000000..0dc804b2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings; + +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.strings.requests.DeidentifyStringRequest; +import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; +import com.skyflow.generated.rest.types.DeidentifyStringResponse; +import com.skyflow.generated.rest.types.ErrorResponse; +import com.skyflow.generated.rest.types.ReidentifyStringResponse; +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 AsyncRawStringsClient { + protected final ClientOptions clientOptions; + + public AsyncRawStringsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * De-identifies sensitive data from a string. + */ + public CompletableFuture> deidentifyString( + DeidentifyStringRequest request) { + return deidentifyString(request, null); + } + + /** + * De-identifies sensitive data from a string. + */ + public CompletableFuture> deidentifyString( + DeidentifyStringRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/string") + .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(), DeidentifyStringResponse.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; + } + + /** + * Re-identifies tokens in a string. + */ + public CompletableFuture> reidentifyString( + ReidentifyStringRequest request) { + return reidentifyString(request, null); + } + + /** + * Re-identifies tokens in a string. + */ + public CompletableFuture> reidentifyString( + ReidentifyStringRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/reidentify/string") + .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(), ReidentifyStringResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java new file mode 100644 index 00000000..86e5cd0d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; +import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; +import com.skyflow.generated.rest.types.DeidentifyStringResponse; +import com.skyflow.generated.rest.types.ReidentifyStringResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncStringsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawStringsClient rawClient; + + public AsyncStringsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawStringsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawStringsClient withRawResponse() { + return this.rawClient; + } + + /** + * De-identifies sensitive data from a string. + */ + public CompletableFuture deidentifyString(DeidentifyStringRequest request) { + return this.rawClient.deidentifyString(request).thenApply(response -> response.body()); + } + + /** + * De-identifies sensitive data from a string. + */ + public CompletableFuture deidentifyString( + DeidentifyStringRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyString(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Re-identifies tokens in a string. + */ + public CompletableFuture reidentifyString(ReidentifyStringRequest request) { + return this.rawClient.reidentifyString(request).thenApply(response -> response.body()); + } + + /** + * Re-identifies tokens in a string. + */ + public CompletableFuture reidentifyString( + ReidentifyStringRequest request, RequestOptions requestOptions) { + return this.rawClient.reidentifyString(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java new file mode 100644 index 00000000..0e1fbad0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings; + +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.strings.requests.DeidentifyStringRequest; +import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; +import com.skyflow.generated.rest.types.DeidentifyStringResponse; +import com.skyflow.generated.rest.types.ErrorResponse; +import com.skyflow.generated.rest.types.ReidentifyStringResponse; +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 RawStringsClient { + protected final ClientOptions clientOptions; + + public RawStringsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * De-identifies sensitive data from a string. + */ + public ApiClientHttpResponse deidentifyString(DeidentifyStringRequest request) { + return deidentifyString(request, null); + } + + /** + * De-identifies sensitive data from a string. + */ + public ApiClientHttpResponse deidentifyString( + DeidentifyStringRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/deidentify/string") + .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(), DeidentifyStringResponse.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); + } + } + + /** + * Re-identifies tokens in a string. + */ + public ApiClientHttpResponse reidentifyString(ReidentifyStringRequest request) { + return reidentifyString(request, null); + } + + /** + * Re-identifies tokens in a string. + */ + public ApiClientHttpResponse reidentifyString( + ReidentifyStringRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/detect/reidentify/string") + .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(), ReidentifyStringResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java new file mode 100644 index 00000000..153efe07 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; +import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; +import com.skyflow.generated.rest.types.DeidentifyStringResponse; +import com.skyflow.generated.rest.types.ReidentifyStringResponse; + +public class StringsClient { + protected final ClientOptions clientOptions; + + private final RawStringsClient rawClient; + + public StringsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawStringsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawStringsClient withRawResponse() { + return this.rawClient; + } + + /** + * De-identifies sensitive data from a string. + */ + public DeidentifyStringResponse deidentifyString(DeidentifyStringRequest request) { + return this.rawClient.deidentifyString(request).body(); + } + + /** + * De-identifies sensitive data from a string. + */ + public DeidentifyStringResponse deidentifyString(DeidentifyStringRequest request, RequestOptions requestOptions) { + return this.rawClient.deidentifyString(request, requestOptions).body(); + } + + /** + * Re-identifies tokens in a string. + */ + public ReidentifyStringResponse reidentifyString(ReidentifyStringRequest request) { + return this.rawClient.reidentifyString(request).body(); + } + + /** + * Re-identifies tokens in a string. + */ + public ReidentifyStringResponse reidentifyString(ReidentifyStringRequest request, RequestOptions requestOptions) { + return this.rawClient.reidentifyString(request, requestOptions).body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java new file mode 100644 index 00000000..d20d14a9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java @@ -0,0 +1,309 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings.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.EntityType; +import com.skyflow.generated.rest.types.TokenType; +import com.skyflow.generated.rest.types.Transformations; +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 = DeidentifyStringRequest.Builder.class) +public final class DeidentifyStringRequest { + private final String vaultId; + + private final String text; + + private final Optional> entityTypes; + + private final Optional tokenType; + + private final Optional> allowRegex; + + private final Optional> restrictRegex; + + private final Optional transformations; + + private final Map additionalProperties; + + private DeidentifyStringRequest( + String vaultId, + String text, + Optional> entityTypes, + Optional tokenType, + Optional> allowRegex, + Optional> restrictRegex, + Optional transformations, + Map additionalProperties) { + this.vaultId = vaultId; + this.text = text; + this.entityTypes = entityTypes; + this.tokenType = tokenType; + this.allowRegex = allowRegex; + this.restrictRegex = restrictRegex; + this.transformations = transformations; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return String to de-identify. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @JsonProperty("token_type") + public Optional getTokenType() { + return tokenType; + } + + @JsonProperty("allow_regex") + public Optional> getAllowRegex() { + return allowRegex; + } + + @JsonProperty("restrict_regex") + public Optional> getRestrictRegex() { + return restrictRegex; + } + + @JsonProperty("transformations") + public Optional getTransformations() { + return transformations; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyStringRequest && equalTo((DeidentifyStringRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyStringRequest other) { + return vaultId.equals(other.vaultId) + && text.equals(other.text) + && entityTypes.equals(other.entityTypes) + && tokenType.equals(other.tokenType) + && allowRegex.equals(other.allowRegex) + && restrictRegex.equals(other.restrictRegex) + && transformations.equals(other.transformations); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.text, + this.entityTypes, + this.tokenType, + this.allowRegex, + this.restrictRegex, + this.transformations); + } + + @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(DeidentifyStringRequest other); + } + + public interface TextStage { + /** + * String to de-identify. + */ + _FinalStage text(@NotNull String text); + } + + public interface _FinalStage { + DeidentifyStringRequest build(); + + _FinalStage entityTypes(Optional> entityTypes); + + _FinalStage entityTypes(List entityTypes); + + _FinalStage tokenType(Optional tokenType); + + _FinalStage tokenType(TokenType tokenType); + + _FinalStage allowRegex(Optional> allowRegex); + + _FinalStage allowRegex(List allowRegex); + + _FinalStage restrictRegex(Optional> restrictRegex); + + _FinalStage restrictRegex(List restrictRegex); + + _FinalStage transformations(Optional transformations); + + _FinalStage transformations(Transformations transformations); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements VaultIdStage, TextStage, _FinalStage { + private String vaultId; + + private String text; + + private Optional transformations = Optional.empty(); + + private Optional> restrictRegex = Optional.empty(); + + private Optional> allowRegex = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyStringRequest other) { + vaultId(other.getVaultId()); + text(other.getText()); + entityTypes(other.getEntityTypes()); + tokenType(other.getTokenType()); + allowRegex(other.getAllowRegex()); + restrictRegex(other.getRestrictRegex()); + transformations(other.getTransformations()); + return this; + } + + @Override + @JsonSetter("vault_id") + public TextStage vaultId(@NotNull String vaultId) { + this.vaultId = Objects.requireNonNull(vaultId, "vaultId must not be null"); + return this; + } + + /** + * String to de-identify.

String to de-identify.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("text") + public _FinalStage text(@NotNull String text) { + this.text = Objects.requireNonNull(text, "text must not be null"); + return this; + } + + @Override + public _FinalStage transformations(Transformations transformations) { + this.transformations = Optional.ofNullable(transformations); + return this; + } + + @Override + @JsonSetter(value = "transformations", nulls = Nulls.SKIP) + public _FinalStage transformations(Optional transformations) { + this.transformations = transformations; + return this; + } + + @Override + public _FinalStage restrictRegex(List restrictRegex) { + this.restrictRegex = Optional.ofNullable(restrictRegex); + return this; + } + + @Override + @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) + public _FinalStage restrictRegex(Optional> restrictRegex) { + this.restrictRegex = restrictRegex; + return this; + } + + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage tokenType(TokenType tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + @Override + @JsonSetter(value = "token_type", nulls = Nulls.SKIP) + public _FinalStage tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + @Override + public _FinalStage entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + @Override + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public _FinalStage entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + @Override + public DeidentifyStringRequest build() { + return new DeidentifyStringRequest( + vaultId, + text, + entityTypes, + tokenType, + allowRegex, + restrictRegex, + transformations, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java new file mode 100644 index 00000000..e18b2169 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java @@ -0,0 +1,192 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings.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.strings.types.ReidentifyStringRequestFormat; +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 = ReidentifyStringRequest.Builder.class) +public final class ReidentifyStringRequest { + private final String text; + + private final String vaultId; + + private final Optional format; + + private final Map additionalProperties; + + private ReidentifyStringRequest( + String text, + String vaultId, + Optional format, + Map additionalProperties) { + this.text = text; + this.vaultId = vaultId; + this.format = format; + this.additionalProperties = additionalProperties; + } + + /** + * @return String to re-identify. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + /** + * @return ID of the vault where the entities are stored. + */ + @JsonProperty("vault_id") + public String getVaultId() { + return vaultId; + } + + /** + * @return Mapping of perferred 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; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyStringRequest && equalTo((ReidentifyStringRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyStringRequest other) { + return text.equals(other.text) && vaultId.equals(other.vaultId) && format.equals(other.format); + } + + @Override + public int hashCode() { + return Objects.hash(this.text, this.vaultId, this.format); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TextStage builder() { + return new Builder(); + } + + public interface TextStage { + /** + * String to re-identify. + */ + VaultIdStage text(@NotNull String text); + + Builder from(ReidentifyStringRequest other); + } + + public interface VaultIdStage { + /** + * ID of the vault where the entities are stored. + */ + _FinalStage vaultId(@NotNull String vaultId); + } + + public interface _FinalStage { + ReidentifyStringRequest build(); + + /** + *

Mapping of perferred 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(ReidentifyStringRequestFormat format); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TextStage, VaultIdStage, _FinalStage { + private String text; + + private String vaultId; + + private Optional format = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(ReidentifyStringRequest other) { + text(other.getText()); + vaultId(other.getVaultId()); + format(other.getFormat()); + return this; + } + + /** + * String to re-identify.

String to re-identify.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @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 where the entities are stored.

ID of the vault where the entities are stored.

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

Mapping of perferred 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. + */ + @Override + public _FinalStage format(ReidentifyStringRequestFormat format) { + this.format = Optional.ofNullable(format); + return this; + } + + /** + *

Mapping of perferred 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.

+ */ + @Override + @JsonSetter(value = "format", nulls = Nulls.SKIP) + public _FinalStage format(Optional format) { + this.format = format; + return this; + } + + @Override + public ReidentifyStringRequest build() { + return new ReidentifyStringRequest(text, vaultId, format, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java new file mode 100644 index 00000000..748cc2f6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.strings.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 = ReidentifyStringRequestFormat.Builder.class) +public final class ReidentifyStringRequestFormat { + private final Optional> redacted; + + private final Optional> masked; + + private final Optional> plaintext; + + private final Map additionalProperties; + + private ReidentifyStringRequestFormat( + 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; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyStringRequestFormat && equalTo((ReidentifyStringRequestFormat) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyStringRequestFormat other) { + return redacted.equals(other.redacted) && masked.equals(other.masked) && plaintext.equals(other.plaintext); + } + + @Override + public int hashCode() { + return Objects.hash(this.redacted, this.masked, this.plaintext); + } + + @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(ReidentifyStringRequestFormat 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 ReidentifyStringRequestFormat build() { + return new ReidentifyStringRequestFormat(redacted, masked, plaintext, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java new file mode 100644 index 00000000..fbf69580 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java @@ -0,0 +1,206 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.tokens; + +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.NotFoundError; +import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; +import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; +import com.skyflow.generated.rest.types.V1DetokenizeResponse; +import com.skyflow.generated.rest.types.V1TokenizeResponse; +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 AsyncRawTokensClient { + protected final ClientOptions clientOptions; + + public AsyncRawTokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns records that correspond to the specified tokens. + */ + public CompletableFuture> recordServiceDetokenize(String vaultId) { + return recordServiceDetokenize(vaultId, V1DetokenizePayload.builder().build()); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public CompletableFuture> recordServiceDetokenize( + String vaultId, V1DetokenizePayload request) { + return recordServiceDetokenize(vaultId, request, null); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public CompletableFuture> recordServiceDetokenize( + String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegments("detokenize") + .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(), V1DetokenizeResponse.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; + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public CompletableFuture> recordServiceTokenize(String vaultId) { + return recordServiceTokenize(vaultId, V1TokenizePayload.builder().build()); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public CompletableFuture> recordServiceTokenize( + String vaultId, V1TokenizePayload request) { + return recordServiceTokenize(vaultId, request, null); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public CompletableFuture> recordServiceTokenize( + String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegments("tokenize") + .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(), V1TokenizeResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java new file mode 100644 index 00000000..26d5ea05 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.tokens; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; +import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; +import com.skyflow.generated.rest.types.V1DetokenizeResponse; +import com.skyflow.generated.rest.types.V1TokenizeResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTokensClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTokensClient rawClient; + + public AsyncTokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTokensClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTokensClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns records that correspond to the specified tokens. + */ + public CompletableFuture recordServiceDetokenize(String vaultId) { + return this.rawClient.recordServiceDetokenize(vaultId).thenApply(response -> response.body()); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public CompletableFuture recordServiceDetokenize( + String vaultId, V1DetokenizePayload request) { + return this.rawClient.recordServiceDetokenize(vaultId, request).thenApply(response -> response.body()); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public CompletableFuture recordServiceDetokenize( + String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceDetokenize(vaultId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public CompletableFuture recordServiceTokenize(String vaultId) { + return this.rawClient.recordServiceTokenize(vaultId).thenApply(response -> response.body()); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public CompletableFuture recordServiceTokenize(String vaultId, V1TokenizePayload request) { + return this.rawClient.recordServiceTokenize(vaultId, request).thenApply(response -> response.body()); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public CompletableFuture recordServiceTokenize( + String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceTokenize(vaultId, request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java new file mode 100644 index 00000000..5ed17d28 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.tokens; + +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.NotFoundError; +import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; +import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; +import com.skyflow.generated.rest.types.V1DetokenizeResponse; +import com.skyflow.generated.rest.types.V1TokenizeResponse; +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 RawTokensClient { + protected final ClientOptions clientOptions; + + public RawTokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns records that correspond to the specified tokens. + */ + public ApiClientHttpResponse recordServiceDetokenize(String vaultId) { + return recordServiceDetokenize(vaultId, V1DetokenizePayload.builder().build()); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public ApiClientHttpResponse recordServiceDetokenize( + String vaultId, V1DetokenizePayload request) { + return recordServiceDetokenize(vaultId, request, null); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public ApiClientHttpResponse recordServiceDetokenize( + String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegments("detokenize") + .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(), V1DetokenizeResponse.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); + } + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public ApiClientHttpResponse recordServiceTokenize(String vaultId) { + return recordServiceTokenize(vaultId, V1TokenizePayload.builder().build()); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public ApiClientHttpResponse recordServiceTokenize(String vaultId, V1TokenizePayload request) { + return recordServiceTokenize(vaultId, request, null); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public ApiClientHttpResponse recordServiceTokenize( + String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/vaults") + .addPathSegment(vaultId) + .addPathSegments("tokenize") + .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(), V1TokenizeResponse.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/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java new file mode 100644 index 00000000..8b0e7e40 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java @@ -0,0 +1,77 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.tokens; + +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; +import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; +import com.skyflow.generated.rest.types.V1DetokenizeResponse; +import com.skyflow.generated.rest.types.V1TokenizeResponse; + +public class TokensClient { + protected final ClientOptions clientOptions; + + private final RawTokensClient rawClient; + + public TokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawTokensClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTokensClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns records that correspond to the specified tokens. + */ + public V1DetokenizeResponse recordServiceDetokenize(String vaultId) { + return this.rawClient.recordServiceDetokenize(vaultId).body(); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public V1DetokenizeResponse recordServiceDetokenize(String vaultId, V1DetokenizePayload request) { + return this.rawClient.recordServiceDetokenize(vaultId, request).body(); + } + + /** + * Returns records that correspond to the specified tokens. + */ + public V1DetokenizeResponse recordServiceDetokenize( + String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceDetokenize(vaultId, request, requestOptions) + .body(); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public V1TokenizeResponse recordServiceTokenize(String vaultId) { + return this.rawClient.recordServiceTokenize(vaultId).body(); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public V1TokenizeResponse recordServiceTokenize(String vaultId, V1TokenizePayload request) { + return this.rawClient.recordServiceTokenize(vaultId, request).body(); + } + + /** + * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. + */ + public V1TokenizeResponse recordServiceTokenize( + String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { + return this.rawClient + .recordServiceTokenize(vaultId, request, requestOptions) + .body(); + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java new file mode 100644 index 00000000..59318aa8 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java @@ -0,0 +1,166 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.tokens.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.V1DetokenizeRecordRequest; +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 = V1DetokenizePayload.Builder.class) +public final class V1DetokenizePayload { + private final Optional> detokenizationParameters; + + private final Optional downloadUrl; + + private final Optional continueOnError; + + private final Map additionalProperties; + + private V1DetokenizePayload( + Optional> detokenizationParameters, + Optional downloadUrl, + Optional continueOnError, + Map additionalProperties) { + this.detokenizationParameters = detokenizationParameters; + this.downloadUrl = downloadUrl; + this.continueOnError = continueOnError; + this.additionalProperties = additionalProperties; + } + + /** + * @return Detokenization details. + */ + @JsonProperty("detokenizationParameters") + public Optional> getDetokenizationParameters() { + return detokenizationParameters; + } + + /** + * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. + */ + @JsonProperty("downloadURL") + public Optional getDownloadUrl() { + return downloadUrl; + } + + /** + * @return If true, the detokenization request continues even if an error occurs. + */ + @JsonProperty("continueOnError") + public Optional getContinueOnError() { + return continueOnError; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1DetokenizePayload && equalTo((V1DetokenizePayload) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1DetokenizePayload other) { + return detokenizationParameters.equals(other.detokenizationParameters) + && downloadUrl.equals(other.downloadUrl) + && continueOnError.equals(other.continueOnError); + } + + @Override + public int hashCode() { + return Objects.hash(this.detokenizationParameters, this.downloadUrl, this.continueOnError); + } + + @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> detokenizationParameters = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + private Optional continueOnError = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1DetokenizePayload other) { + detokenizationParameters(other.getDetokenizationParameters()); + downloadUrl(other.getDownloadUrl()); + continueOnError(other.getContinueOnError()); + return this; + } + + /** + *

Detokenization details.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

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

If true, the detokenization request continues even if an error occurs.

+ */ + @JsonSetter(value = "continueOnError", nulls = Nulls.SKIP) + public Builder continueOnError(Optional continueOnError) { + this.continueOnError = continueOnError; + return this; + } + + public Builder continueOnError(Boolean continueOnError) { + this.continueOnError = Optional.ofNullable(continueOnError); + return this; + } + + public V1DetokenizePayload build() { + return new V1DetokenizePayload( + detokenizationParameters, downloadUrl, continueOnError, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java new file mode 100644 index 00000000..9729023e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.rest.resources.tokens.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.V1TokenizeRecordRequest; +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 = V1TokenizePayload.Builder.class) +public final class V1TokenizePayload { + private final Optional> tokenizationParameters; + + private final Map additionalProperties; + + private V1TokenizePayload( + Optional> tokenizationParameters, Map additionalProperties) { + this.tokenizationParameters = tokenizationParameters; + this.additionalProperties = additionalProperties; + } + + /** + * @return Tokenization details. + */ + @JsonProperty("tokenizationParameters") + public Optional> getTokenizationParameters() { + return tokenizationParameters; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1TokenizePayload && equalTo((V1TokenizePayload) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1TokenizePayload other) { + return tokenizationParameters.equals(other.tokenizationParameters); + } + + @Override + public int hashCode() { + return Objects.hash(this.tokenizationParameters); + } + + @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> tokenizationParameters = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1TokenizePayload other) { + tokenizationParameters(other.getTokenizationParameters()); + return this; + } + + /** + *

Tokenization details.

+ */ + @JsonSetter(value = "tokenizationParameters", nulls = Nulls.SKIP) + public Builder tokenizationParameters(Optional> tokenizationParameters) { + this.tokenizationParameters = tokenizationParameters; + return this; + } + + public Builder tokenizationParameters(List tokenizationParameters) { + this.tokenizationParameters = Optional.ofNullable(tokenizationParameters); + return this; + } + + public V1TokenizePayload build() { + return new V1TokenizePayload(tokenizationParameters, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java b/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java new file mode 100644 index 00000000..139ab3e5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java @@ -0,0 +1,194 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.sessionId, this.default_, this.entityColumnMap); + } + + @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() {} + + @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. + */ + @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. + */ + @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. + */ + @Override + public _FinalStage entityColumnMap(List entityColumnMap) { + this.entityColumnMap = Optional.ofNullable(entityColumnMap); + return this; + } + + /** + *

Column mapping for different entities.

+ */ + @Override + @JsonSetter(value = "entity_column_map", nulls = Nulls.SKIP) + public _FinalStage entityColumnMap(Optional> entityColumnMap) { + this.entityColumnMap = entityColumnMap; + return this; + } + + @Override + public AdvancedOptionsColumnMapping build() { + return new AdvancedOptionsColumnMapping(sessionId, default_, entityColumnMap, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java b/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java new file mode 100644 index 00000000..f0860ead --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java @@ -0,0 +1,126 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.entityType, this.columnName); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java b/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java new file mode 100644 index 00000000..f396ed7e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java @@ -0,0 +1,135 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.tableName, this.mapping); + } + + @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() {} + + @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. + */ + @Override + @JsonSetter("table_name") + public MappingStage tableName(@NotNull String tableName) { + this.tableName = Objects.requireNonNull(tableName, "tableName must not be null"); + return this; + } + + @Override + @JsonSetter("mapping") + public _FinalStage mapping(@NotNull AdvancedOptionsColumnMapping mapping) { + this.mapping = Objects.requireNonNull(mapping, "mapping must not be null"); + return this; + } + + @Override + public AdvancedOptionsVaultSchema build() { + return new AdvancedOptionsVaultSchema(tableName, mapping, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java b/v2/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java new file mode 100644 index 00000000..fe61faa5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java @@ -0,0 +1,40 @@ +/** + * 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 + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java new file mode 100644 index 00000000..d16caf10 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java @@ -0,0 +1,80 @@ +/** + * 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 AuditEventAuditResourceType { + NONE_API("NONE_API"), + + ACCOUNT("ACCOUNT"), + + AUDIT("AUDIT"), + + BASE_DATA_TYPE("BASE_DATA_TYPE"), + + FIELD_TEMPLATE("FIELD_TEMPLATE"), + + FILE("FILE"), + + KEY("KEY"), + + POLICY("POLICY"), + + PROTO_PARSE("PROTO_PARSE"), + + RECORD("RECORD"), + + ROLE("ROLE"), + + RULE("RULE"), + + SECRET("SECRET"), + + SERVICE_ACCOUNT("SERVICE_ACCOUNT"), + + TOKEN("TOKEN"), + + USER("USER"), + + VAULT("VAULT"), + + VAULT_TEMPLATE("VAULT_TEMPLATE"), + + WORKSPACE("WORKSPACE"), + + TABLE("TABLE"), + + POLICY_TEMPLATE("POLICY_TEMPLATE"), + + MEMBER("MEMBER"), + + TAG("TAG"), + + CONNECTION("CONNECTION"), + + MIGRATION("MIGRATION"), + + SCHEDULED_JOB("SCHEDULED_JOB"), + + JOB("JOB"), + + COLUMN_NAME("COLUMN_NAME"), + + NETWORK_TOKEN("NETWORK_TOKEN"), + + SUBSCRIPTION("SUBSCRIPTION"); + + private final String value; + + AuditEventAuditResourceType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java new file mode 100644 index 00000000..210f96c0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java @@ -0,0 +1,440 @@ +/** + * 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 = AuditEventContext.Builder.class) +public final class AuditEventContext { + private final Optional changeId; + + private final Optional requestId; + + private final Optional traceId; + + private final Optional sessionId; + + private final Optional actor; + + private final Optional actorType; + + private final Optional accessType; + + private final Optional ipAddress; + + private final Optional origin; + + private final Optional authMode; + + private final Optional jwtId; + + private final Optional bearerTokenContextId; + + private final Map additionalProperties; + + private AuditEventContext( + Optional changeId, + Optional requestId, + Optional traceId, + Optional sessionId, + Optional actor, + Optional actorType, + Optional accessType, + Optional ipAddress, + Optional origin, + Optional authMode, + Optional jwtId, + Optional bearerTokenContextId, + Map additionalProperties) { + this.changeId = changeId; + this.requestId = requestId; + this.traceId = traceId; + this.sessionId = sessionId; + this.actor = actor; + this.actorType = actorType; + this.accessType = accessType; + this.ipAddress = ipAddress; + this.origin = origin; + this.authMode = authMode; + this.jwtId = jwtId; + this.bearerTokenContextId = bearerTokenContextId; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID for the audit event. + */ + @JsonProperty("changeID") + public Optional getChangeId() { + return changeId; + } + + /** + * @return ID for the request that caused the event. + */ + @JsonProperty("requestID") + public Optional getRequestId() { + return requestId; + } + + /** + * @return ID for the request set by the service that received the request. + */ + @JsonProperty("traceID") + public Optional getTraceId() { + return traceId; + } + + /** + * @return ID for the session in which the request was sent. + */ + @JsonProperty("sessionID") + public Optional getSessionId() { + return sessionId; + } + + /** + * @return Member who sent the request. Depending on actorType, this may be a user ID or a service account ID. + */ + @JsonProperty("actor") + public Optional getActor() { + return actor; + } + + @JsonProperty("actorType") + public Optional getActorType() { + return actorType; + } + + @JsonProperty("accessType") + public Optional getAccessType() { + return accessType; + } + + /** + * @return IP Address of the client that made the request. + */ + @JsonProperty("ipAddress") + public Optional getIpAddress() { + return ipAddress; + } + + /** + * @return HTTP Origin request header (including scheme, hostname, and port) of the request. + */ + @JsonProperty("origin") + public Optional getOrigin() { + return origin; + } + + @JsonProperty("authMode") + public Optional getAuthMode() { + return authMode; + } + + /** + * @return ID of the JWT token. + */ + @JsonProperty("jwtID") + public Optional getJwtId() { + return jwtId; + } + + /** + * @return Embedded User Context. + */ + @JsonProperty("bearerTokenContextID") + public Optional getBearerTokenContextId() { + return bearerTokenContextId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AuditEventContext && equalTo((AuditEventContext) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AuditEventContext other) { + return changeId.equals(other.changeId) + && requestId.equals(other.requestId) + && traceId.equals(other.traceId) + && sessionId.equals(other.sessionId) + && actor.equals(other.actor) + && actorType.equals(other.actorType) + && accessType.equals(other.accessType) + && ipAddress.equals(other.ipAddress) + && origin.equals(other.origin) + && authMode.equals(other.authMode) + && jwtId.equals(other.jwtId) + && bearerTokenContextId.equals(other.bearerTokenContextId); + } + + @Override + public int hashCode() { + return Objects.hash( + this.changeId, + this.requestId, + this.traceId, + this.sessionId, + this.actor, + this.actorType, + this.accessType, + this.ipAddress, + this.origin, + this.authMode, + this.jwtId, + this.bearerTokenContextId); + } + + @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 changeId = Optional.empty(); + + private Optional requestId = Optional.empty(); + + private Optional traceId = Optional.empty(); + + private Optional sessionId = Optional.empty(); + + private Optional actor = Optional.empty(); + + private Optional actorType = Optional.empty(); + + private Optional accessType = Optional.empty(); + + private Optional ipAddress = Optional.empty(); + + private Optional origin = Optional.empty(); + + private Optional authMode = Optional.empty(); + + private Optional jwtId = Optional.empty(); + + private Optional bearerTokenContextId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AuditEventContext other) { + changeId(other.getChangeId()); + requestId(other.getRequestId()); + traceId(other.getTraceId()); + sessionId(other.getSessionId()); + actor(other.getActor()); + actorType(other.getActorType()); + accessType(other.getAccessType()); + ipAddress(other.getIpAddress()); + origin(other.getOrigin()); + authMode(other.getAuthMode()); + jwtId(other.getJwtId()); + bearerTokenContextId(other.getBearerTokenContextId()); + return this; + } + + /** + *

ID for the audit event.

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

ID for the request that caused the event.

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

ID for the request set by the service that received the request.

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

ID for the session in which the request was sent.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

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

IP Address of the client that made the request.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

ID of the JWT token.

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

Embedded User Context.

+ */ + @JsonSetter(value = "bearerTokenContextID", nulls = Nulls.SKIP) + public Builder bearerTokenContextId(Optional bearerTokenContextId) { + this.bearerTokenContextId = bearerTokenContextId; + return this; + } + + public Builder bearerTokenContextId(String bearerTokenContextId) { + this.bearerTokenContextId = Optional.ofNullable(bearerTokenContextId); + return this; + } + + public AuditEventContext build() { + return new AuditEventContext( + changeId, + requestId, + traceId, + sessionId, + actor, + actorType, + accessType, + ipAddress, + origin, + authMode, + jwtId, + bearerTokenContextId, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventData.java b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventData.java new file mode 100644 index 00000000..e2028fba --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventData.java @@ -0,0 +1,101 @@ +/** + * 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 = AuditEventData.Builder.class) +public final class AuditEventData { + private final Optional content; + + private final Map additionalProperties; + + private AuditEventData(Optional content, Map additionalProperties) { + this.content = content; + this.additionalProperties = additionalProperties; + } + + /** + * @return The entire body of the data requested or the query fired. + */ + @JsonProperty("content") + public Optional getContent() { + return content; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AuditEventData && equalTo((AuditEventData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AuditEventData other) { + return content.equals(other.content); + } + + @Override + public int hashCode() { + return Objects.hash(this.content); + } + + @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 content = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AuditEventData other) { + content(other.getContent()); + return this; + } + + /** + *

The entire body of the data requested or the query fired.

+ */ + @JsonSetter(value = "content", nulls = Nulls.SKIP) + public Builder content(Optional content) { + this.content = content; + return this; + } + + public Builder content(String content) { + this.content = Optional.ofNullable(content); + return this; + } + + public AuditEventData build() { + return new AuditEventData(content, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java new file mode 100644 index 00000000..1352c42f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java @@ -0,0 +1,130 @@ +/** + * 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 = AuditEventHttpInfo.Builder.class) +public final class AuditEventHttpInfo { + private final Optional uri; + + private final Optional method; + + private final Map additionalProperties; + + private AuditEventHttpInfo( + Optional uri, Optional method, Map additionalProperties) { + this.uri = uri; + this.method = method; + this.additionalProperties = additionalProperties; + } + + /** + * @return The http URI that is used. + */ + @JsonProperty("URI") + public Optional getUri() { + return uri; + } + + /** + * @return http method used. + */ + @JsonProperty("method") + public Optional getMethod() { + return method; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AuditEventHttpInfo && equalTo((AuditEventHttpInfo) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AuditEventHttpInfo other) { + return uri.equals(other.uri) && method.equals(other.method); + } + + @Override + public int hashCode() { + return Objects.hash(this.uri, this.method); + } + + @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 uri = Optional.empty(); + + private Optional method = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AuditEventHttpInfo other) { + uri(other.getUri()); + method(other.getMethod()); + return this; + } + + /** + *

The http URI that is used.

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

http method used.

+ */ + @JsonSetter(value = "method", nulls = Nulls.SKIP) + public Builder method(Optional method) { + this.method = method; + return this; + } + + public Builder method(String method) { + this.method = Optional.ofNullable(method); + return this; + } + + public AuditEventHttpInfo build() { + return new AuditEventHttpInfo(uri, method, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java b/v2/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java new file mode 100644 index 00000000..a6f5e673 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java @@ -0,0 +1,30 @@ +/** + * 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 BatchRecordMethod { + NONE("NONE"), + + POST("POST"), + + PUT("PUT"), + + GET("GET"), + + DELETE("DELETE"); + + private final String value; + + BatchRecordMethod(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java b/v2/src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java new file mode 100644 index 00000000..163e862e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java @@ -0,0 +1,26 @@ +/** + * 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 ContextAccessType { + ACCESS_NONE("ACCESS_NONE"), + + API("API"), + + SQL("SQL"); + + private final String value; + + ContextAccessType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java b/v2/src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java new file mode 100644 index 00000000..204ad039 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java @@ -0,0 +1,28 @@ +/** + * 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 ContextAuthMode { + AUTH_NONE("AUTH_NONE"), + + OKTA_JWT("OKTA_JWT"), + + SERVICE_ACCOUNT_JWT("SERVICE_ACCOUNT_JWT"), + + PAT_JWT("PAT_JWT"); + + private final String value; + + ContextAuthMode(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java new file mode 100644 index 00000000..4938361f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java @@ -0,0 +1,164 @@ +/** + * 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 = DeidentifyFileOutput.Builder.class) +public final class DeidentifyFileOutput { + private final Optional processedFile; + + private final Optional processedFileType; + + private final Optional processedFileExtension; + + private final Map additionalProperties; + + private DeidentifyFileOutput( + Optional processedFile, + Optional processedFileType, + Optional processedFileExtension, + Map additionalProperties) { + this.processedFile = processedFile; + this.processedFileType = processedFileType; + this.processedFileExtension = processedFileExtension; + this.additionalProperties = additionalProperties; + } + + /** + * @return URL or base64-encoded data of the output. + */ + @JsonProperty("processed_file") + public Optional getProcessedFile() { + return processedFile; + } + + /** + * @return Type of the processed file. + */ + @JsonProperty("processed_file_type") + public Optional getProcessedFileType() { + return processedFileType; + } + + /** + * @return Extension of the processed file. + */ + @JsonProperty("processed_file_extension") + public Optional getProcessedFileExtension() { + return processedFileExtension; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyFileOutput && equalTo((DeidentifyFileOutput) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyFileOutput other) { + return processedFile.equals(other.processedFile) + && processedFileType.equals(other.processedFileType) + && processedFileExtension.equals(other.processedFileExtension); + } + + @Override + public int hashCode() { + return Objects.hash(this.processedFile, this.processedFileType, this.processedFileExtension); + } + + @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 processedFile = Optional.empty(); + + private Optional processedFileType = Optional.empty(); + + private Optional processedFileExtension = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeidentifyFileOutput other) { + processedFile(other.getProcessedFile()); + processedFileType(other.getProcessedFileType()); + processedFileExtension(other.getProcessedFileExtension()); + 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; + } + + /** + *

Type of the processed file.

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

Extension of the processed file.

+ */ + @JsonSetter(value = "processed_file_extension", nulls = Nulls.SKIP) + public Builder processedFileExtension(Optional processedFileExtension) { + this.processedFileExtension = processedFileExtension; + return this; + } + + public Builder processedFileExtension(String processedFileExtension) { + this.processedFileExtension = Optional.ofNullable(processedFileExtension); + return this; + } + + public DeidentifyFileOutput build() { + return new DeidentifyFileOutput( + processedFile, processedFileType, processedFileExtension, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java new file mode 100644 index 00000000..8b602431 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java @@ -0,0 +1,40 @@ +/** + * 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 DeidentifyFileOutputProcessedFileType { + ENTITIES("entities"), + + PLAINTEXT_TRANSCRIPTION("plaintext_transcription"), + + REDACTED_AUDIO("redacted_audio"), + + REDACTED_DIARIZED_TRANSCRIPTION("redacted_diarized_transcription"), + + REDACTED_FILE("redacted_file"), + + REDACTED_IMAGE("redacted_image"), + + REDACTED_MEDICAL_DIARIZED_TRANSCRIPTION("redacted_medical_diarized_transcription"), + + REDACTED_MEDICAL_TRANSCRIPTION("redacted_medical_transcription"), + + REDACTED_TEXT("redacted_text"), + + REDACTED_TRANSCRIPTION("redacted_transcription"); + + private final String value; + + DeidentifyFileOutputProcessedFileType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java new file mode 100644 index 00000000..6b06d486 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java @@ -0,0 +1,112 @@ +/** + * 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 = DeidentifyFileResponse.Builder.class) +public final class DeidentifyFileResponse { + private final String runId; + + private final Map additionalProperties; + + private DeidentifyFileResponse(String runId, Map additionalProperties) { + this.runId = runId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Status URL for the detect run. + */ + @JsonProperty("run_id") + public String getRunId() { + return runId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyFileResponse && equalTo((DeidentifyFileResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyFileResponse other) { + return runId.equals(other.runId); + } + + @Override + public int hashCode() { + return Objects.hash(this.runId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static RunIdStage builder() { + return new Builder(); + } + + public interface RunIdStage { + /** + * Status URL for the detect run. + */ + _FinalStage runId(@NotNull String runId); + + Builder from(DeidentifyFileResponse other); + } + + public interface _FinalStage { + DeidentifyFileResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements RunIdStage, _FinalStage { + private String runId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyFileResponse other) { + runId(other.getRunId()); + return this; + } + + /** + * Status URL for the detect run.

Status URL for the detect run.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("run_id") + public _FinalStage runId(@NotNull String runId) { + this.runId = Objects.requireNonNull(runId, "runId must not be null"); + return this; + } + + @Override + public DeidentifyFileResponse build() { + return new DeidentifyFileResponse(runId, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java new file mode 100644 index 00000000..95f93828 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java @@ -0,0 +1,521 @@ +/** + * 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.ArrayList; +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 = DeidentifyStatusResponse.Builder.class) +public final class DeidentifyStatusResponse { + private final DeidentifyStatusResponseStatus status; + + private final List output; + + private final DeidentifyStatusResponseOutputType outputType; + + private final String message; + + private final Optional wordCount; + + private final Optional characterCount; + + private final Optional size; + + private final Optional duration; + + private final Optional pages; + + private final Optional slides; + + private final Map additionalProperties; + + private DeidentifyStatusResponse( + DeidentifyStatusResponseStatus status, + List output, + DeidentifyStatusResponseOutputType outputType, + String message, + Optional wordCount, + Optional characterCount, + Optional size, + Optional duration, + Optional pages, + Optional slides, + Map additionalProperties) { + this.status = status; + this.output = output; + this.outputType = outputType; + this.message = message; + this.wordCount = wordCount; + this.characterCount = characterCount; + this.size = size; + this.duration = duration; + this.pages = pages; + this.slides = slides; + this.additionalProperties = additionalProperties; + } + + /** + * @return Status of the detect run. + */ + @JsonProperty("status") + public DeidentifyStatusResponseStatus getStatus() { + return status; + } + + /** + * @return How the input file was specified. + */ + @JsonProperty("output") + public List getOutput() { + return output; + } + + /** + * @return How the output file is specified. + */ + @JsonProperty("output_type") + public DeidentifyStatusResponseOutputType getOutputType() { + return outputType; + } + + /** + * @return Status details about the detect run. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return Number of words in the processed text. + */ + @JsonProperty("word_count") + public Optional getWordCount() { + return wordCount; + } + + /** + * @return Number of characters in the processed text. + */ + @JsonProperty("character_count") + public Optional getCharacterCount() { + return characterCount; + } + + /** + * @return Size of the processed text in kilobytes (KB). + */ + @JsonProperty("size") + public Optional getSize() { + return size; + } + + /** + * @return Duration of the processed audio in seconds. + */ + @JsonProperty("duration") + public Optional getDuration() { + return duration; + } + + /** + * @return Number of pages in the processed PDF. + */ + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return Number of slides in the processed presentation. + */ + @JsonProperty("slides") + public Optional getSlides() { + return slides; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyStatusResponse && equalTo((DeidentifyStatusResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyStatusResponse other) { + return status.equals(other.status) + && output.equals(other.output) + && outputType.equals(other.outputType) + && message.equals(other.message) + && wordCount.equals(other.wordCount) + && characterCount.equals(other.characterCount) + && size.equals(other.size) + && duration.equals(other.duration) + && pages.equals(other.pages) + && slides.equals(other.slides); + } + + @Override + public int hashCode() { + return Objects.hash( + this.status, + this.output, + this.outputType, + this.message, + this.wordCount, + this.characterCount, + this.size, + this.duration, + this.pages, + this.slides); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static StatusStage builder() { + return new Builder(); + } + + public interface StatusStage { + /** + * Status of the detect run. + */ + OutputTypeStage status(@NotNull DeidentifyStatusResponseStatus status); + + Builder from(DeidentifyStatusResponse other); + } + + public interface OutputTypeStage { + /** + * How the output file is specified. + */ + MessageStage outputType(@NotNull DeidentifyStatusResponseOutputType outputType); + } + + public interface MessageStage { + /** + * Status details about the detect run. + */ + _FinalStage message(@NotNull String message); + } + + public interface _FinalStage { + DeidentifyStatusResponse build(); + + /** + *

How the input file was specified.

+ */ + _FinalStage output(List output); + + _FinalStage addOutput(DeidentifyFileOutput output); + + _FinalStage addAllOutput(List output); + + /** + *

Number of words in the processed text.

+ */ + _FinalStage wordCount(Optional wordCount); + + _FinalStage wordCount(Integer wordCount); + + /** + *

Number of characters in the processed text.

+ */ + _FinalStage characterCount(Optional characterCount); + + _FinalStage characterCount(Integer characterCount); + + /** + *

Size of the processed text in kilobytes (KB).

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

Duration of the processed audio in seconds.

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

Number of pages in the processed PDF.

+ */ + _FinalStage pages(Optional pages); + + _FinalStage pages(Integer pages); + + /** + *

Number of slides in the processed presentation.

+ */ + _FinalStage slides(Optional slides); + + _FinalStage slides(Integer slides); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements StatusStage, OutputTypeStage, MessageStage, _FinalStage { + private DeidentifyStatusResponseStatus status; + + private DeidentifyStatusResponseOutputType outputType; + + private String message; + + private Optional slides = Optional.empty(); + + private Optional pages = Optional.empty(); + + private Optional duration = Optional.empty(); + + private Optional size = Optional.empty(); + + private Optional characterCount = Optional.empty(); + + private Optional wordCount = Optional.empty(); + + private List output = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyStatusResponse other) { + status(other.getStatus()); + output(other.getOutput()); + outputType(other.getOutputType()); + message(other.getMessage()); + wordCount(other.getWordCount()); + characterCount(other.getCharacterCount()); + size(other.getSize()); + duration(other.getDuration()); + pages(other.getPages()); + slides(other.getSlides()); + return this; + } + + /** + * Status of the detect run.

Status of the detect run.

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

How the output file is specified.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("output_type") + public MessageStage outputType(@NotNull DeidentifyStatusResponseOutputType outputType) { + this.outputType = Objects.requireNonNull(outputType, "outputType must not be null"); + return this; + } + + /** + * Status details about the detect run.

Status details about the detect run.

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

Number of slides in the processed presentation.

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

Number of slides in the processed presentation.

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

Number of pages in the processed PDF.

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

Number of pages in the processed PDF.

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

Duration of the processed audio in seconds.

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

Duration of the processed audio in seconds.

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

Size of the processed text in kilobytes (KB).

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

Size of the processed text in kilobytes (KB).

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

Number of characters in the processed text.

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

Number of characters in the processed text.

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

Number of words in the processed text.

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

Number of words in the processed text.

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

How the input file was specified.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage addAllOutput(List output) { + this.output.addAll(output); + return this; + } + + /** + *

How the input file was specified.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage addOutput(DeidentifyFileOutput output) { + this.output.add(output); + return this; + } + + /** + *

How the input file was specified.

+ */ + @Override + @JsonSetter(value = "output", nulls = Nulls.SKIP) + public _FinalStage output(List output) { + this.output.clear(); + this.output.addAll(output); + return this; + } + + @Override + public DeidentifyStatusResponse build() { + return new DeidentifyStatusResponse( + status, + output, + outputType, + message, + wordCount, + characterCount, + size, + duration, + pages, + slides, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java new file mode 100644 index 00000000..5df3f85a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java @@ -0,0 +1,26 @@ +/** + * 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 DeidentifyStatusResponseOutputType { + BASE_64("BASE64"), + + EFS_PATH("EFS_PATH"), + + UNKNOWN("UNKNOWN"); + + private final String value; + + DeidentifyStatusResponseOutputType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java new file mode 100644 index 00000000..67653c66 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java @@ -0,0 +1,26 @@ +/** + * 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 DeidentifyStatusResponseStatus { + FAILED("FAILED"), + + IN_PROGRESS("IN_PROGRESS"), + + SUCCESS("SUCCESS"); + + private final String value; + + DeidentifyStatusResponseStatus(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java new file mode 100644 index 00000000..b78bb43e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java @@ -0,0 +1,242 @@ +/** + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeidentifyStringResponse.Builder.class) +public final class DeidentifyStringResponse { + private final String processedText; + + private final List entities; + + private final int wordCount; + + private final int characterCount; + + private final Map additionalProperties; + + private DeidentifyStringResponse( + String processedText, + List entities, + int wordCount, + int characterCount, + Map additionalProperties) { + this.processedText = processedText; + this.entities = entities; + this.wordCount = wordCount; + this.characterCount = characterCount; + this.additionalProperties = additionalProperties; + } + + /** + * @return De-identified text. + */ + @JsonProperty("processed_text") + public String getProcessedText() { + return processedText; + } + + /** + * @return Detected entities. + */ + @JsonProperty("entities") + public List getEntities() { + return entities; + } + + /** + * @return Number of words from the input text. + */ + @JsonProperty("word_count") + public int getWordCount() { + return wordCount; + } + + /** + * @return Number of characters from the input text. + */ + @JsonProperty("character_count") + public int getCharacterCount() { + return characterCount; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeidentifyStringResponse && equalTo((DeidentifyStringResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeidentifyStringResponse other) { + return processedText.equals(other.processedText) + && entities.equals(other.entities) + && wordCount == other.wordCount + && characterCount == other.characterCount; + } + + @Override + public int hashCode() { + return Objects.hash(this.processedText, this.entities, this.wordCount, this.characterCount); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProcessedTextStage builder() { + return new Builder(); + } + + public interface ProcessedTextStage { + /** + * De-identified text. + */ + WordCountStage processedText(@NotNull String processedText); + + Builder from(DeidentifyStringResponse other); + } + + public interface WordCountStage { + /** + * Number of words from the input text. + */ + CharacterCountStage wordCount(int wordCount); + } + + public interface CharacterCountStage { + /** + * Number of characters from the input text. + */ + _FinalStage characterCount(int characterCount); + } + + public interface _FinalStage { + DeidentifyStringResponse build(); + + /** + *

Detected entities.

+ */ + _FinalStage entities(List entities); + + _FinalStage addEntities(DetectedEntity entities); + + _FinalStage addAllEntities(List entities); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProcessedTextStage, WordCountStage, CharacterCountStage, _FinalStage { + private String processedText; + + private int wordCount; + + private int characterCount; + + private List entities = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(DeidentifyStringResponse other) { + processedText(other.getProcessedText()); + entities(other.getEntities()); + wordCount(other.getWordCount()); + characterCount(other.getCharacterCount()); + return this; + } + + /** + * De-identified text.

De-identified text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("processed_text") + public WordCountStage processedText(@NotNull String processedText) { + this.processedText = Objects.requireNonNull(processedText, "processedText must not be null"); + return this; + } + + /** + * Number of words from the input text.

Number of words from the input text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("word_count") + public CharacterCountStage wordCount(int wordCount) { + this.wordCount = wordCount; + return this; + } + + /** + * Number of characters from the input text.

Number of characters from the input text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("character_count") + public _FinalStage characterCount(int characterCount) { + this.characterCount = characterCount; + return this; + } + + /** + *

Detected entities.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage addAllEntities(List entities) { + this.entities.addAll(entities); + return this; + } + + /** + *

Detected entities.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage addEntities(DetectedEntity entities) { + this.entities.add(entities); + return this; + } + + /** + *

Detected entities.

+ */ + @Override + @JsonSetter(value = "entities", nulls = Nulls.SKIP) + public _FinalStage entities(List entities) { + this.entities.clear(); + this.entities.addAll(entities); + return this; + } + + @Override + public DeidentifyStringResponse build() { + return new DeidentifyStringResponse( + processedText, entities, wordCount, characterCount, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java b/v2/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java new file mode 100644 index 00000000..605b21ed --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java @@ -0,0 +1,36 @@ +/** + * 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 + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java b/v2/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java new file mode 100644 index 00000000..723f3392 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java @@ -0,0 +1,146 @@ +/** + * 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 + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java b/v2/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java new file mode 100644 index 00000000..b73459fe --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java @@ -0,0 +1,24 @@ +/** + * 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 DetectFileRequestDataType { + UNKNOWN("UNKNOWN"), + + BASE_64("BASE64"); + + private final String value; + + DetectFileRequestDataType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java b/v2/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java new file mode 100644 index 00000000..637b3031 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java @@ -0,0 +1,26 @@ +/** + * 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 DetectRequestDeidentifyOption { + UNKNOWN("UNKNOWN"), + + ENTITY_UNQ_COUNTER("ENTITY_UNQ_COUNTER"), + + ENTITY_ONLY("ENTITY_ONLY"); + + private final String value; + + DetectRequestDeidentifyOption(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java b/v2/src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java new file mode 100644 index 00000000..840a62a9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java @@ -0,0 +1,217 @@ +/** + * 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 = DetectedEntity.Builder.class) +public final class DetectedEntity { + private final Optional token; + + private final Optional value; + + private final Optional location; + + private final Optional entityType; + + private final Optional> entityScores; + + private final Map additionalProperties; + + private DetectedEntity( + Optional token, + Optional value, + Optional location, + Optional entityType, + Optional> entityScores, + Map additionalProperties) { + this.token = token; + this.value = value; + this.location = location; + this.entityType = entityType; + this.entityScores = entityScores; + this.additionalProperties = additionalProperties; + } + + /** + * @return Processed text of the entity. + */ + @JsonProperty("token") + public Optional getToken() { + return token; + } + + /** + * @return Original text of the entity. + */ + @JsonProperty("value") + public Optional getValue() { + return value; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + /** + * @return Highest-rated label. + */ + @JsonProperty("entity_type") + public Optional getEntityType() { + return entityType; + } + + /** + * @return entity_scores and their scores. + */ + @JsonProperty("entity_scores") + public Optional> getEntityScores() { + return entityScores; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetectedEntity && equalTo((DetectedEntity) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetectedEntity other) { + return token.equals(other.token) + && value.equals(other.value) + && location.equals(other.location) + && entityType.equals(other.entityType) + && entityScores.equals(other.entityScores); + } + + @Override + public int hashCode() { + return Objects.hash(this.token, this.value, this.location, this.entityType, this.entityScores); + } + + @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 token = Optional.empty(); + + private Optional value = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional entityType = Optional.empty(); + + private Optional> entityScores = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DetectedEntity other) { + token(other.getToken()); + value(other.getValue()); + location(other.getLocation()); + entityType(other.getEntityType()); + entityScores(other.getEntityScores()); + return this; + } + + /** + *

Processed text of the entity.

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

Original text of the entity.

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

Highest-rated label.

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

entity_scores and their scores.

+ */ + @JsonSetter(value = "entity_scores", nulls = Nulls.SKIP) + public Builder entityScores(Optional> entityScores) { + this.entityScores = entityScores; + return this; + } + + public Builder entityScores(Map entityScores) { + this.entityScores = Optional.ofNullable(entityScores); + return this; + } + + public DetectedEntity build() { + return new DetectedEntity(token, value, location, entityType, entityScores, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java b/v2/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java new file mode 100644 index 00000000..e9f4be2a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java @@ -0,0 +1,38 @@ +/** + * 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 DetokenizeRecordResponseValueType { + NONE("NONE"), + + STRING("STRING"), + + INTEGER("INTEGER"), + + FLOAT("FLOAT"), + + BOOL("BOOL"), + + DATETIME("DATETIME"), + + JSON("JSON"), + + ARRAY("ARRAY"), + + DATE("DATE"); + + private final String value; + + DetokenizeRecordResponseValueType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/EntityLocation.java b/v2/src/main/java/com/skyflow/generated/rest/types/EntityLocation.java new file mode 100644 index 00000000..197afeda --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/EntityLocation.java @@ -0,0 +1,194 @@ +/** + * 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 = EntityLocation.Builder.class) +public final class EntityLocation { + private final Optional startIndex; + + private final Optional endIndex; + + private final Optional startIndexProcessed; + + private final Optional endIndexProcessed; + + private final Map additionalProperties; + + private EntityLocation( + 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; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EntityLocation && equalTo((EntityLocation) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EntityLocation other) { + return startIndex.equals(other.startIndex) + && endIndex.equals(other.endIndex) + && startIndexProcessed.equals(other.startIndexProcessed) + && endIndexProcessed.equals(other.endIndexProcessed); + } + + @Override + public int hashCode() { + return Objects.hash(this.startIndex, this.endIndex, this.startIndexProcessed, this.endIndexProcessed); + } + + @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(EntityLocation 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 EntityLocation build() { + return new EntityLocation( + startIndex, endIndex, startIndexProcessed, endIndexProcessed, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/EntityType.java b/v2/src/main/java/com/skyflow/generated/rest/types/EntityType.java new file mode 100644 index 00000000..206dfb3c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/EntityType.java @@ -0,0 +1,146 @@ +/** + * 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 EntityType { + ACCOUNT_NUMBER("account_number"), + + AGE("age"), + + ALL("all"), + + BANK_ACCOUNT("bank_account"), + + BLOOD_TYPE("blood_type"), + + CONDITION("condition"), + + CORPORATE_ACTION("corporate_action"), + + CREDIT_CARD("credit_card"), + + CREDIT_CARD_EXPIRATION("credit_card_expiration"), + + CVV("cvv"), + + DATE("date"), + + DATE_INTERVAL("date_interval"), + + DOB("dob"), + + DOSE("dose"), + + DRIVER_LICENSE("driver_license"), + + DRUG("drug"), + + DURATION("duration"), + + EMAIL_ADDRESS("email_address"), + + EVENT("event"), + + FILENAME("filename"), + + FINANCIAL_METRIC("financial_metric"), + + GENDER_SEXUALITY("gender_sexuality"), + + HEALTHCARE_NUMBER("healthcare_number"), + + INJURY("injury"), + + IP_ADDRESS("ip_address"), + + LANGUAGE("language"), + + LOCATION("location"), + + LOCATION_ADDRESS("location_address"), + + LOCATION_ADDRESS_STREET("location_address_street"), + + LOCATION_CITY("location_city"), + + LOCATION_COORDINATE("location_coordinate"), + + LOCATION_COUNTRY("location_country"), + + LOCATION_STATE("location_state"), + + LOCATION_ZIP("location_zip"), + + MARITAL_STATUS("marital_status"), + + MEDICAL_CODE("medical_code"), + + MEDICAL_PROCESS("medical_process"), + + MONEY("money"), + + NAME("name"), + + NAME_FAMILY("name_family"), + + NAME_GIVEN("name_given"), + + NAME_MEDICAL_PROFESSIONAL("name_medical_professional"), + + NUMERICAL_PII("numerical_pii"), + + OCCUPATION("occupation"), + + ORGANIZATION("organization"), + + ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), + + ORIGIN("origin"), + + PASSPORT_NUMBER("passport_number"), + + PASSWORD("password"), + + PHONE_NUMBER("phone_number"), + + PHYSICAL_ATTRIBUTE("physical_attribute"), + + POLITICAL_AFFILIATION("political_affiliation"), + + PRODUCT("product"), + + RELIGION("religion"), + + ROUTING_NUMBER("routing_number"), + + SSN("ssn"), + + STATISTICS("statistics"), + + TIME("time"), + + TREND("trend"), + + URL("url"), + + USERNAME("username"), + + VEHICLE_ID("vehicle_id"), + + ZODIAC_SIGN("zodiac_sign"); + + private final String value; + + EntityType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java new file mode 100644 index 00000000..565714eb --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java @@ -0,0 +1,102 @@ +/** + * 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 = ErrorResponse.Builder.class) +public final class ErrorResponse { + private final ErrorResponseError error; + + private final Map additionalProperties; + + private ErrorResponse(ErrorResponseError error, Map additionalProperties) { + this.error = error; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("error") + public ErrorResponseError getError() { + return error; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ErrorResponse && equalTo((ErrorResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ErrorResponse other) { + return error.equals(other.error); + } + + @Override + public int hashCode() { + return Objects.hash(this.error); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ErrorStage builder() { + return new Builder(); + } + + public interface ErrorStage { + _FinalStage error(@NotNull ErrorResponseError error); + + Builder from(ErrorResponse other); + } + + public interface _FinalStage { + ErrorResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ErrorStage, _FinalStage { + private ErrorResponseError error; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(ErrorResponse other) { + error(other.getError()); + return this; + } + + @Override + @JsonSetter("error") + public _FinalStage error(@NotNull ErrorResponseError error) { + this.error = Objects.requireNonNull(error, "error must not be null"); + return this; + } + + @Override + public ErrorResponse build() { + return new ErrorResponse(error, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java b/v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java new file mode 100644 index 00000000..21799203 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java @@ -0,0 +1,240 @@ +/** + * 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 = ErrorResponseError.Builder.class) +public final class ErrorResponseError { + private final int grpcCode; + + private final int httpCode; + + private final String httpStatus; + + private final String message; + + private final Optional>> details; + + private final Map additionalProperties; + + private ErrorResponseError( + int grpcCode, + int httpCode, + String httpStatus, + String message, + Optional>> details, + Map additionalProperties) { + this.grpcCode = grpcCode; + this.httpCode = httpCode; + this.httpStatus = httpStatus; + this.message = message; + this.details = details; + this.additionalProperties = additionalProperties; + } + + /** + * @return gRPC status codes. See https://grpc.io/docs/guides/status-codes. + */ + @JsonProperty("grpc_code") + public int getGrpcCode() { + return grpcCode; + } + + /** + * @return HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status. + */ + @JsonProperty("http_code") + public int getHttpCode() { + return httpCode; + } + + /** + * @return HTTP status message. + */ + @JsonProperty("http_status") + public String getHttpStatus() { + return httpStatus; + } + + @JsonProperty("message") + public String getMessage() { + return message; + } + + @JsonProperty("details") + public Optional>> getDetails() { + return details; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ErrorResponseError && equalTo((ErrorResponseError) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ErrorResponseError other) { + return grpcCode == other.grpcCode + && httpCode == other.httpCode + && httpStatus.equals(other.httpStatus) + && message.equals(other.message) + && details.equals(other.details); + } + + @Override + public int hashCode() { + return Objects.hash(this.grpcCode, this.httpCode, this.httpStatus, this.message, this.details); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static GrpcCodeStage builder() { + return new Builder(); + } + + public interface GrpcCodeStage { + /** + * gRPC status codes. See https://grpc.io/docs/guides/status-codes. + */ + HttpCodeStage grpcCode(int grpcCode); + + Builder from(ErrorResponseError other); + } + + public interface HttpCodeStage { + /** + * HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status. + */ + HttpStatusStage httpCode(int httpCode); + } + + public interface HttpStatusStage { + /** + * HTTP status message. + */ + MessageStage httpStatus(@NotNull String httpStatus); + } + + public interface MessageStage { + _FinalStage message(@NotNull String message); + } + + public interface _FinalStage { + ErrorResponseError build(); + + _FinalStage details(Optional>> details); + + _FinalStage details(List> details); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements GrpcCodeStage, HttpCodeStage, HttpStatusStage, MessageStage, _FinalStage { + private int grpcCode; + + private int httpCode; + + private String httpStatus; + + private String message; + + private Optional>> details = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @Override + public Builder from(ErrorResponseError other) { + grpcCode(other.getGrpcCode()); + httpCode(other.getHttpCode()); + httpStatus(other.getHttpStatus()); + message(other.getMessage()); + details(other.getDetails()); + return this; + } + + /** + * gRPC status codes. See https://grpc.io/docs/guides/status-codes.

gRPC status codes. See https://grpc.io/docs/guides/status-codes.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("grpc_code") + public HttpCodeStage grpcCode(int grpcCode) { + this.grpcCode = grpcCode; + return this; + } + + /** + * HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.

HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("http_code") + public HttpStatusStage httpCode(int httpCode) { + this.httpCode = httpCode; + return this; + } + + /** + * HTTP status message.

HTTP status message.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("http_status") + public MessageStage httpStatus(@NotNull String httpStatus) { + this.httpStatus = Objects.requireNonNull(httpStatus, "httpStatus must not be null"); + return this; + } + + @Override + @JsonSetter("message") + public _FinalStage message(@NotNull String message) { + this.message = Objects.requireNonNull(message, "message must not be null"); + return this; + } + + @Override + public _FinalStage details(List> details) { + this.details = Optional.ofNullable(details); + return this; + } + + @Override + @JsonSetter(value = "details", nulls = Nulls.SKIP) + public _FinalStage details(Optional>> details) { + this.details = details; + return this; + } + + @Override + public ErrorResponseError build() { + return new ErrorResponseError(grpcCode, httpCode, httpStatus, message, details, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java b/v2/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java new file mode 100644 index 00000000..807aee4e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java @@ -0,0 +1,144 @@ +/** + * 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 = GooglerpcStatus.Builder.class) +public final class GooglerpcStatus { + private final Optional code; + + private final Optional message; + + private final Optional> details; + + private final Map additionalProperties; + + private GooglerpcStatus( + Optional code, + Optional message, + Optional> details, + Map additionalProperties) { + this.code = code; + this.message = message; + this.details = details; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("code") + public Optional getCode() { + return code; + } + + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @JsonProperty("details") + public Optional> getDetails() { + return details; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GooglerpcStatus && equalTo((GooglerpcStatus) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GooglerpcStatus other) { + return code.equals(other.code) && message.equals(other.message) && details.equals(other.details); + } + + @Override + public int hashCode() { + return Objects.hash(this.code, this.message, this.details); + } + + @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 code = Optional.empty(); + + private Optional message = Optional.empty(); + + private Optional> details = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GooglerpcStatus other) { + code(other.getCode()); + message(other.getMessage()); + details(other.getDetails()); + return this; + } + + @JsonSetter(value = "code", nulls = Nulls.SKIP) + public Builder code(Optional code) { + this.code = code; + return this; + } + + public Builder code(Integer code) { + this.code = Optional.ofNullable(code); + return this; + } + + @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; + } + + @JsonSetter(value = "details", nulls = Nulls.SKIP) + public Builder details(Optional> details) { + this.details = details; + return this; + } + + public Builder details(List details) { + this.details = Optional.ofNullable(details); + return this; + } + + public GooglerpcStatus build() { + return new GooglerpcStatus(code, message, details, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java b/v2/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java new file mode 100644 index 00000000..a8f574a4 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java @@ -0,0 +1,40 @@ +/** + * 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 + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java b/v2/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java new file mode 100644 index 00000000..9f019b66 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java @@ -0,0 +1,95 @@ +/** + * 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 = ProtobufAny.Builder.class) +public final class ProtobufAny { + private final Optional type; + + private final Map additionalProperties; + + private ProtobufAny(Optional type, Map additionalProperties) { + this.type = type; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("@type") + public Optional getType() { + return type; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProtobufAny && equalTo((ProtobufAny) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProtobufAny other) { + return type.equals(other.type); + } + + @Override + public int hashCode() { + return Objects.hash(this.type); + } + + @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 type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ProtobufAny other) { + type(other.getType()); + return this; + } + + @JsonSetter(value = "@type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public ProtobufAny build() { + return new ProtobufAny(type, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java b/v2/src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java new file mode 100644 index 00000000..88022df8 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java @@ -0,0 +1,28 @@ +/** + * 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 RedactionEnumRedaction { + DEFAULT("DEFAULT"), + + REDACTED("REDACTED"), + + MASKED("MASKED"), + + PLAIN_TEXT("PLAIN_TEXT"); + + private final String value; + + RedactionEnumRedaction(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.java new file mode 100644 index 00000000..dad2f08f --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.java @@ -0,0 +1,101 @@ +/** + * 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 = ReidentifyStringResponse.Builder.class) +public final class ReidentifyStringResponse { + private final Optional text; + + private final Map additionalProperties; + + private ReidentifyStringResponse(Optional text, Map additionalProperties) { + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return Re-identified text. + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReidentifyStringResponse && equalTo((ReidentifyStringResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReidentifyStringResponse other) { + return text.equals(other.text); + } + + @Override + public int hashCode() { + return Objects.hash(this.text); + } + + @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(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ReidentifyStringResponse other) { + text(other.getText()); + return this; + } + + /** + *

Re-identified text.

+ */ + @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; + } + + public ReidentifyStringResponse build() { + return new ReidentifyStringResponse(text, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java b/v2/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java new file mode 100644 index 00000000..ad0a32a7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java @@ -0,0 +1,56 @@ +/** + * 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 RequestActionType { + NONE("NONE"), + + ASSIGN("ASSIGN"), + + CREATE("CREATE"), + + DELETE("DELETE"), + + EXECUTE("EXECUTE"), + + LIST("LIST"), + + READ("READ"), + + UNASSIGN("UNASSIGN"), + + UPDATE("UPDATE"), + + VALIDATE("VALIDATE"), + + LOGIN("LOGIN"), + + ROTATE("ROTATE"), + + SCHEDULEROTATION("SCHEDULEROTATION"), + + SCHEDULEROTATIONALERT("SCHEDULEROTATIONALERT"), + + IMPORT("IMPORT"), + + GETIMPORTPARAMETERS("GETIMPORTPARAMETERS"), + + PING("PING"), + + GETCLOUDPROVIDER("GETCLOUDPROVIDER"); + + private final String value; + + RequestActionType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/TokenType.java b/v2/src/main/java/com/skyflow/generated/rest/types/TokenType.java new file mode 100644 index 00000000..eb30f761 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/TokenType.java @@ -0,0 +1,188 @@ +/** + * 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 = TokenType.Builder.class) +public final class TokenType { + private final Optional default_; + + private final Optional> vaultToken; + + private final Optional> entityUnqCounter; + + private final Optional> entityOnly; + + private final Map additionalProperties; + + private TokenType( + Optional default_, + Optional> vaultToken, + Optional> entityUnqCounter, + Optional> entityOnly, + Map additionalProperties) { + this.default_ = default_; + this.vaultToken = vaultToken; + this.entityUnqCounter = entityUnqCounter; + this.entityOnly = entityOnly; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("default") + public Optional getDefault() { + return default_; + } + + /** + * @return Entity types to replace with vault tokens. + */ + @JsonProperty("vault_token") + public Optional> getVaultToken() { + return vaultToken; + } + + /** + * @return Entity types to replace with entity tokens with unique counters. + */ + @JsonProperty("entity_unq_counter") + public Optional> getEntityUnqCounter() { + return entityUnqCounter; + } + + /** + * @return Entity types to replace with entity tokens. + */ + @JsonProperty("entity_only") + public Optional> getEntityOnly() { + return entityOnly; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenType && equalTo((TokenType) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenType other) { + return default_.equals(other.default_) + && vaultToken.equals(other.vaultToken) + && entityUnqCounter.equals(other.entityUnqCounter) + && entityOnly.equals(other.entityOnly); + } + + @Override + public int hashCode() { + return Objects.hash(this.default_, this.vaultToken, this.entityUnqCounter, this.entityOnly); + } + + @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 default_ = Optional.empty(); + + private Optional> vaultToken = Optional.empty(); + + private Optional> entityUnqCounter = Optional.empty(); + + private Optional> entityOnly = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenType other) { + default_(other.getDefault()); + vaultToken(other.getVaultToken()); + entityUnqCounter(other.getEntityUnqCounter()); + entityOnly(other.getEntityOnly()); + return this; + } + + @JsonSetter(value = "default", nulls = Nulls.SKIP) + public Builder default_(Optional default_) { + this.default_ = default_; + return this; + } + + public Builder default_(TokenTypeDefault default_) { + this.default_ = Optional.ofNullable(default_); + return this; + } + + /** + *

Entity types to replace with vault tokens.

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

Entity types to replace with entity tokens with unique counters.

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

Entity types to replace with entity tokens.

+ */ + @JsonSetter(value = "entity_only", nulls = Nulls.SKIP) + public Builder entityOnly(Optional> entityOnly) { + this.entityOnly = entityOnly; + return this; + } + + public Builder entityOnly(List entityOnly) { + this.entityOnly = Optional.ofNullable(entityOnly); + return this; + } + + public TokenType build() { + return new TokenType(default_, vaultToken, entityUnqCounter, entityOnly, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java b/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java new file mode 100644 index 00000000..5eeed0a7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java @@ -0,0 +1,26 @@ +/** + * 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 TokenTypeDefault { + ENTITY_ONLY("entity_only"), + + ENTITY_UNQ_COUNTER("entity_unq_counter"), + + VAULT_TOKEN("vault_token"); + + private final String value; + + TokenTypeDefault(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java b/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java new file mode 100644 index 00000000..4bf8dffb --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java @@ -0,0 +1,158 @@ +/** + * 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 = TokenTypeWithoutVault.Builder.class) +public final class TokenTypeWithoutVault { + private final Optional default_; + + private final Optional> entityUnqCounter; + + private final Optional> entityOnly; + + private final Map additionalProperties; + + private TokenTypeWithoutVault( + Optional default_, + Optional> entityUnqCounter, + Optional> entityOnly, + Map additionalProperties) { + this.default_ = default_; + this.entityUnqCounter = entityUnqCounter; + this.entityOnly = entityOnly; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("default") + public Optional getDefault() { + return default_; + } + + /** + * @return Entity types to replace with entity tokens with unique counters. + */ + @JsonProperty("entity_unq_counter") + public Optional> getEntityUnqCounter() { + return entityUnqCounter; + } + + /** + * @return Entity types to replace with entity tokens. + */ + @JsonProperty("entity_only") + public Optional> getEntityOnly() { + return entityOnly; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenTypeWithoutVault && equalTo((TokenTypeWithoutVault) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenTypeWithoutVault other) { + return default_.equals(other.default_) + && entityUnqCounter.equals(other.entityUnqCounter) + && entityOnly.equals(other.entityOnly); + } + + @Override + public int hashCode() { + return Objects.hash(this.default_, this.entityUnqCounter, this.entityOnly); + } + + @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 default_ = Optional.empty(); + + private Optional> entityUnqCounter = Optional.empty(); + + private Optional> entityOnly = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenTypeWithoutVault other) { + default_(other.getDefault()); + entityUnqCounter(other.getEntityUnqCounter()); + entityOnly(other.getEntityOnly()); + return this; + } + + @JsonSetter(value = "default", nulls = Nulls.SKIP) + public Builder default_(Optional default_) { + this.default_ = default_; + return this; + } + + public Builder default_(TokenTypeWithoutVaultDefault default_) { + this.default_ = Optional.ofNullable(default_); + return this; + } + + /** + *

Entity types to replace with entity tokens with unique counters.

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

Entity types to replace with entity tokens.

+ */ + @JsonSetter(value = "entity_only", nulls = Nulls.SKIP) + public Builder entityOnly(Optional> entityOnly) { + this.entityOnly = entityOnly; + return this; + } + + public Builder entityOnly(List entityOnly) { + this.entityOnly = Optional.ofNullable(entityOnly); + return this; + } + + public TokenTypeWithoutVault build() { + return new TokenTypeWithoutVault(default_, entityUnqCounter, entityOnly, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java b/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java new file mode 100644 index 00000000..d7d0d573 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java @@ -0,0 +1,24 @@ +/** + * 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 TokenTypeWithoutVaultDefault { + ENTITY_ONLY("entity_only"), + + ENTITY_UNQ_COUNTER("entity_unq_counter"); + + private final String value; + + TokenTypeWithoutVaultDefault(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/Transformations.java b/v2/src/main/java/com/skyflow/generated/rest/types/Transformations.java new file mode 100644 index 00000000..bef63c2a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/Transformations.java @@ -0,0 +1,101 @@ +/** + * 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 = Transformations.Builder.class) +public final class Transformations { + private final Optional shiftDates; + + private final Map additionalProperties; + + private Transformations(Optional shiftDates, Map additionalProperties) { + this.shiftDates = shiftDates; + this.additionalProperties = additionalProperties; + } + + /** + * @return Shift dates by a specified number of days. + */ + @JsonProperty("shift_dates") + public Optional getShiftDates() { + return shiftDates; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Transformations && equalTo((Transformations) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Transformations other) { + return shiftDates.equals(other.shiftDates); + } + + @Override + public int hashCode() { + return Objects.hash(this.shiftDates); + } + + @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 shiftDates = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Transformations other) { + shiftDates(other.getShiftDates()); + return this; + } + + /** + *

Shift dates by a specified number of days.

+ */ + @JsonSetter(value = "shift_dates", nulls = Nulls.SKIP) + public Builder shiftDates(Optional shiftDates) { + this.shiftDates = shiftDates; + return this; + } + + public Builder shiftDates(TransformationsShiftDates shiftDates) { + this.shiftDates = Optional.ofNullable(shiftDates); + return this; + } + + public Transformations build() { + return new Transformations(shiftDates, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java b/v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java new file mode 100644 index 00000000..e9206467 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java @@ -0,0 +1,162 @@ +/** + * 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 = TransformationsShiftDates.Builder.class) +public final class TransformationsShiftDates { + private final Optional maxDays; + + private final Optional minDays; + + private final Optional> entityTypes; + + private final Map additionalProperties; + + private TransformationsShiftDates( + Optional maxDays, + Optional minDays, + Optional> entityTypes, + Map additionalProperties) { + this.maxDays = maxDays; + this.minDays = minDays; + this.entityTypes = entityTypes; + this.additionalProperties = additionalProperties; + } + + /** + * @return Maximum number of days to shift the date by. + */ + @JsonProperty("max_days") + public Optional getMaxDays() { + return maxDays; + } + + /** + * @return Minimum number of days to shift the date by. + */ + @JsonProperty("min_days") + public Optional getMinDays() { + return minDays; + } + + /** + * @return Entity types to shift dates for. + */ + @JsonProperty("entity_types") + public Optional> getEntityTypes() { + return entityTypes; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TransformationsShiftDates && equalTo((TransformationsShiftDates) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TransformationsShiftDates other) { + return maxDays.equals(other.maxDays) && minDays.equals(other.minDays) && entityTypes.equals(other.entityTypes); + } + + @Override + public int hashCode() { + return Objects.hash(this.maxDays, this.minDays, this.entityTypes); + } + + @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 maxDays = Optional.empty(); + + private Optional minDays = Optional.empty(); + + private Optional> entityTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TransformationsShiftDates other) { + maxDays(other.getMaxDays()); + minDays(other.getMinDays()); + entityTypes(other.getEntityTypes()); + return this; + } + + /** + *

Maximum number of days to shift the date by.

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

Minimum number of days to shift the date by.

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

Entity types to shift dates for.

+ */ + @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) + public Builder entityTypes(Optional> entityTypes) { + this.entityTypes = entityTypes; + return this; + } + + public Builder entityTypes(List entityTypes) { + this.entityTypes = Optional.ofNullable(entityTypes); + return this; + } + + public TransformationsShiftDates build() { + return new TransformationsShiftDates(maxDays, minDays, entityTypes, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java b/v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java new file mode 100644 index 00000000..3da8eb6d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java @@ -0,0 +1,26 @@ +/** + * 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 TransformationsShiftDatesEntityTypesItem { + DATE("date"), + + DATE_INTERVAL("date_interval"), + + DOB("dob"); + + private final String value; + + TransformationsShiftDatesEntityTypesItem(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java new file mode 100644 index 00000000..2aee86d5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java @@ -0,0 +1,157 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.dateShift, this.customClient, this.schema); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java new file mode 100644 index 00000000..3d2c9102 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java @@ -0,0 +1,151 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.outputTranscription, this.outputProcessedAudio, this.options); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java new file mode 100644 index 00000000..c4d88e7a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java @@ -0,0 +1,234 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash( + this.bleepStartPadding, + this.bleepEndPadding, + this.distortionSteps, + this.bleepFrequency, + this.bleepGain); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.java new file mode 100644 index 00000000..d942fdcd --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.java @@ -0,0 +1,130 @@ +/** + * 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 = V1AuditAfterOptions.Builder.class) +public final class V1AuditAfterOptions { + private final Optional timestamp; + + private final Optional changeId; + + private final Map additionalProperties; + + private V1AuditAfterOptions( + Optional timestamp, Optional changeId, Map additionalProperties) { + this.timestamp = timestamp; + this.changeId = changeId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. + */ + @JsonProperty("timestamp") + public Optional getTimestamp() { + return timestamp; + } + + /** + * @return Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. + */ + @JsonProperty("changeID") + public Optional getChangeId() { + return changeId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1AuditAfterOptions && equalTo((V1AuditAfterOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1AuditAfterOptions other) { + return timestamp.equals(other.timestamp) && changeId.equals(other.changeId); + } + + @Override + public int hashCode() { + return Objects.hash(this.timestamp, this.changeId); + } + + @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 timestamp = Optional.empty(); + + private Optional changeId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1AuditAfterOptions other) { + timestamp(other.getTimestamp()); + changeId(other.getChangeId()); + return this; + } + + /** + *

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

+ */ + @JsonSetter(value = "changeID", nulls = Nulls.SKIP) + public Builder changeId(Optional changeId) { + this.changeId = changeId; + return this; + } + + public Builder changeId(String changeId) { + this.changeId = Optional.ofNullable(changeId); + return this; + } + + public V1AuditAfterOptions build() { + return new V1AuditAfterOptions(timestamp, changeId, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java new file mode 100644 index 00000000..c582d06d --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java @@ -0,0 +1,187 @@ +/** + * 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 = V1AuditEventResponse.Builder.class) +public final class V1AuditEventResponse { + private final Optional code; + + private final Optional message; + + private final Optional data; + + private final Optional timestamp; + + private final Map additionalProperties; + + private V1AuditEventResponse( + Optional code, + Optional message, + Optional data, + Optional timestamp, + Map additionalProperties) { + this.code = code; + this.message = message; + this.data = data; + this.timestamp = timestamp; + this.additionalProperties = additionalProperties; + } + + /** + * @return The status of the overall operation. + */ + @JsonProperty("code") + public Optional getCode() { + return code; + } + + /** + * @return The status message for the overall operation. + */ + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @JsonProperty("data") + public Optional getData() { + return data; + } + + /** + * @return time when this response is generated, use extention method to set it. + */ + @JsonProperty("timestamp") + public Optional getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1AuditEventResponse && equalTo((V1AuditEventResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1AuditEventResponse other) { + return code.equals(other.code) + && message.equals(other.message) + && data.equals(other.data) + && timestamp.equals(other.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash(this.code, this.message, this.data, this.timestamp); + } + + @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 code = Optional.empty(); + + private Optional message = Optional.empty(); + + private Optional data = Optional.empty(); + + private Optional timestamp = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1AuditEventResponse other) { + code(other.getCode()); + message(other.getMessage()); + data(other.getData()); + timestamp(other.getTimestamp()); + return this; + } + + /** + *

The status of the overall operation.

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

The status message for the overall operation.

+ */ + @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; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(AuditEventData data) { + this.data = Optional.ofNullable(data); + return this; + } + + /** + *

time when this response is generated, use extention method to set it.

+ */ + @JsonSetter(value = "timestamp", nulls = Nulls.SKIP) + public Builder timestamp(Optional timestamp) { + this.timestamp = timestamp; + return this; + } + + public Builder timestamp(String timestamp) { + this.timestamp = Optional.ofNullable(timestamp); + return this; + } + + public V1AuditEventResponse build() { + return new V1AuditEventResponse(code, message, data, timestamp, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java new file mode 100644 index 00000000..dd23d77c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java @@ -0,0 +1,127 @@ +/** + * 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 = V1AuditResponse.Builder.class) +public final class V1AuditResponse { + private final Optional> event; + + private final Optional nextOps; + + private final Map additionalProperties; + + private V1AuditResponse( + Optional> event, + Optional nextOps, + Map additionalProperties) { + this.event = event; + this.nextOps = nextOps; + this.additionalProperties = additionalProperties; + } + + /** + * @return Events matching the query. + */ + @JsonProperty("event") + public Optional> getEvent() { + return event; + } + + @JsonProperty("nextOps") + public Optional getNextOps() { + return nextOps; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1AuditResponse && equalTo((V1AuditResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1AuditResponse other) { + return event.equals(other.event) && nextOps.equals(other.nextOps); + } + + @Override + public int hashCode() { + return Objects.hash(this.event, this.nextOps); + } + + @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> event = Optional.empty(); + + private Optional nextOps = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1AuditResponse other) { + event(other.getEvent()); + nextOps(other.getNextOps()); + return this; + } + + /** + *

Events matching the query.

+ */ + @JsonSetter(value = "event", nulls = Nulls.SKIP) + public Builder event(Optional> event) { + this.event = event; + return this; + } + + public Builder event(List event) { + this.event = Optional.ofNullable(event); + return this; + } + + @JsonSetter(value = "nextOps", nulls = Nulls.SKIP) + public Builder nextOps(Optional nextOps) { + this.nextOps = nextOps; + return this; + } + + public Builder nextOps(V1AuditAfterOptions nextOps) { + this.nextOps = Optional.ofNullable(nextOps); + return this; + } + + public V1AuditResponse build() { + return new V1AuditResponse(event, nextOps, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java new file mode 100644 index 00000000..ca2bfdc2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java @@ -0,0 +1,238 @@ +/** + * 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 = V1AuditResponseEvent.Builder.class) +public final class V1AuditResponseEvent { + private final Optional context; + + private final Optional request; + + private final Optional response; + + private final Optional parentAccountId; + + private final Optional accountId; + + private final Optional> resourceIDs; + + private final Map additionalProperties; + + private V1AuditResponseEvent( + Optional context, + Optional request, + Optional response, + Optional parentAccountId, + Optional accountId, + Optional> resourceIDs, + Map additionalProperties) { + this.context = context; + this.request = request; + this.response = response; + this.parentAccountId = parentAccountId; + this.accountId = accountId; + this.resourceIDs = resourceIDs; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("context") + public Optional getContext() { + return context; + } + + @JsonProperty("request") + public Optional getRequest() { + return request; + } + + @JsonProperty("response") + public Optional getResponse() { + return response; + } + + /** + * @return Parent account ID of the account that made the request, if any. + */ + @JsonProperty("parentAccountID") + public Optional getParentAccountId() { + return parentAccountId; + } + + /** + * @return ID of the account that made the request. + */ + @JsonProperty("accountID") + public Optional getAccountId() { + return accountId; + } + + /** + * @return IDs for resources involved in the event. Presented in {resourceType}/{resourceID} format. For example, VAULT/cd1d815aa09b4cbfbb803bd20349f202. + */ + @JsonProperty("resourceIDs") + public Optional> getResourceIDs() { + return resourceIDs; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1AuditResponseEvent && equalTo((V1AuditResponseEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1AuditResponseEvent other) { + return context.equals(other.context) + && request.equals(other.request) + && response.equals(other.response) + && parentAccountId.equals(other.parentAccountId) + && accountId.equals(other.accountId) + && resourceIDs.equals(other.resourceIDs); + } + + @Override + public int hashCode() { + return Objects.hash( + this.context, this.request, this.response, this.parentAccountId, this.accountId, this.resourceIDs); + } + + @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 context = Optional.empty(); + + private Optional request = Optional.empty(); + + private Optional response = Optional.empty(); + + private Optional parentAccountId = Optional.empty(); + + private Optional accountId = Optional.empty(); + + private Optional> resourceIDs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1AuditResponseEvent other) { + context(other.getContext()); + request(other.getRequest()); + response(other.getResponse()); + parentAccountId(other.getParentAccountId()); + accountId(other.getAccountId()); + resourceIDs(other.getResourceIDs()); + return this; + } + + @JsonSetter(value = "context", nulls = Nulls.SKIP) + public Builder context(Optional context) { + this.context = context; + return this; + } + + public Builder context(AuditEventContext context) { + this.context = Optional.ofNullable(context); + return this; + } + + @JsonSetter(value = "request", nulls = Nulls.SKIP) + public Builder request(Optional request) { + this.request = request; + return this; + } + + public Builder request(V1AuditResponseEventRequest request) { + this.request = Optional.ofNullable(request); + return this; + } + + @JsonSetter(value = "response", nulls = Nulls.SKIP) + public Builder response(Optional response) { + this.response = response; + return this; + } + + public Builder response(V1AuditEventResponse response) { + this.response = Optional.ofNullable(response); + return this; + } + + /** + *

Parent account ID of the account that made the request, if any.

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

ID of the account that made the request.

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

IDs for resources involved in the event. Presented in {resourceType}/{resourceID} format. For example, VAULT/cd1d815aa09b4cbfbb803bd20349f202.

+ */ + @JsonSetter(value = "resourceIDs", nulls = Nulls.SKIP) + public Builder resourceIDs(Optional> resourceIDs) { + this.resourceIDs = resourceIDs; + return this; + } + + public Builder resourceIDs(List resourceIDs) { + this.resourceIDs = Optional.ofNullable(resourceIDs); + return this; + } + + public V1AuditResponseEvent build() { + return new V1AuditResponseEvent( + context, request, response, parentAccountId, accountId, resourceIDs, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java new file mode 100644 index 00000000..046c8fb4 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java @@ -0,0 +1,339 @@ +/** + * 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 = V1AuditResponseEventRequest.Builder.class) +public final class V1AuditResponseEventRequest { + private final Optional data; + + private final Optional apiName; + + private final Optional workspaceId; + + private final Optional vaultId; + + private final Optional> tags; + + private final Optional timestamp; + + private final Optional actionType; + + private final Optional resourceType; + + private final Optional httpInfo; + + private final Map additionalProperties; + + private V1AuditResponseEventRequest( + Optional data, + Optional apiName, + Optional workspaceId, + Optional vaultId, + Optional> tags, + Optional timestamp, + Optional actionType, + Optional resourceType, + Optional httpInfo, + Map additionalProperties) { + this.data = data; + this.apiName = apiName; + this.workspaceId = workspaceId; + this.vaultId = vaultId; + this.tags = tags; + this.timestamp = timestamp; + this.actionType = actionType; + this.resourceType = resourceType; + this.httpInfo = httpInfo; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public Optional getData() { + return data; + } + + /** + * @return API name. + */ + @JsonProperty("apiName") + public Optional getApiName() { + return apiName; + } + + /** + * @return The workspaceID (if any) of the request. + */ + @JsonProperty("workspaceID") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The vaultID (if any) of the request. + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Tags associated with the event. To provide better search capabilities. Like login. + */ + @JsonProperty("tags") + public Optional> getTags() { + return tags; + } + + /** + * @return time when this request is generated, use extention method to set it. + */ + @JsonProperty("timestamp") + public Optional getTimestamp() { + return timestamp; + } + + @JsonProperty("actionType") + public Optional getActionType() { + return actionType; + } + + @JsonProperty("resourceType") + public Optional getResourceType() { + return resourceType; + } + + @JsonProperty("httpInfo") + public Optional getHttpInfo() { + return httpInfo; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1AuditResponseEventRequest && equalTo((V1AuditResponseEventRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1AuditResponseEventRequest other) { + return data.equals(other.data) + && apiName.equals(other.apiName) + && workspaceId.equals(other.workspaceId) + && vaultId.equals(other.vaultId) + && tags.equals(other.tags) + && timestamp.equals(other.timestamp) + && actionType.equals(other.actionType) + && resourceType.equals(other.resourceType) + && httpInfo.equals(other.httpInfo); + } + + @Override + public int hashCode() { + return Objects.hash( + this.data, + this.apiName, + this.workspaceId, + this.vaultId, + this.tags, + this.timestamp, + this.actionType, + this.resourceType, + this.httpInfo); + } + + @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 data = Optional.empty(); + + private Optional apiName = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional vaultId = Optional.empty(); + + private Optional> tags = Optional.empty(); + + private Optional timestamp = Optional.empty(); + + private Optional actionType = Optional.empty(); + + private Optional resourceType = Optional.empty(); + + private Optional httpInfo = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1AuditResponseEventRequest other) { + data(other.getData()); + apiName(other.getApiName()); + workspaceId(other.getWorkspaceId()); + vaultId(other.getVaultId()); + tags(other.getTags()); + timestamp(other.getTimestamp()); + actionType(other.getActionType()); + resourceType(other.getResourceType()); + httpInfo(other.getHttpInfo()); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(AuditEventData data) { + this.data = Optional.ofNullable(data); + return this; + } + + /** + *

API name.

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

The workspaceID (if any) of the request.

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

The vaultID (if any) of the request.

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Tags associated with the event. To provide better search capabilities. Like login.

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

time when this request is generated, use extention method to set it.

+ */ + @JsonSetter(value = "timestamp", nulls = Nulls.SKIP) + public Builder timestamp(Optional timestamp) { + this.timestamp = timestamp; + return this; + } + + public Builder timestamp(String timestamp) { + this.timestamp = Optional.ofNullable(timestamp); + return this; + } + + @JsonSetter(value = "actionType", nulls = Nulls.SKIP) + public Builder actionType(Optional actionType) { + this.actionType = actionType; + return this; + } + + public Builder actionType(RequestActionType actionType) { + this.actionType = Optional.ofNullable(actionType); + return this; + } + + @JsonSetter(value = "resourceType", nulls = Nulls.SKIP) + public Builder resourceType(Optional resourceType) { + this.resourceType = resourceType; + return this; + } + + public Builder resourceType(AuditEventAuditResourceType resourceType) { + this.resourceType = Optional.ofNullable(resourceType); + return this; + } + + @JsonSetter(value = "httpInfo", nulls = Nulls.SKIP) + public Builder httpInfo(Optional httpInfo) { + this.httpInfo = httpInfo; + return this; + } + + public Builder httpInfo(AuditEventHttpInfo httpInfo) { + this.httpInfo = Optional.ofNullable(httpInfo); + return this; + } + + public V1AuditResponseEventRequest build() { + return new V1AuditResponseEventRequest( + data, + apiName, + workspaceId, + vaultId, + tags, + timestamp, + actionType, + resourceType, + httpInfo, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java new file mode 100644 index 00000000..a557da82 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java @@ -0,0 +1,133 @@ +/** + * 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 = V1BatchOperationResponse.Builder.class) +public final class V1BatchOperationResponse { + private final Optional vaultId; + + private final Optional>> responses; + + private final Map additionalProperties; + + private V1BatchOperationResponse( + Optional vaultId, + Optional>> responses, + Map additionalProperties) { + this.vaultId = vaultId; + this.responses = responses; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault. + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Responses in the same order as in the request. Responses have the same payload structure as their corresponding APIs: <br/><ul><li>POST returns an Insert Records response.</li><li>PUT returns an Update Record response.</li><li>GET returns a Get Record response.</li><li>DELETE returns a Delete Record response.</li></ul> + */ + @JsonProperty("responses") + public Optional>> getResponses() { + return responses; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1BatchOperationResponse && equalTo((V1BatchOperationResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1BatchOperationResponse other) { + return vaultId.equals(other.vaultId) && responses.equals(other.responses); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.responses); + } + + @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(); + + private Optional>> responses = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1BatchOperationResponse other) { + vaultId(other.getVaultId()); + responses(other.getResponses()); + return this; + } + + /** + *

ID of the vault.

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Responses in the same order as in the request. Responses have the same payload structure as their corresponding APIs: <br/><ul><li>POST returns an Insert Records response.</li><li>PUT returns an Update Record response.</li><li>GET returns a Get Record response.</li><li>DELETE returns a Delete Record response.</li></ul>

+ */ + @JsonSetter(value = "responses", nulls = Nulls.SKIP) + public Builder responses(Optional>> responses) { + this.responses = responses; + return this; + } + + public Builder responses(List> responses) { + this.responses = Optional.ofNullable(responses); + return this; + } + + public V1BatchOperationResponse build() { + return new V1BatchOperationResponse(vaultId, responses, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java new file mode 100644 index 00000000..afc572cf --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java @@ -0,0 +1,382 @@ +/** + * 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 = V1BatchRecord.Builder.class) +public final class V1BatchRecord { + private final Optional> fields; + + private final Optional tableName; + + private final Optional method; + + private final Optional batchId; + + private final Optional redaction; + + private final Optional tokenization; + + private final Optional id; + + private final Optional downloadUrl; + + private final Optional upsert; + + private final Optional> tokens; + + private final Map additionalProperties; + + private V1BatchRecord( + Optional> fields, + Optional tableName, + Optional method, + Optional batchId, + Optional redaction, + Optional tokenization, + Optional id, + Optional downloadUrl, + Optional upsert, + Optional> tokens, + Map additionalProperties) { + this.fields = fields; + this.tableName = tableName; + this.method = method; + this.batchId = batchId; + this.redaction = redaction; + this.tokenization = tokenization; + this.id = id; + this.downloadUrl = downloadUrl; + this.upsert = upsert; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return Field and value key pairs. For example, {'field_1':'value_1', 'field_2':'value_2'}. Only valid when method is POST or PUT. + */ + @JsonProperty("fields") + public Optional> getFields() { + return fields; + } + + /** + * @return Name of the table to perform the operation on. + */ + @JsonProperty("tableName") + public Optional getTableName() { + return tableName; + } + + @JsonProperty("method") + public Optional getMethod() { + return method; + } + + /** + * @return ID to group operations by. Operations in the same group are executed sequentially. + */ + @JsonProperty("batchID") + public Optional getBatchId() { + return batchId; + } + + @JsonProperty("redaction") + public Optional getRedaction() { + return redaction; + } + + /** + * @return If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified. + */ + @JsonProperty("tokenization") + public Optional getTokenization() { + return tokenization; + } + + /** + * @return skyflow_id for the record. Only valid when method is GET, DELETE, or PUT. + */ + @JsonProperty("ID") + public Optional getId() { + return id; + } + + /** + * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. + */ + @JsonProperty("downloadURL") + public Optional getDownloadUrl() { + return downloadUrl; + } + + /** + * @return Column that stores primary keys for upsert operations. The column must be marked as unique in the vault schema. Only valid when method is POST. + */ + @JsonProperty("upsert") + public Optional getUpsert() { + return upsert; + } + + /** + * @return Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}. + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1BatchRecord && equalTo((V1BatchRecord) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1BatchRecord other) { + return fields.equals(other.fields) + && tableName.equals(other.tableName) + && method.equals(other.method) + && batchId.equals(other.batchId) + && redaction.equals(other.redaction) + && tokenization.equals(other.tokenization) + && id.equals(other.id) + && downloadUrl.equals(other.downloadUrl) + && upsert.equals(other.upsert) + && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash( + this.fields, + this.tableName, + this.method, + this.batchId, + this.redaction, + this.tokenization, + this.id, + this.downloadUrl, + this.upsert, + this.tokens); + } + + @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> fields = Optional.empty(); + + private Optional tableName = Optional.empty(); + + private Optional method = Optional.empty(); + + private Optional batchId = Optional.empty(); + + private Optional redaction = Optional.empty(); + + private Optional tokenization = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + private Optional upsert = Optional.empty(); + + private Optional> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1BatchRecord other) { + fields(other.getFields()); + tableName(other.getTableName()); + method(other.getMethod()); + batchId(other.getBatchId()); + redaction(other.getRedaction()); + tokenization(other.getTokenization()); + id(other.getId()); + downloadUrl(other.getDownloadUrl()); + upsert(other.getUpsert()); + tokens(other.getTokens()); + return this; + } + + /** + *

Field and value key pairs. For example, {'field_1':'value_1', 'field_2':'value_2'}. Only valid when method is POST or PUT.

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

Name of the table to perform the operation on.

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

ID to group operations by. Operations in the same group are executed sequentially.

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

If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified.

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

skyflow_id for the record. Only valid when method is GET, DELETE, or PUT.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

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

Column that stores primary keys for upsert operations. The column must be marked as unique in the vault schema. Only valid when method is POST.

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

Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}.

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(Map tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public V1BatchRecord build() { + return new V1BatchRecord( + fields, + tableName, + method, + batchId, + redaction, + tokenization, + id, + downloadUrl, + upsert, + tokens, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java new file mode 100644 index 00000000..58472a8b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java @@ -0,0 +1,102 @@ +/** + * 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 = V1BinListResponse.Builder.class) +public final class V1BinListResponse { + private final Optional> cardsData; + + private final Map additionalProperties; + + private V1BinListResponse(Optional> cardsData, Map additionalProperties) { + this.cardsData = cardsData; + this.additionalProperties = additionalProperties; + } + + /** + * @return Card metadata associated with the specified BIN. + */ + @JsonProperty("cards_data") + public Optional> getCardsData() { + return cardsData; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1BinListResponse && equalTo((V1BinListResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1BinListResponse other) { + return cardsData.equals(other.cardsData); + } + + @Override + public int hashCode() { + return Objects.hash(this.cardsData); + } + + @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> cardsData = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1BinListResponse other) { + cardsData(other.getCardsData()); + return this; + } + + /** + *

Card metadata associated with the specified BIN.

+ */ + @JsonSetter(value = "cards_data", nulls = Nulls.SKIP) + public Builder cardsData(Optional> cardsData) { + this.cardsData = cardsData; + return this; + } + + public Builder cardsData(List cardsData) { + this.cardsData = Optional.ofNullable(cardsData); + return this; + } + + public V1BinListResponse build() { + return new V1BinListResponse(cardsData, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java new file mode 100644 index 00000000..ddb0d213 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java @@ -0,0 +1,103 @@ +/** + * 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 = V1BulkDeleteRecordResponse.Builder.class) +public final class V1BulkDeleteRecordResponse { + private final Optional> recordIdResponse; + + private final Map additionalProperties; + + private V1BulkDeleteRecordResponse( + Optional> recordIdResponse, Map additionalProperties) { + this.recordIdResponse = recordIdResponse; + this.additionalProperties = additionalProperties; + } + + /** + * @return IDs for the deleted records, or * if all records were deleted. + */ + @JsonProperty("RecordIDResponse") + public Optional> getRecordIdResponse() { + return recordIdResponse; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1BulkDeleteRecordResponse && equalTo((V1BulkDeleteRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1BulkDeleteRecordResponse other) { + return recordIdResponse.equals(other.recordIdResponse); + } + + @Override + public int hashCode() { + return Objects.hash(this.recordIdResponse); + } + + @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> recordIdResponse = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1BulkDeleteRecordResponse other) { + recordIdResponse(other.getRecordIdResponse()); + return this; + } + + /** + *

IDs for the deleted records, or * if all records were deleted.

+ */ + @JsonSetter(value = "RecordIDResponse", nulls = Nulls.SKIP) + public Builder recordIdResponse(Optional> recordIdResponse) { + this.recordIdResponse = recordIdResponse; + return this; + } + + public Builder recordIdResponse(List recordIdResponse) { + this.recordIdResponse = Optional.ofNullable(recordIdResponse); + return this; + } + + public V1BulkDeleteRecordResponse build() { + return new V1BulkDeleteRecordResponse(recordIdResponse, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java new file mode 100644 index 00000000..c2d3790a --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java @@ -0,0 +1,102 @@ +/** + * 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 = V1BulkGetRecordResponse.Builder.class) +public final class V1BulkGetRecordResponse { + private final Optional> records; + + private final Map additionalProperties; + + private V1BulkGetRecordResponse(Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return The specified records. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1BulkGetRecordResponse && equalTo((V1BulkGetRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1BulkGetRecordResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1BulkGetRecordResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

The specified records.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public V1BulkGetRecordResponse build() { + return new V1BulkGetRecordResponse(records, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1Byot.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1Byot.java new file mode 100644 index 00000000..bafd7a09 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1Byot.java @@ -0,0 +1,26 @@ +/** + * 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 V1Byot { + DISABLE("DISABLE"), + + ENABLE("ENABLE"), + + ENABLE_STRICT("ENABLE_STRICT"); + + private final String value; + + V1Byot(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1Card.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1Card.java new file mode 100644 index 00000000..f2a9db90 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1Card.java @@ -0,0 +1,362 @@ +/** + * 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 = V1Card.Builder.class) +public final class V1Card { + private final Optional bin; + + private final Optional issuerName; + + private final Optional countryCode; + + private final Optional currency; + + private final Optional cardType; + + private final Optional cardCategory; + + private final Optional cardScheme; + + private final Optional cardLastFourDigits; + + private final Optional cardExpiry; + + private final Map additionalProperties; + + private V1Card( + Optional bin, + Optional issuerName, + Optional countryCode, + Optional currency, + Optional cardType, + Optional cardCategory, + Optional cardScheme, + Optional cardLastFourDigits, + Optional cardExpiry, + Map additionalProperties) { + this.bin = bin; + this.issuerName = issuerName; + this.countryCode = countryCode; + this.currency = currency; + this.cardType = cardType; + this.cardCategory = cardCategory; + this.cardScheme = cardScheme; + this.cardLastFourDigits = cardLastFourDigits; + this.cardExpiry = cardExpiry; + this.additionalProperties = additionalProperties; + } + + /** + * @return BIN of the card. + */ + @JsonProperty("BIN") + public Optional getBin() { + return bin; + } + + /** + * @return Name of the card issuer bank. + */ + @JsonProperty("issuer_name") + public Optional getIssuerName() { + return issuerName; + } + + /** + * @return Country code of the card. + */ + @JsonProperty("country_code") + public Optional getCountryCode() { + return countryCode; + } + + /** + * @return Currency of the card. + */ + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + + /** + * @return Type of the card. + */ + @JsonProperty("card_type") + public Optional getCardType() { + return cardType; + } + + /** + * @return Category of the card. + */ + @JsonProperty("card_category") + public Optional getCardCategory() { + return cardCategory; + } + + /** + * @return Scheme of the card. + */ + @JsonProperty("card_scheme") + public Optional getCardScheme() { + return cardScheme; + } + + /** + * @return Last four digits of the card number. + */ + @JsonProperty("card_last_four_digits") + public Optional getCardLastFourDigits() { + return cardLastFourDigits; + } + + /** + * @return Expiry date of the card. + */ + @JsonProperty("card_expiry") + public Optional getCardExpiry() { + return cardExpiry; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Card && equalTo((V1Card) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1Card other) { + return bin.equals(other.bin) + && issuerName.equals(other.issuerName) + && countryCode.equals(other.countryCode) + && currency.equals(other.currency) + && cardType.equals(other.cardType) + && cardCategory.equals(other.cardCategory) + && cardScheme.equals(other.cardScheme) + && cardLastFourDigits.equals(other.cardLastFourDigits) + && cardExpiry.equals(other.cardExpiry); + } + + @Override + public int hashCode() { + return Objects.hash( + this.bin, + this.issuerName, + this.countryCode, + this.currency, + this.cardType, + this.cardCategory, + this.cardScheme, + this.cardLastFourDigits, + this.cardExpiry); + } + + @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 bin = Optional.empty(); + + private Optional issuerName = Optional.empty(); + + private Optional countryCode = Optional.empty(); + + private Optional currency = Optional.empty(); + + private Optional cardType = Optional.empty(); + + private Optional cardCategory = Optional.empty(); + + private Optional cardScheme = Optional.empty(); + + private Optional cardLastFourDigits = Optional.empty(); + + private Optional cardExpiry = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1Card other) { + bin(other.getBin()); + issuerName(other.getIssuerName()); + countryCode(other.getCountryCode()); + currency(other.getCurrency()); + cardType(other.getCardType()); + cardCategory(other.getCardCategory()); + cardScheme(other.getCardScheme()); + cardLastFourDigits(other.getCardLastFourDigits()); + cardExpiry(other.getCardExpiry()); + return this; + } + + /** + *

BIN of the card.

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

Name of the card issuer bank.

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

Country code of the card.

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

Currency of the card.

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

Type of the card.

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

Category of the card.

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

Scheme of the card.

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

Last four digits of the card number.

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

Expiry date of the card.

+ */ + @JsonSetter(value = "card_expiry", nulls = Nulls.SKIP) + public Builder cardExpiry(Optional cardExpiry) { + this.cardExpiry = cardExpiry; + return this; + } + + public Builder cardExpiry(String cardExpiry) { + this.cardExpiry = Optional.ofNullable(cardExpiry); + return this; + } + + public V1Card build() { + return new V1Card( + bin, + issuerName, + countryCode, + currency, + cardType, + cardCategory, + cardScheme, + cardLastFourDigits, + cardExpiry, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java new file mode 100644 index 00000000..4ec85903 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java @@ -0,0 +1,130 @@ +/** + * 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 = V1DeleteFileResponse.Builder.class) +public final class V1DeleteFileResponse { + private final Optional skyflowId; + + private final Optional deleted; + + private final Map additionalProperties; + + private V1DeleteFileResponse( + Optional skyflowId, Optional deleted, Map additionalProperties) { + this.skyflowId = skyflowId; + this.deleted = deleted; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the record. + */ + @JsonProperty("skyflow_id") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return If true, the file was deleted. + */ + @JsonProperty("deleted") + public Optional getDeleted() { + return deleted; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1DeleteFileResponse && equalTo((V1DeleteFileResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1DeleteFileResponse other) { + return skyflowId.equals(other.skyflowId) && deleted.equals(other.deleted); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.deleted); + } + + @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 deleted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1DeleteFileResponse other) { + skyflowId(other.getSkyflowId()); + deleted(other.getDeleted()); + return this; + } + + /** + *

ID of the record.

+ */ + @JsonSetter(value = "skyflow_id", 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; + } + + /** + *

If true, the file was deleted.

+ */ + @JsonSetter(value = "deleted", nulls = Nulls.SKIP) + public Builder deleted(Optional deleted) { + this.deleted = deleted; + return this; + } + + public Builder deleted(Boolean deleted) { + this.deleted = Optional.ofNullable(deleted); + return this; + } + + public V1DeleteFileResponse build() { + return new V1DeleteFileResponse(skyflowId, deleted, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java new file mode 100644 index 00000000..2f3bde14 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java @@ -0,0 +1,130 @@ +/** + * 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 = V1DeleteRecordResponse.Builder.class) +public final class V1DeleteRecordResponse { + private final Optional skyflowId; + + private final Optional deleted; + + private final Map additionalProperties; + + private V1DeleteRecordResponse( + Optional skyflowId, Optional deleted, Map additionalProperties) { + this.skyflowId = skyflowId; + this.deleted = deleted; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the deleted record. + */ + @JsonProperty("skyflow_id") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return If true, the record was deleted. + */ + @JsonProperty("deleted") + public Optional getDeleted() { + return deleted; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1DeleteRecordResponse && equalTo((V1DeleteRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1DeleteRecordResponse other) { + return skyflowId.equals(other.skyflowId) && deleted.equals(other.deleted); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.deleted); + } + + @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 deleted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1DeleteRecordResponse other) { + skyflowId(other.getSkyflowId()); + deleted(other.getDeleted()); + return this; + } + + /** + *

ID of the deleted record.

+ */ + @JsonSetter(value = "skyflow_id", 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; + } + + /** + *

If true, the record was deleted.

+ */ + @JsonSetter(value = "deleted", nulls = Nulls.SKIP) + public Builder deleted(Optional deleted) { + this.deleted = deleted; + return this; + } + + public Builder deleted(Boolean deleted) { + this.deleted = Optional.ofNullable(deleted); + return this; + } + + public V1DeleteRecordResponse build() { + return new V1DeleteRecordResponse(skyflowId, deleted, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java new file mode 100644 index 00000000..26b8320e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java @@ -0,0 +1,101 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.statusUrl); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java new file mode 100644 index 00000000..183cd103 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java @@ -0,0 +1,156 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.status, this.output, this.message); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java new file mode 100644 index 00000000..58f848ca --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java @@ -0,0 +1,28 @@ +/** + * 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 V1DetectStatusResponseStatus { + UNKNOWN("UNKNOWN"), + + FAILED("FAILED"), + + SUCCESS("SUCCESS"), + + IN_PROGRESS("IN_PROGRESS"); + + private final String value; + + V1DetectStatusResponseStatus(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java new file mode 100644 index 00000000..6f518de6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java @@ -0,0 +1,522 @@ +/** + * 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; + } + + @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); + } + + @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); + } + + @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() {} + + @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. + */ + @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. + */ + @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. + */ + @Override + public _FinalStage storeEntities(Boolean storeEntities) { + this.storeEntities = Optional.ofNullable(storeEntities); + return this; + } + + /** + *

Indicates whether entities should be stored in the vault.

+ */ + @Override + @JsonSetter(value = "store_entities", nulls = Nulls.SKIP) + public _FinalStage storeEntities(Optional storeEntities) { + this.storeEntities = storeEntities; + return this; + } + + @Override + public _FinalStage advancedOptions(V1AdvancedOptions advancedOptions) { + this.advancedOptions = Optional.ofNullable(advancedOptions); + return this; + } + + @Override + @JsonSetter(value = "advanced_options", nulls = Nulls.SKIP) + public _FinalStage advancedOptions(Optional advancedOptions) { + this.advancedOptions = advancedOptions; + return this; + } + + @Override + public _FinalStage accuracy(DetectDataAccuracy accuracy) { + this.accuracy = Optional.ofNullable(accuracy); + return this; + } + + @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. + */ + @Override + public _FinalStage returnEntities(Boolean returnEntities) { + this.returnEntities = Optional.ofNullable(returnEntities); + return this; + } + + /** + *

If true, returns the details for the detected entities.

+ */ + @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. + */ + @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'.

+ */ + @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. + */ + @Override + public _FinalStage allowRegex(List allowRegex) { + this.allowRegex = Optional.ofNullable(allowRegex); + return this; + } + + /** + *

Regular expressions to ignore when detecting entities.

+ */ + @Override + @JsonSetter(value = "allow_regex", nulls = Nulls.SKIP) + public _FinalStage allowRegex(Optional> allowRegex) { + this.allowRegex = allowRegex; + return this; + } + + @Override + public _FinalStage deidentifyTokenFormat(DetectRequestDeidentifyOption deidentifyTokenFormat) { + this.deidentifyTokenFormat = Optional.ofNullable(deidentifyTokenFormat); + return this; + } + + @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. + */ + @Override + public _FinalStage restrictEntityTypes(List restrictEntityTypes) { + this.restrictEntityTypes = Optional.ofNullable(restrictEntityTypes); + return this; + } + + /** + *

Entities to detect and deidentify.

+ */ + @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. + */ + @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.

+ */ + @Override + @JsonSetter(value = "session_id", nulls = Nulls.SKIP) + public _FinalStage sessionId(Optional sessionId) { + this.sessionId = sessionId; + return this; + } + + @Override + public V1DetectTextRequest build() { + return new V1DetectTextRequest( + text, + vaultId, + sessionId, + restrictEntityTypes, + deidentifyTokenFormat, + allowRegex, + restrictRegex, + returnEntities, + accuracy, + advancedOptions, + storeEntities, + additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java new file mode 100644 index 00000000..de6090d6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java @@ -0,0 +1,133 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.processedText, this.entities); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.java new file mode 100644 index 00000000..3cf5b59c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.java @@ -0,0 +1,126 @@ +/** + * 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 = V1DetokenizeRecordRequest.Builder.class) +public final class V1DetokenizeRecordRequest { + private final Optional token; + + private final Optional redaction; + + private final Map additionalProperties; + + private V1DetokenizeRecordRequest( + Optional token, + Optional redaction, + Map additionalProperties) { + this.token = token; + this.redaction = redaction; + this.additionalProperties = additionalProperties; + } + + /** + * @return Token that identifies the record to detokenize. + */ + @JsonProperty("token") + public Optional getToken() { + return token; + } + + @JsonProperty("redaction") + public Optional getRedaction() { + return redaction; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1DetokenizeRecordRequest && equalTo((V1DetokenizeRecordRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1DetokenizeRecordRequest other) { + return token.equals(other.token) && redaction.equals(other.redaction); + } + + @Override + public int hashCode() { + return Objects.hash(this.token, this.redaction); + } + + @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 token = Optional.empty(); + + private Optional redaction = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1DetokenizeRecordRequest other) { + token(other.getToken()); + redaction(other.getRedaction()); + return this; + } + + /** + *

Token that identifies the record to detokenize.

+ */ + @JsonSetter(value = "token", nulls = Nulls.SKIP) + public Builder token(Optional token) { + this.token = token; + return this; + } + + public Builder token(String token) { + this.token = Optional.ofNullable(token); + return this; + } + + @JsonSetter(value = "redaction", nulls = Nulls.SKIP) + public Builder redaction(Optional redaction) { + this.redaction = redaction; + return this; + } + + public Builder redaction(RedactionEnumRedaction redaction) { + this.redaction = Optional.ofNullable(redaction); + return this; + } + + public V1DetokenizeRecordRequest build() { + return new V1DetokenizeRecordRequest(token, redaction, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java new file mode 100644 index 00000000..ba0abbfa --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java @@ -0,0 +1,187 @@ +/** + * 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 = V1DetokenizeRecordResponse.Builder.class) +public final class V1DetokenizeRecordResponse { + private final Optional token; + + private final Optional valueType; + + private final Optional value; + + private final Optional error; + + private final Map additionalProperties; + + private V1DetokenizeRecordResponse( + Optional token, + Optional valueType, + Optional value, + Optional error, + Map additionalProperties) { + this.token = token; + this.valueType = valueType; + this.value = value; + this.error = error; + this.additionalProperties = additionalProperties; + } + + /** + * @return Token of the record. + */ + @JsonProperty("token") + public Optional getToken() { + return token; + } + + @JsonProperty("valueType") + public Optional getValueType() { + return valueType; + } + + /** + * @return Data corresponding to the token. + */ + @JsonProperty("value") + public Optional getValue() { + return value; + } + + /** + * @return Error if token isn't found. + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1DetokenizeRecordResponse && equalTo((V1DetokenizeRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1DetokenizeRecordResponse other) { + return token.equals(other.token) + && valueType.equals(other.valueType) + && value.equals(other.value) + && error.equals(other.error); + } + + @Override + public int hashCode() { + return Objects.hash(this.token, this.valueType, this.value, this.error); + } + + @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 token = Optional.empty(); + + private Optional valueType = Optional.empty(); + + private Optional value = Optional.empty(); + + private Optional error = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1DetokenizeRecordResponse other) { + token(other.getToken()); + valueType(other.getValueType()); + value(other.getValue()); + error(other.getError()); + return this; + } + + /** + *

Token of the record.

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

Data corresponding to the token.

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

Error if token isn't found.

+ */ + @JsonSetter(value = "error", nulls = Nulls.SKIP) + public Builder error(Optional error) { + this.error = error; + return this; + } + + public Builder error(String error) { + this.error = Optional.ofNullable(error); + return this; + } + + public V1DetokenizeRecordResponse build() { + return new V1DetokenizeRecordResponse(token, valueType, value, error, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java new file mode 100644 index 00000000..74f4f6e6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java @@ -0,0 +1,103 @@ +/** + * 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 = V1DetokenizeResponse.Builder.class) +public final class V1DetokenizeResponse { + private final Optional> records; + + private final Map additionalProperties; + + private V1DetokenizeResponse( + Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return Records corresponding to the specified tokens. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1DetokenizeResponse && equalTo((V1DetokenizeResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1DetokenizeResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1DetokenizeResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

Records corresponding to the specified tokens.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public V1DetokenizeResponse build() { + return new V1DetokenizeResponse(records, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java new file mode 100644 index 00000000..dfbccb8b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java @@ -0,0 +1,132 @@ +/** + * 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 = V1FieldRecords.Builder.class) +public final class V1FieldRecords { + private final Optional> fields; + + private final Optional> tokens; + + private final Map additionalProperties; + + private V1FieldRecords( + Optional> fields, + Optional> tokens, + Map additionalProperties) { + this.fields = fields; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return Fields and values for the record. For example, {'field_1':'value_1', 'field_2':'value_2'}. + */ + @JsonProperty("fields") + public Optional> getFields() { + return fields; + } + + /** + * @return Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}. + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1FieldRecords && equalTo((V1FieldRecords) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1FieldRecords other) { + return fields.equals(other.fields) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.fields, this.tokens); + } + + @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> fields = Optional.empty(); + + private Optional> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1FieldRecords other) { + fields(other.getFields()); + tokens(other.getTokens()); + return this; + } + + /** + *

Fields and values for the record. For example, {'field_1':'value_1', 'field_2':'value_2'}.

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

Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}.

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(Map tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public V1FieldRecords build() { + return new V1FieldRecords(fields, tokens, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java new file mode 100644 index 00000000..02658ef2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java @@ -0,0 +1,38 @@ +/** + * 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 V1FileAvScanStatus { + SCAN_NONE("SCAN_NONE"), + + SCAN_CLEAN("SCAN_CLEAN"), + + SCAN_INFECTED("SCAN_INFECTED"), + + SCAN_DELETED("SCAN_DELETED"), + + SCAN_ERROR("SCAN_ERROR"), + + SCAN_PENDING("SCAN_PENDING"), + + SCAN_UNSCANNABLE("SCAN_UNSCANNABLE"), + + SCAN_FILE_NOT_FOUND("SCAN_FILE_NOT_FOUND"), + + SCAN_INVALID("SCAN_INVALID"); + + private final String value; + + V1FileAvScanStatus(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java new file mode 100644 index 00000000..8e4b568c --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java @@ -0,0 +1,58 @@ +/** + * 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 V1FileDataFormat { + BMP("bmp"), + + 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"); + + private final String value; + + V1FileDataFormat(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java new file mode 100644 index 00000000..f5669085 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java @@ -0,0 +1,130 @@ +/** + * 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 = V1GetAuthTokenResponse.Builder.class) +public final class V1GetAuthTokenResponse { + private final Optional accessToken; + + private final Optional tokenType; + + private final Map additionalProperties; + + private V1GetAuthTokenResponse( + Optional accessToken, Optional tokenType, Map additionalProperties) { + this.accessToken = accessToken; + this.tokenType = tokenType; + this.additionalProperties = additionalProperties; + } + + /** + * @return AccessToken. + */ + @JsonProperty("accessToken") + public Optional getAccessToken() { + return accessToken; + } + + /** + * @return TokenType : Bearer. + */ + @JsonProperty("tokenType") + public Optional getTokenType() { + return tokenType; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1GetAuthTokenResponse && equalTo((V1GetAuthTokenResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1GetAuthTokenResponse other) { + return accessToken.equals(other.accessToken) && tokenType.equals(other.tokenType); + } + + @Override + public int hashCode() { + return Objects.hash(this.accessToken, this.tokenType); + } + + @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 accessToken = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1GetAuthTokenResponse other) { + accessToken(other.getAccessToken()); + tokenType(other.getTokenType()); + return this; + } + + /** + *

AccessToken.

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

TokenType : Bearer.

+ */ + @JsonSetter(value = "tokenType", nulls = Nulls.SKIP) + public Builder tokenType(Optional tokenType) { + this.tokenType = tokenType; + return this; + } + + public Builder tokenType(String tokenType) { + this.tokenType = Optional.ofNullable(tokenType); + return this; + } + + public V1GetAuthTokenResponse build() { + return new V1GetAuthTokenResponse(accessToken, tokenType, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java new file mode 100644 index 00000000..4bd67013 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java @@ -0,0 +1,96 @@ +/** + * 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 = V1GetFileScanStatusResponse.Builder.class) +public final class V1GetFileScanStatusResponse { + private final Optional avScanStatus; + + private final Map additionalProperties; + + private V1GetFileScanStatusResponse( + Optional avScanStatus, Map additionalProperties) { + this.avScanStatus = avScanStatus; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("av_scan_status") + public Optional getAvScanStatus() { + return avScanStatus; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1GetFileScanStatusResponse && equalTo((V1GetFileScanStatusResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1GetFileScanStatusResponse other) { + return avScanStatus.equals(other.avScanStatus); + } + + @Override + public int hashCode() { + return Objects.hash(this.avScanStatus); + } + + @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 avScanStatus = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1GetFileScanStatusResponse other) { + avScanStatus(other.getAvScanStatus()); + return this; + } + + @JsonSetter(value = "av_scan_status", nulls = Nulls.SKIP) + public Builder avScanStatus(Optional avScanStatus) { + this.avScanStatus = avScanStatus; + return this; + } + + public Builder avScanStatus(V1FileAvScanStatus avScanStatus) { + this.avScanStatus = Optional.ofNullable(avScanStatus); + return this; + } + + public V1GetFileScanStatusResponse build() { + return new V1GetFileScanStatusResponse(avScanStatus, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java new file mode 100644 index 00000000..821d1f06 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java @@ -0,0 +1,102 @@ +/** + * 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 = V1GetQueryResponse.Builder.class) +public final class V1GetQueryResponse { + private final Optional> records; + + private final Map additionalProperties; + + private V1GetQueryResponse(Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return Records returned by the query. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1GetQueryResponse && equalTo((V1GetQueryResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1GetQueryResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1GetQueryResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

Records returned by the query.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public V1GetQueryResponse build() { + return new V1GetQueryResponse(records, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java new file mode 100644 index 00000000..f457b11b --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java @@ -0,0 +1,132 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.outputProcessedImage, this.outputOcrText); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java new file mode 100644 index 00000000..0addf786 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java @@ -0,0 +1,103 @@ +/** + * 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 = V1InsertRecordResponse.Builder.class) +public final class V1InsertRecordResponse { + private final Optional> records; + + private final Map additionalProperties; + + private V1InsertRecordResponse( + Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return Identifiers for the inserted records. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1InsertRecordResponse && equalTo((V1InsertRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1InsertRecordResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1InsertRecordResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

Identifiers for the inserted records.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public V1InsertRecordResponse build() { + return new V1InsertRecordResponse(records, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1Locations.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1Locations.java new file mode 100644 index 00000000..07a7b7e7 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1Locations.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 = 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.startIndex, this.endIndex, this.startIndexProcessed, this.endIndexProcessed); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1MemberType.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1MemberType.java new file mode 100644 index 00000000..48e96379 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1MemberType.java @@ -0,0 +1,26 @@ +/** + * 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 V1MemberType { + NONE("NONE"), + + USER("USER"), + + SERVICE_ACCOUNT("SERVICE_ACCOUNT"); + + private final String value; + + V1MemberType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java new file mode 100644 index 00000000..b8a6efde --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java @@ -0,0 +1,95 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.options); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java new file mode 100644 index 00000000..312d2702 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java @@ -0,0 +1,130 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.density, this.maxResolution); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java new file mode 100644 index 00000000..ba09f5bc --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java @@ -0,0 +1,151 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.outputType, this.processedFile, this.processedFileType); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.java new file mode 100644 index 00000000..f69719cf --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.java @@ -0,0 +1,132 @@ +/** + * 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 = V1RecordMetaProperties.Builder.class) +public final class V1RecordMetaProperties { + private final Optional skyflowId; + + private final Optional> tokens; + + private final Map additionalProperties; + + private V1RecordMetaProperties( + Optional skyflowId, + Optional> tokens, + Map additionalProperties) { + this.skyflowId = skyflowId; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the inserted record. + */ + @JsonProperty("skyflow_id") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return Tokens for the record. + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1RecordMetaProperties && equalTo((V1RecordMetaProperties) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1RecordMetaProperties other) { + return skyflowId.equals(other.skyflowId) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.tokens); + } + + @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> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1RecordMetaProperties other) { + skyflowId(other.getSkyflowId()); + tokens(other.getTokens()); + return this; + } + + /** + *

ID of the inserted record.

+ */ + @JsonSetter(value = "skyflow_id", 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; + } + + /** + *

Tokens for the record.

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(Map tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public V1RecordMetaProperties build() { + return new V1RecordMetaProperties(skyflowId, tokens, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java new file mode 100644 index 00000000..001fa29e --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java @@ -0,0 +1,218 @@ +/** + * 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; + } + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(this.processedText, this.originalText, this.location, this.bestLabel, this.labels); + } + + @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/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.java new file mode 100644 index 00000000..2c15ceac --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.java @@ -0,0 +1,130 @@ +/** + * 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 = V1TokenizeRecordRequest.Builder.class) +public final class V1TokenizeRecordRequest { + private final Optional value; + + private final Optional columnGroup; + + private final Map additionalProperties; + + private V1TokenizeRecordRequest( + Optional value, Optional columnGroup, Map additionalProperties) { + this.value = value; + this.columnGroup = columnGroup; + this.additionalProperties = additionalProperties; + } + + /** + * @return Existing value to return a token for. + */ + @JsonProperty("value") + public Optional getValue() { + return value; + } + + /** + * @return Name of the column group that the value belongs to. + */ + @JsonProperty("columnGroup") + public Optional getColumnGroup() { + return columnGroup; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1TokenizeRecordRequest && equalTo((V1TokenizeRecordRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1TokenizeRecordRequest other) { + return value.equals(other.value) && columnGroup.equals(other.columnGroup); + } + + @Override + public int hashCode() { + return Objects.hash(this.value, this.columnGroup); + } + + @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 value = Optional.empty(); + + private Optional columnGroup = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1TokenizeRecordRequest other) { + value(other.getValue()); + columnGroup(other.getColumnGroup()); + return this; + } + + /** + *

Existing value to return a token for.

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

Name of the column group that the value belongs to.

+ */ + @JsonSetter(value = "columnGroup", nulls = Nulls.SKIP) + public Builder columnGroup(Optional columnGroup) { + this.columnGroup = columnGroup; + return this; + } + + public Builder columnGroup(String columnGroup) { + this.columnGroup = Optional.ofNullable(columnGroup); + return this; + } + + public V1TokenizeRecordRequest build() { + return new V1TokenizeRecordRequest(value, columnGroup, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java new file mode 100644 index 00000000..201a4f60 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java @@ -0,0 +1,101 @@ +/** + * 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 = V1TokenizeRecordResponse.Builder.class) +public final class V1TokenizeRecordResponse { + private final Optional token; + + private final Map additionalProperties; + + private V1TokenizeRecordResponse(Optional token, Map additionalProperties) { + this.token = token; + this.additionalProperties = additionalProperties; + } + + /** + * @return Token corresponding to a value. + */ + @JsonProperty("token") + public Optional getToken() { + return token; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1TokenizeRecordResponse && equalTo((V1TokenizeRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1TokenizeRecordResponse other) { + return token.equals(other.token); + } + + @Override + public int hashCode() { + return Objects.hash(this.token); + } + + @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 token = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1TokenizeRecordResponse other) { + token(other.getToken()); + return this; + } + + /** + *

Token corresponding to a value.

+ */ + @JsonSetter(value = "token", nulls = Nulls.SKIP) + public Builder token(Optional token) { + this.token = token; + return this; + } + + public Builder token(String token) { + this.token = Optional.ofNullable(token); + return this; + } + + public V1TokenizeRecordResponse build() { + return new V1TokenizeRecordResponse(token, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java new file mode 100644 index 00000000..62d77bed --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java @@ -0,0 +1,103 @@ +/** + * 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 = V1TokenizeResponse.Builder.class) +public final class V1TokenizeResponse { + private final Optional> records; + + private final Map additionalProperties; + + private V1TokenizeResponse( + Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return Tokens corresponding to the specified values. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1TokenizeResponse && equalTo((V1TokenizeResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1TokenizeResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1TokenizeResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

Tokens corresponding to the specified values.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public V1TokenizeResponse build() { + return new V1TokenizeResponse(records, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java new file mode 100644 index 00000000..03ed7b58 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java @@ -0,0 +1,132 @@ +/** + * 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 = V1UpdateRecordResponse.Builder.class) +public final class V1UpdateRecordResponse { + private final Optional skyflowId; + + private final Optional> tokens; + + private final Map additionalProperties; + + private V1UpdateRecordResponse( + Optional skyflowId, + Optional> tokens, + Map additionalProperties) { + this.skyflowId = skyflowId; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the updated record. + */ + @JsonProperty("skyflow_id") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return Tokens for the record. + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1UpdateRecordResponse && equalTo((V1UpdateRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1UpdateRecordResponse other) { + return skyflowId.equals(other.skyflowId) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.tokens); + } + + @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> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1UpdateRecordResponse other) { + skyflowId(other.getSkyflowId()); + tokens(other.getTokens()); + return this; + } + + /** + *

ID of the updated record.

+ */ + @JsonSetter(value = "skyflow_id", 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; + } + + /** + *

Tokens for the record.

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(Map tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public V1UpdateRecordResponse build() { + return new V1UpdateRecordResponse(skyflowId, tokens, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java new file mode 100644 index 00000000..c19d1cb5 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java @@ -0,0 +1,163 @@ +/** + * 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 = V1VaultFieldMapping.Builder.class) +public final class V1VaultFieldMapping { + private final Optional cardNumber; + + private final Optional cardLastFourDigits; + + private final Optional cardExpiry; + + private final Map additionalProperties; + + private V1VaultFieldMapping( + Optional cardNumber, + Optional cardLastFourDigits, + Optional cardExpiry, + Map additionalProperties) { + this.cardNumber = cardNumber; + this.cardLastFourDigits = cardLastFourDigits; + this.cardExpiry = cardExpiry; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the column that stores the card number. + */ + @JsonProperty("card_number") + public Optional getCardNumber() { + return cardNumber; + } + + /** + * @return Name of the column that stores the card number suffix. + */ + @JsonProperty("card_last_four_digits") + public Optional getCardLastFourDigits() { + return cardLastFourDigits; + } + + /** + * @return Name of the column that stores the expiry date. + */ + @JsonProperty("card_expiry") + public Optional getCardExpiry() { + return cardExpiry; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1VaultFieldMapping && equalTo((V1VaultFieldMapping) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1VaultFieldMapping other) { + return cardNumber.equals(other.cardNumber) + && cardLastFourDigits.equals(other.cardLastFourDigits) + && cardExpiry.equals(other.cardExpiry); + } + + @Override + public int hashCode() { + return Objects.hash(this.cardNumber, this.cardLastFourDigits, this.cardExpiry); + } + + @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 cardNumber = Optional.empty(); + + private Optional cardLastFourDigits = Optional.empty(); + + private Optional cardExpiry = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1VaultFieldMapping other) { + cardNumber(other.getCardNumber()); + cardLastFourDigits(other.getCardLastFourDigits()); + cardExpiry(other.getCardExpiry()); + return this; + } + + /** + *

Name of the column that stores the card number.

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

Name of the column that stores the card number suffix.

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

Name of the column that stores the expiry date.

+ */ + @JsonSetter(value = "card_expiry", nulls = Nulls.SKIP) + public Builder cardExpiry(Optional cardExpiry) { + this.cardExpiry = cardExpiry; + return this; + } + + public Builder cardExpiry(String cardExpiry) { + this.cardExpiry = Optional.ofNullable(cardExpiry); + return this; + } + + public V1VaultFieldMapping build() { + return new V1VaultFieldMapping(cardNumber, cardLastFourDigits, cardExpiry, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java b/v2/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java new file mode 100644 index 00000000..cd838305 --- /dev/null +++ b/v2/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java @@ -0,0 +1,155 @@ +/** + * 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 = V1VaultSchemaConfig.Builder.class) +public final class V1VaultSchemaConfig { + private final Optional id; + + private final Optional tableName; + + private final Optional mapping; + + private final Map additionalProperties; + + private V1VaultSchemaConfig( + Optional id, + Optional tableName, + Optional mapping, + Map additionalProperties) { + this.id = id; + this.tableName = tableName; + this.mapping = mapping; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault that stores card details. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return Name of the table that stores card details. + */ + @JsonProperty("table_name") + public Optional getTableName() { + return tableName; + } + + @JsonProperty("mapping") + public Optional getMapping() { + return mapping; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1VaultSchemaConfig && equalTo((V1VaultSchemaConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1VaultSchemaConfig other) { + return id.equals(other.id) && tableName.equals(other.tableName) && mapping.equals(other.mapping); + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.tableName, this.mapping); + } + + @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 id = Optional.empty(); + + private Optional tableName = Optional.empty(); + + private Optional mapping = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(V1VaultSchemaConfig other) { + id(other.getId()); + tableName(other.getTableName()); + mapping(other.getMapping()); + return this; + } + + /** + *

ID of the vault that stores card details.

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

Name of the table that stores card details.

+ */ + @JsonSetter(value = "table_name", nulls = Nulls.SKIP) + public Builder tableName(Optional tableName) { + this.tableName = tableName; + return this; + } + + public Builder tableName(String tableName) { + this.tableName = Optional.ofNullable(tableName); + return this; + } + + @JsonSetter(value = "mapping", nulls = Nulls.SKIP) + public Builder mapping(Optional mapping) { + this.mapping = mapping; + return this; + } + + public Builder mapping(V1VaultFieldMapping mapping) { + this.mapping = Optional.ofNullable(mapping); + return this; + } + + public V1VaultSchemaConfig build() { + return new V1VaultSchemaConfig(id, tableName, mapping, additionalProperties); + } + } +} diff --git a/v2/src/main/java/com/skyflow/logs/ErrorLogs.java b/v2/src/main/java/com/skyflow/logs/ErrorLogs.java new file mode 100644 index 00000000..3415860c --- /dev/null +++ b/v2/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -0,0 +1,140 @@ +package com.skyflow.logs; + +public enum ErrorLogs { + // Client initialization + VAULT_CONFIG_EXISTS("Vault config with vault ID %s1 already exists."), + VAULT_CONFIG_DOES_NOT_EXIST("Vault config with vault ID %s1 doesn't exist."), + VAULT_ID_IS_REQUIRED("Invalid vault config. Vault ID is required."), + EMPTY_VAULT_ID("Invalid vault config. Vault ID can not be empty."), + CLUSTER_ID_IS_REQUIRED("Invalid vault config. Cluster ID is required."), + EMPTY_CLUSTER_ID("Invalid vault config. Cluster ID can not be empty."), + CONNECTION_CONFIG_EXISTS("Connection config with connection ID %s1 already exists."), + CONNECTION_CONFIG_DOES_NOT_EXIST("Connection config with connection ID %s1 doesn't exist."), + CONNECTION_ID_IS_REQUIRED("Invalid connection config. Connection ID is required."), + EMPTY_CONNECTION_ID("Invalid connection config. Connection ID can not be empty."), + CONNECTION_URL_IS_REQUIRED("Invalid connection config. Connection URL is required."), + EMPTY_CONNECTION_URL("Invalid connection config. Connection URL can not be empty."), + INVALID_CONNECTION_URL("Invalid connection config. Connection URL is not a valid URL."), + MULTIPLE_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Only one of 'path', 'credentialsString', 'token' or 'apiKey' is allowed."), + NO_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Any one of 'path', 'credentialsString', 'token' or 'apiKey' is required."), + EMPTY_CREDENTIALS_PATH("Invalid credentials. Credentials path can not be empty."), + EMPTY_CREDENTIALS_STRING("Invalid credentials. Credentials string can not be empty."), + EMPTY_TOKEN_VALUE("Invalid credentials. Token can not be empty."), + EMPTY_API_KEY_VALUE("Invalid credentials. Api key can not be empty."), + INVALID_API_KEY("Invalid credentials. Api key is invalid."), + EMPTY_ROLES("Invalid credentials. Roles can not be empty."), + EMPTY_OR_NULL_ROLE_IN_ROLES("Invalid credentials. Role can not be null or empty in roles at index %s1."), + EMPTY_OR_NULL_CONTEXT("Invalid credentials. Context can not be empty."), + + // Bearer token generation + INVALID_BEARER_TOKEN("Bearer token is invalid or expired."), + INVALID_CREDENTIALS_FILE("Credentials file is either null or an invalid file."), + INVALID_CREDENTIALS_STRING("Credentials string is either null or empty."), + INVALID_CREDENTIALS_FILE_FORMAT("Credentials file is not in a valid JSON format."), + CREDENTIALS_FILE_NOT_FOUND("Credentials file not found at specified path."), + INVALID_CREDENTIALS_STRING_FORMAT("Credentials string is not in a valid JSON string format."), + PRIVATE_KEY_IS_REQUIRED("Private key is required."), + CLIENT_ID_IS_REQUIRED("Client ID is required."), + KEY_ID_IS_REQUIRED("Key ID is required."), + TOKEN_URI_IS_REQUIRED("Token URI is required."), + INVALID_TOKEN_URI("Invalid value for token URI in credentials."), + JWT_INVALID_FORMAT("Private key is not in a valid format."), + INVALID_ALGORITHM("Algorithm for parsing private key is invalid or does not exist."), + INVALID_KEY_SPEC("Unable to parse RSA private key."), + BEARER_TOKEN_REJECTED("Bearer token request resulted in failure."), + SIGNED_DATA_TOKENS_REJECTED("Signed data tokens request resulted in failure."), + + // Vault api interfaces + TABLE_IS_REQUIRED("Invalid %s1 request. Table is required."), + EMPTY_TABLE_NAME("Invalid %s1 request. Table name can not be empty."), + VALUES_IS_REQUIRED("Invalid %s1 request. Values are required."), + EMPTY_VALUES("Invalid %s1 request. Values can not be empty."), + EMPTY_OR_NULL_VALUE_IN_VALUES("Invalid %s1 request. Value can not be null or empty in values for key \"%s2\"."), + EMPTY_OR_NULL_KEY_IN_VALUES("Invalid %s1 request. Key can not be null or empty in values"), + EMPTY_UPSERT("Invalid %s1 request. Upsert can not be empty."), + HOMOGENOUS_NOT_SUPPORTED_WITH_UPSERT("Invalid %s1 request. Homogenous is not supported when upsert is passed."), + TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE("Invalid %s1 request. Tokens are not allowed when tokenMode is DISABLE."), + TOKENS_REQUIRED_WITH_TOKEN_MODE("Invalid %s1 request. Tokens are required when tokenMode is %s2."), + EMPTY_TOKENS("Invalid %s1 request. Tokens can not be empty."), + EMPTY_OR_NULL_VALUE_IN_TOKENS("Invalid %s1 request. Value can not be null or empty in tokens for key \"%s2\"."), + EMPTY_OR_NULL_KEY_IN_TOKENS("Invalid %s1 request. Key can not be null or empty in tokens."), + INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT("Invalid %s1 request. For tokenMode as ENABLE_STRICT, tokens should be passed for all fields."), + MISMATCH_OF_FIELDS_AND_TOKENS("Invalid %s1 request. Keys for values and tokens are not matching."), + INSERT_RECORDS_REJECTED("Insert request resulted in failure."), + DETOKENIZE_DATA_REQUIRED("Invalid %s1 request. Detokenize data is required."), + EMPTY_DETOKENIZE_DATA("Invalid %s1 request. Detokenize data can not be empty."), + EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA("Invalid %s1 request. Token can not be null or empty in detokenize data at index %s2."), + REDACTION_IS_REQUIRED("Invalid %s1 request. Redaction is required."), + DETOKENIZE_REQUEST_REJECTED("Detokenize request resulted in failure."), + IDS_IS_REQUIRED("Invalid %s1 request. Ids are required."), + EMPTY_IDS("Invalid %s1 request. Ids can not be empty."), + EMPTY_OR_NULL_ID_IN_IDS("Invalid %s1 request. Id can not be null or empty in ids at index %s2."), + EMPTY_FIELDS("Invalid %s1 request. Fields can not be empty."), + EMPTY_OR_NULL_FIELD_IN_FIELDS("Invalid %s1 request. Field can not be null or empty in fields at index %s2."), + TOKENIZATION_NOT_SUPPORTED_WITH_REDACTION("Invalid %s1 request. Return tokens is not supported when redaction is applied."), + TOKENIZATION_SUPPORTED_ONLY_WITH_IDS("Invalid %s1 request. Return tokens is not supported when column name and values are passed."), + EMPTY_OFFSET("Invalid %s1 request. Offset can not be empty."), + EMPTY_LIMIT("Invalid %s1 request. Limit can not be empty."), + NEITHER_IDS_NOR_COLUMN_NAME_PASSED("Invalid %s1 request. Neither ids nor column name and values are passed."), + BOTH_IDS_AND_COLUMN_NAME_PASSED("Invalid %s1 request. Both ids and column name and values are passed."), + COLUMN_NAME_IS_REQUIRED("Invalid %s1 request. Column name is required when column values are passed."), + EMPTY_COLUMN_NAME("Invalid %s1 request. Column name can not be empty."), + COLUMN_VALUES_IS_REQUIRED_GET("Invalid %s1 request. Column values are required when column name is passed."), + EMPTY_COLUMN_VALUES("Invalid %s1 request. Column values can not be empty."), + EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES("Invalid %s1 request. Column value can not by null or empty in column values at index %s2."), + GET_REQUEST_REJECTED("Get request resulted in failure."), + DATA_IS_REQUIRED("Invalid %s1 request. Data is required."), + EMPTY_DATA("Invalid %s1 request. Data can not be empty."), + SKYFLOW_ID_IS_REQUIRED("Invalid %s1 request. Skyflow Id is required."), + INVALID_SKYFLOW_ID_TYPE("Invalid %s1 request. Skyflow Id should of type String."), + EMPTY_SKYFLOW_ID("Invalid %s1 request. Skyflow Id can not be empty."), + UPDATE_REQUEST_REJECTED("Update request resulted in failure."), + QUERY_IS_REQUIRED("Invalid %s1 request. Query is required."), + EMPTY_QUERY("Invalid %s1 request. Query can not be empty."), + QUERY_REQUEST_REJECTED("Query request resulted in failure."), + COLUMN_VALUES_IS_REQUIRED_TOKENIZE("Invalid %s1 request. ColumnValues are required."), + EMPTY_OR_NULL_COLUMN_GROUP_IN_COLUMN_VALUES("Invalid %s1 request. Column group can not be null or empty in column values at index %s2."), + TOKENIZE_REQUEST_REJECTED("Tokenize request resulted in failure."), + DELETE_REQUEST_REJECTED("Delete request resulted in failure."), + + // invoke connection interface + INVOKE_CONNECTION_INVALID_CONNECTION_URL("Invalid %s1 request. Connection URL is not a valid URL."), + EMPTY_REQUEST_HEADERS("Invalid %s1 request. Request headers can not be empty."), + INVALID_REQUEST_HEADERS("Invalid %s1 request. Request header can not be null or empty in request headers."), + EMPTY_PATH_PARAMS("Invalid %s1 request. Path params can not be empty."), + INVALID_PATH_PARAM("Invalid %s1 request. Path parameter can not be null or empty in path params."), + EMPTY_QUERY_PARAMS("Invalid %s1 request. Query params can not be empty."), + INVALID_QUERY_PARAM("Invalid %s1 request. Query parameter can not be null or empty in query params."), + EMPTY_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), + INVALID_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), + INVOKE_CONNECTION_REQUEST_REJECTED("Invoke connection 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."), + DEIDENTIFY_TEXT_REQUEST_REJECTED("DeIdentify text request resulted in failure."), + INVALID_TEXT_IN_REIDENTIFY("Invalid %s1 request. The text field is required and must be a non-empty string. Specify a valid text."), + REIDENTIFY_TEXT_REQUEST_REJECTED("ReIdentify text request resulted in failure."), + DEIDENTIFY_FILE_REQUEST_REJECTED("DeIdentify file request resulted in failure."), + GET_DETECT_RUN_REQUEST_REJECTED("Get detect run request resulted in failure."), + INVALID_NULL_FILE_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file field is required and must not be null. Specify a valid file."), + FILE_NOT_FOUND_TO_DEIDENTIFY("Invalid %s1 request. The file field is required and must not be empty. Specify a valid file."), + FILE_NOT_READABLE_TO_DEIDENTIFY("Invalid %s1 request. The file is not readable. Please check the file permissions or path."), + INVALID_PIXEL_DENSITY_TO_DEIDENTIFY_FILE("Invalid %s1 request. Pixel density must be a positive integer greater than 0. Specify a valid pixel density."), + INVALID_MAX_RESOLUTION("Invalid %s1 request. Max resolution must be a positive integer greater than 0. Specify a valid max resolution."), + INVALID_BLEEP_TO_DEIDENTIFY_AUDIO("Invalid %s1 request. Specify a valid bleep as AudioBleep"), + OUTPUT_DIRECTORY_NOT_FOUND("Invalid %s1 request. The output directory does not exist. Please specify a valid output directory."), + INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY("Invalid %s1 request. The output directory is not writable. Please check the permissions or specify a valid output directory."), + EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file and file path fields are both empty. Specify a valid file object or file path."), + ; + + private final String log; + + ErrorLogs(String log) { + this.log = log; + } + + public final String getLog() { + return log; + } +} diff --git a/v2/src/main/java/com/skyflow/logs/InfoLogs.java b/v2/src/main/java/com/skyflow/logs/InfoLogs.java new file mode 100644 index 00000000..efd81a49 --- /dev/null +++ b/v2/src/main/java/com/skyflow/logs/InfoLogs.java @@ -0,0 +1,105 @@ +package com.skyflow.logs; + +public enum InfoLogs { + // Client initialization + CLIENT_INITIALIZED("Initialized skyflow client."), + VALIDATING_VAULT_CONFIG("Validating vault config."), + VALIDATING_CONNECTION_CONFIG("Validating connection config."), + UNABLE_TO_GENERATE_SDK_METRIC("Unable to generate %s1 metric."), + VAULT_CONTROLLER_INITIALIZED("Initialized vault controller with vault ID %s1."), + DETECT_CONTROLLER_INITIALIZED("Initialized detect controller with vault ID %s1."), + CONNECTION_CONTROLLER_INITIALIZED("Initialized connection controller with connection ID %s1."), + LOGGER_SETUP_DONE("Set up logger."), + CURRENT_LOG_LEVEL("Current log level is %s1."), + + // Bearer token generation + EMPTY_BEARER_TOKEN("Bearer token is empty."), + BEARER_TOKEN_EXPIRED("Bearer token is expired."), + GET_BEARER_TOKEN_TRIGGERED("getBearerToken method triggered."), + GET_BEARER_TOKEN_SUCCESS("Bearer token generated."), + GET_SIGNED_DATA_TOKENS_TRIGGERED("getSignedDataTokens method triggered."), + GET_SIGNED_DATA_TOKEN_SUCCESS("Signed data tokens generated."), + REUSE_BEARER_TOKEN("Reusing bearer token."), + REUSE_API_KEY("Reusing api key."), + GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED("generateBearerTokenFromCredentials method triggered."), + GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED("generateBearerTokenFromCredentialString method triggered."), + GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED("generateSignedTokensFromCredentialsFile method triggered."), + GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_STRING_TRIGGERED("generateSignedTokensFromCredentialsString method triggered."), + + // Insert interface + INSERT_TRIGGERED("Insert method triggered."), + VALIDATE_INSERT_REQUEST("Validating insert request."), + INSERT_REQUEST_RESOLVED("Insert request resolved."), + INSERT_SUCCESS("Data inserted."), + + // Detokenize interface + DETOKENIZE_TRIGGERED("Detokenize method triggered."), + VALIDATE_DETOKENIZE_REQUEST("Validating detokenize request."), + DETOKENIZE_REQUEST_RESOLVED("Detokenize request resolved."), + DETOKENIZE_PARTIAL_SUCCESS("Data detokenized partially."), + DETOKENIZE_SUCCESS("Data detokenized."), + + // Get interface + GET_TRIGGERED("Get method triggered."), + VALIDATE_GET_REQUEST("Validating get request."), + GET_REQUEST_RESOLVED("Get request resolved."), + GET_SUCCESS("Data revealed."), + + // Update interface + UPDATE_TRIGGERED("Update method triggered."), + VALIDATE_UPDATE_REQUEST("Validating update request."), + UPDATE_REQUEST_RESOLVED("Update request resolved."), + UPDATE_SUCCESS("Data updated."), + + // Delete interface + DELETE_TRIGGERED("Delete method triggered."), + VALIDATING_DELETE_REQUEST("Validating delete request."), + DELETE_REQUEST_RESOLVED("Delete request resolved."), + DELETE_SUCCESS("Data deleted."), + + // Query interface + QUERY_TRIGGERED("Query method triggered."), + VALIDATING_QUERY_REQUEST("Validating query request."), + QUERY_REQUEST_RESOLVED("Query request resolved."), + QUERY_SUCCESS("Query executed."), + + // Tokenize interface + TOKENIZE_TRIGGERED("Tokenize method triggered."), + VALIDATING_TOKENIZE_REQUEST("Validating tokenize request."), + TOKENIZE_REQUEST_RESOLVED("Tokenize request resolved."), + TOKENIZE_SUCCESS("Data tokenized."), + + + // Invoke connection interface + INVOKE_CONNECTION_TRIGGERED("Invoke connection method triggered."), + VALIDATING_INVOKE_CONNECTION_REQUEST("Validating invoke connection request."), + INVOKE_CONNECTION_REQUEST_RESOLVED("Invoke connection request resolved."), + + // detect + VALIDATE_DEIDENTIFY_TEXT_REQUEST("Validating deidentify text request."), + DEIDENTIFY_TEXT_SUCCESS("Text data de-identified."), + DEIDENTIFY_TEXT_TRIGGERED("DeIdentify text method triggered."), + DEIDENTIFY_TEXT_REQUEST_RESOLVED("DeIdentify text request resolved."), + VALIDATE_REIDENTIFY_TEXT_REQUEST("Validating reidentify text request."), + REIDENTIFY_TEXT_TRIGGERED("ReIdentify text method triggered."), + REIDENTIFY_TEXT_REQUEST_RESOLVED("ReIdentify text request resolved."), + DEIDENTIFY_FILE_TRIGGERED("DeIdentify file method triggered."), + VALIDATE_DEIDENTIFY_FILE_REQUEST("Validating deidentify file request."), + DEIDENTIFY_FILE_REQUEST_RESOLVED("DeIdentify file request resolved."), + DEIDENTIFY_FILE_SUCCESS("File deidentified successfully."), + GET_DETECT_RUN_TRIGGERED("Get detect run method triggered."), + VALIDATE_GET_DETECT_RUN_REQUEST("Validating get detect run request."), + REIDENTIFY_TEXT_SUCCESS("Text data re-identified."), + ; + + + private final String log; + + InfoLogs(String log) { + this.log = log; + } + + public final String getLog() { + return log; + } +} diff --git a/v2/src/main/java/com/skyflow/utils/Constants.java b/v2/src/main/java/com/skyflow/utils/Constants.java new file mode 100644 index 00000000..f2f1fff8 --- /dev/null +++ b/v2/src/main/java/com/skyflow/utils/Constants.java @@ -0,0 +1,31 @@ +package com.skyflow.utils; + +public final class Constants { + public static final String SECURE_PROTOCOL = "https://"; + public static final String DEV_DOMAIN = ".vault.skyflowapis.dev"; + public static final String STAGE_DOMAIN = ".vault.skyflowapis.tech"; + public static final String SANDBOX_DOMAIN = ".vault.skyflowapis-preview.com"; + public static final String PROD_DOMAIN = ".vault.skyflowapis.com"; + public static final String PKCS8_PRIVATE_HEADER = "-----BEGIN PRIVATE KEY-----"; + public static final String PKCS8_PRIVATE_FOOTER = "-----END PRIVATE KEY-----"; + public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; + public static final String SIGNED_DATA_TOKEN_PREFIX = "signed_token_"; + public static final String ORDER_ASCENDING = "ASCENDING"; + public static final String API_KEY_REGEX = "^sky-[a-zA-Z0-9]{5}-[a-fA-F0-9]{32}$"; + public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; + public static final String SDK_NAME = "Skyflow Java SDK "; + public static final String SDK_VERSION = "v2"; + public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; + public static final String SDK_METRIC_NAME_VERSION = "sdk_name_version"; + public static final String SDK_METRIC_NAME_VERSION_PREFIX = "skyflow-java@"; + public static final String SDK_METRIC_CLIENT_DEVICE_MODEL = "sdk_client_device_model"; + public static final String SDK_METRIC_CLIENT_OS_DETAILS = "sdk_client_os_details"; + public static final String SDK_METRIC_RUNTIME_DETAILS = "sdk_runtime_details"; + public static final String SDK_METRIC_RUNTIME_DETAILS_PREFIX = "Java@"; + public static final String SDK_AUTH_HEADER_KEY = "x-skyflow-authorization"; + 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"; +} diff --git a/v2/src/main/java/com/skyflow/utils/HttpUtility.java b/v2/src/main/java/com/skyflow/utils/HttpUtility.java new file mode 100644 index 00000000..b8e9283b --- /dev/null +++ b/v2/src/main/java/com/skyflow/utils/HttpUtility.java @@ -0,0 +1,165 @@ +package com.skyflow.utils; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.skyflow.errors.SkyflowException; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public final class HttpUtility { + + private static final String LINE_FEED = "\r\n"; + private static String requestID; + + public static String getRequestID() { + return requestID; + } + + public static String sendRequest(String method, URL url, JsonObject params, Map headers) throws IOException, SkyflowException { + + HttpURLConnection connection = null; + BufferedReader in = null; + StringBuffer response = null; + String boundary = String.valueOf(System.currentTimeMillis()); + + try { + connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod(method); + connection.setRequestProperty("content-type", "application/json"); + connection.setRequestProperty("Accept", "*/*"); + + if (headers != null && !headers.isEmpty()) { + for (Map.Entry entry : headers.entrySet()) + connection.setRequestProperty(entry.getKey(), entry.getValue()); + + // append dynamic boundary if content-type is multipart/form-data + if (headers.containsKey("content-type")) { + if (Objects.equals(headers.get("content-type"), "multipart/form-data")) { + connection.setRequestProperty("content-type", "multipart/form-data; boundary=" + boundary); + } + } + } + if (params != null && !params.isEmpty()) { + connection.setDoOutput(true); + try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { + byte[] input = null; + String requestContentType = connection.getRequestProperty("content-type"); + + if (requestContentType.contains("application/x-www-form-urlencoded")) { + input = formatJsonToFormEncodedString(params).getBytes(StandardCharsets.UTF_8); + } else if (requestContentType.contains("multipart/form-data")) { + input = formatJsonToMultiPartFormDataString(params, boundary).getBytes(StandardCharsets.UTF_8); + } else { + input = params.toString().getBytes(StandardCharsets.UTF_8); + } + + wr.write(input, 0, input.length); + wr.flush(); + } + } + + int httpCode = connection.getResponseCode(); + String requestID = connection.getHeaderField("x-request-id"); + HttpUtility.requestID = requestID.split(",")[0]; + Map> responseHeaders = connection.getHeaderFields(); + Reader streamReader; + if (httpCode > 299) { + if (connection.getErrorStream() != null) + streamReader = new InputStreamReader(connection.getErrorStream()); + else { + String description = appendRequestId("replace with description", requestID); + throw new SkyflowException(description); + } + } else { + streamReader = new InputStreamReader(connection.getInputStream()); + } + + response = new StringBuffer(); + in = new BufferedReader(streamReader); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + + if (httpCode > 299) { + throw new SkyflowException(httpCode, new Throwable(), responseHeaders, response.toString()); + } + } finally { + if (in != null) { + in.close(); + } + if (connection != null) { + connection.disconnect(); + } + } + return response.toString(); + + } + + public static String formatJsonToFormEncodedString(JsonObject requestBody) { + StringBuilder formEncodeString = new StringBuilder(); + HashMap jsonMap = convertJsonToMap(requestBody, ""); + + for (Map.Entry currentEntry : jsonMap.entrySet()) + formEncodeString.append(makeFormEncodeKeyValuePair(currentEntry.getKey(), currentEntry.getValue())); + + return formEncodeString.substring(0, formEncodeString.length() - 1); + } + + public static String formatJsonToMultiPartFormDataString(JsonObject requestBody, String boundary) { + StringBuilder formEncodeString = new StringBuilder(); + HashMap jsonMap = convertJsonToMap(requestBody, ""); + + for (Map.Entry currentEntry : jsonMap.entrySet()) + formEncodeString.append(makeFormDataKeyValuePair(currentEntry.getKey(), currentEntry.getValue(), boundary)); + + formEncodeString.append(LINE_FEED); + formEncodeString.append("--").append(boundary).append("--").append(LINE_FEED); + + return formEncodeString.toString(); + } + + private static HashMap convertJsonToMap(JsonObject json, String rootKey) { + HashMap currentMap = new HashMap<>(); + Map jsonMap = json.asMap(); + for (String key : jsonMap.keySet()) { + JsonElement currentValue = jsonMap.get(key); + String currentKey = !rootKey.isEmpty() ? rootKey + '[' + key + ']' : rootKey + key; + if (currentValue.isJsonObject()) { + currentMap.putAll(convertJsonToMap((JsonObject) currentValue, currentKey)); + } else { + currentMap.put(currentKey, currentValue.getAsString()); + } + } + return currentMap; + } + + private static String makeFormDataKeyValuePair(String key, String value, String boundary) { + StringBuilder formDataTextField = new StringBuilder(); + formDataTextField.append("--").append(boundary).append(LINE_FEED); + formDataTextField.append("Content-Disposition: form-data; name=\"").append(key).append("\"").append(LINE_FEED); + formDataTextField.append(LINE_FEED); + formDataTextField.append(value).append(LINE_FEED); + + return formDataTextField.toString(); + } + + public static String appendRequestId(String message, String requestId) { + if (requestId != null && !requestId.isEmpty()) { + message = message + " - requestId: " + requestId; + } + return message; + } + + private static String makeFormEncodeKeyValuePair(String key, String value) { + return key + "=" + value + "&"; + } + +} diff --git a/v2/src/main/java/com/skyflow/utils/Utils.java b/v2/src/main/java/com/skyflow/utils/Utils.java new file mode 100644 index 00000000..baaf3a51 --- /dev/null +++ b/v2/src/main/java/com/skyflow/utils/Utils.java @@ -0,0 +1,202 @@ +package com.skyflow.utils; + +import com.google.gson.JsonObject; +import com.skyflow.common.serviceaccount.util.BearerToken; +import com.skyflow.config.ConnectionConfig; +import com.skyflow.config.Credentials; +import com.skyflow.enums.Env; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.vault.connection.InvokeConnectionRequest; +import org.apache.commons.codec.binary.Base64; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.HashMap; +import java.util.Map; + +public final class Utils { + public static String getVaultURL(String clusterId, Env env) { + StringBuilder sb = new StringBuilder(Constants.SECURE_PROTOCOL); + sb.append(clusterId); + switch (env) { + case DEV: + sb.append(Constants.DEV_DOMAIN); + break; + case STAGE: + sb.append(Constants.STAGE_DOMAIN); + break; + case SANDBOX: + sb.append(Constants.SANDBOX_DOMAIN); + break; + case PROD: + default: + sb.append(Constants.PROD_DOMAIN); + break; + } + return sb.toString(); + } + + public static String generateBearerToken(Credentials credentials) throws com.skyflow.common.errors.SkyflowException { + if (credentials.getPath() != null) { + return BearerToken.builder() + .setCredentials(new File(credentials.getPath())) + .setRoles(credentials.getRoles()) + .setCtx(credentials.getContext()) + .build() + .getBearerToken(); + } else if (credentials.getCredentialsString() != null) { + return BearerToken.builder() + .setCredentials(credentials.getCredentialsString()) + .setRoles(credentials.getRoles()) + .setCtx(credentials.getContext()) + .build() + .getBearerToken(); + } else { + return credentials.getToken(); + } + } + + public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException { + String PKCS8PrivateHeader = Constants.PKCS8_PRIVATE_HEADER; + String PKCS8PrivateFooter = Constants.PKCS8_PRIVATE_FOOTER; + + String privateKeyContent = pemKey; + PrivateKey privateKey = null; + + if (pemKey.contains(PKCS8PrivateHeader)) { + privateKeyContent = privateKeyContent.replace(PKCS8PrivateHeader, ""); + privateKeyContent = privateKeyContent.replace(PKCS8PrivateFooter, ""); + privateKeyContent = privateKeyContent.replace("\n", ""); + privateKeyContent = privateKeyContent.replace("\r\n", ""); + privateKey = parsePkcs8PrivateKey(Base64.decodeBase64(privateKeyContent)); + } else { + LogUtil.printErrorLog(ErrorLogs.JWT_INVALID_FORMAT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.JwtInvalidFormat.getMessage()); + } + return privateKey; + } + + public static String getBaseURL(String url) throws MalformedURLException { + URL parsedUrl = new URL(url); + String protocol = parsedUrl.getProtocol(); + String host = parsedUrl.getHost(); + return String.format("%s://%s", protocol, host); + } + + public static String parameterizedString(String base, String... args) { + for (int index = 0; index < args.length; index++) { + base = base.replace("%s" + (index + 1), args[index]); + } + return base; + } + + public static String constructConnectionURL(ConnectionConfig config, InvokeConnectionRequest invokeConnectionRequest) { + StringBuilder filledURL = new StringBuilder(config.getConnectionUrl()); + + if (invokeConnectionRequest.getPathParams() != null && !invokeConnectionRequest.getPathParams().isEmpty()) { + for (Map.Entry entry : invokeConnectionRequest.getPathParams().entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + filledURL = new StringBuilder(filledURL.toString().replace(String.format("{%s}", key), value)); + } + } + + if (invokeConnectionRequest.getQueryParams() != null && !invokeConnectionRequest.getQueryParams().isEmpty()) { + filledURL.append("?"); + for (Map.Entry entry : invokeConnectionRequest.getQueryParams().entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + filledURL.append(key).append("=").append(value).append("&"); + } + filledURL = new StringBuilder(filledURL.substring(0, filledURL.length() - 1)); + } + + return filledURL.toString(); + } + + public static Map constructConnectionHeadersMap(Map requestHeaders) { + Map headersMap = new HashMap<>(); + for (Map.Entry entry : requestHeaders.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + headersMap.put(key.toLowerCase(), value); + } + return headersMap; + } + + public static JsonObject getMetrics() { + JsonObject details = new JsonObject(); + String sdkVersion = Constants.SDK_VERSION; + String deviceModel; + String osDetails; + String javaVersion; + // Retrieve device model + try { + deviceModel = System.getProperty("os.name"); + if (deviceModel == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + Constants.SDK_METRIC_CLIENT_DEVICE_MODEL + )); + deviceModel = ""; + } + + // Retrieve OS details + try { + osDetails = System.getProperty("os.version"); + if (osDetails == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + Constants.SDK_METRIC_CLIENT_OS_DETAILS + )); + osDetails = ""; + } + + // Retrieve Java version details + try { + javaVersion = System.getProperty("java.version"); + if (javaVersion == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + Constants.SDK_METRIC_RUNTIME_DETAILS + )); + javaVersion = ""; + } + details.addProperty(Constants.SDK_METRIC_NAME_VERSION, Constants.SDK_METRIC_NAME_VERSION_PREFIX + sdkVersion); + details.addProperty(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL, deviceModel); + details.addProperty(Constants.SDK_METRIC_RUNTIME_DETAILS, Constants.SDK_METRIC_RUNTIME_DETAILS_PREFIX + javaVersion); + details.addProperty(Constants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); + return details; + } + + private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws SkyflowException { + KeyFactory keyFactory; + PrivateKey privateKey = null; + try { + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8Bytes); + keyFactory = KeyFactory.getInstance("RSA"); + privateKey = keyFactory.generatePrivate(keySpec); + } catch (NoSuchAlgorithmException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_ALGORITHM.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidAlgorithm.getMessage()); + } catch (InvalidKeySpecException e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_KEY_SPEC.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidKeySpec.getMessage()); + } + return privateKey; + } +} diff --git a/v2/src/main/java/com/skyflow/utils/logger/LogUtil.java b/v2/src/main/java/com/skyflow/utils/logger/LogUtil.java new file mode 100644 index 00000000..78cfa038 --- /dev/null +++ b/v2/src/main/java/com/skyflow/utils/logger/LogUtil.java @@ -0,0 +1,100 @@ +package com.skyflow.utils.logger; + +import com.skyflow.enums.LogLevel; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; + +import java.util.logging.*; + +public final class LogUtil { + private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName()); + private static final String SDK_LOG_PREFIX = "[" + Constants.SDK_PREFIX + "] "; + private static boolean IS_LOGGER_SETUP_DONE = false; + + synchronized public static void setupLogger(LogLevel logLevel) { + IS_LOGGER_SETUP_DONE = true; + LogManager.getLogManager().reset(); + LOGGER.setUseParentHandlers(false); + Formatter formatter = new SimpleFormatter() { + private static final String format = "%s: %s %n"; + + // Override format method + @Override + public synchronized String format(LogRecord logRecord) { + return String.format( + format, + loggerLevelToLogLevelMap(logRecord.getLevel()), + logRecord.getMessage() + ); + } + }; + ConsoleHandler consoleHandler = new ConsoleHandler(); + consoleHandler.setFormatter(formatter); + consoleHandler.setLevel(Level.CONFIG); + + LOGGER.addHandler(consoleHandler); + LOGGER.setLevel(logLevelToLoggerLevelMap(logLevel)); + printInfoLog(InfoLogs.LOGGER_SETUP_DONE.getLog()); + } + + public static void printErrorLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.severe(SDK_LOG_PREFIX + message); + else { + setupLogger(LogLevel.ERROR); + LOGGER.severe(SDK_LOG_PREFIX + message); + } + } + + public static void printDebugLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.config(SDK_LOG_PREFIX + message); + } + + public static void printWarningLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.warning(SDK_LOG_PREFIX + message); + } + + public static void printInfoLog(String message) { + if (IS_LOGGER_SETUP_DONE) + LOGGER.info(SDK_LOG_PREFIX + message); + } + + + private static Level logLevelToLoggerLevelMap(LogLevel logLevel) { + Level loggerLevel; + switch (logLevel) { + case ERROR: + loggerLevel = Level.SEVERE; + break; + case WARN: + loggerLevel = Level.WARNING; + break; + case INFO: + loggerLevel = Level.INFO; + break; + case DEBUG: + loggerLevel = Level.CONFIG; + break; + default: + loggerLevel = Level.OFF; + } + return loggerLevel; + } + + private static LogLevel loggerLevelToLogLevelMap(Level loggerLevel) { + LogLevel logLevel; + if (Level.SEVERE.equals(loggerLevel)) { + logLevel = LogLevel.ERROR; + } else if (Level.WARNING.equals(loggerLevel)) { + logLevel = LogLevel.WARN; + } else if (Level.INFO.equals(loggerLevel)) { + logLevel = LogLevel.INFO; + } else if (Level.CONFIG.equals(loggerLevel)) { + logLevel = LogLevel.DEBUG; + } else + logLevel = LogLevel.OFF; + return logLevel; + } +} diff --git a/v2/src/main/java/com/skyflow/utils/validations/Validations.java b/v2/src/main/java/com/skyflow/utils/validations/Validations.java new file mode 100644 index 00000000..841c03b6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/utils/validations/Validations.java @@ -0,0 +1,892 @@ +package com.skyflow.utils.validations; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.skyflow.config.ConnectionConfig; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.InterfaceName; +import com.skyflow.enums.RedactionType; +import com.skyflow.enums.TokenMode; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.vault.connection.InvokeConnectionRequest; +import com.skyflow.vault.data.*; +import com.skyflow.vault.detect.*; +import com.skyflow.vault.tokens.ColumnValue; +import com.skyflow.vault.tokens.DetokenizeData; +import com.skyflow.vault.tokens.DetokenizeRequest; +import com.skyflow.vault.tokens.TokenizeRequest; + +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Validations { + private Validations() { + } + + public static void validateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + String vaultId = vaultConfig.getVaultId(); + String clusterId = vaultConfig.getClusterId(); + Credentials credentials = vaultConfig.getCredentials(); + if (vaultId == null) { + LogUtil.printErrorLog(ErrorLogs.VAULT_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidVaultId.getMessage()); + } else if (vaultId.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_VAULT_ID.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyVaultId.getMessage()); + } else if (clusterId == null) { + LogUtil.printErrorLog(ErrorLogs.CLUSTER_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidClusterId.getMessage()); + } else if (clusterId.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CLUSTER_ID.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyClusterId.getMessage()); + } else if (credentials != null) { + validateCredentials(credentials); + } + } + + public static void validateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + String connectionId = connectionConfig.getConnectionId(); + String connectionUrl = connectionConfig.getConnectionUrl(); + + if (connectionId == null) { + LogUtil.printErrorLog(ErrorLogs.CONNECTION_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidConnectionId.getMessage()); + } else if (connectionId.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CONNECTION_ID.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyConnectionId.getMessage()); + } else if (connectionUrl == null) { + LogUtil.printErrorLog(ErrorLogs.CONNECTION_URL_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidConnectionUrl.getMessage()); + } else if (connectionUrl.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CONNECTION_URL.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyConnectionUrl.getMessage()); + } else if (isInvalidURL(connectionUrl)) { + LogUtil.printErrorLog(ErrorLogs.INVALID_CONNECTION_URL.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidConnectionUrlFormat.getMessage()); + } + } + + public static void validateInvokeConnectionRequest(InvokeConnectionRequest invokeConnectionRequest) throws SkyflowException { + Map requestHeaders = invokeConnectionRequest.getRequestHeaders(); + Map pathParams = invokeConnectionRequest.getPathParams(); + Map queryParams = invokeConnectionRequest.getQueryParams(); + Object requestBody = invokeConnectionRequest.getRequestBody(); + + if (requestHeaders != null) { + if (requestHeaders.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_REQUEST_HEADERS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestHeaders.getMessage()); + } else { + for (String header : requestHeaders.keySet()) { + String headerValue = requestHeaders.get(header); + if (header == null || header.trim().isEmpty() || headerValue == null || headerValue.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_REQUEST_HEADERS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestHeaders.getMessage()); + } + } + } + } + + if (pathParams != null) { + if (pathParams.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_PATH_PARAMS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyPathParams.getMessage()); + } else { + for (String param : pathParams.keySet()) { + String paramValue = pathParams.get(param); + if (param == null || param.trim().isEmpty() || paramValue == null || paramValue.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_PATH_PARAM.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPathParams.getMessage()); + } + } + } + } + + if (queryParams != null) { + if (queryParams.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_QUERY_PARAMS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyQueryParams.getMessage()); + } else { + for (String param : queryParams.keySet()) { + String paramValue = queryParams.get(param); + if (param == null || param.trim().isEmpty() || paramValue == null || paramValue.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_QUERY_PARAM.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidQueryParams.getMessage()); + } + } + } + } + + if (requestBody != null) { + Gson gson = new Gson(); + JsonObject bodyObject = gson.toJsonTree(requestBody).getAsJsonObject(); + if (bodyObject.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_REQUEST_BODY.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); + } + } + } + + public static void validateCredentials(Credentials credentials) throws SkyflowException { + int nonNullMembers = 0; + String path = credentials.getPath(); + String credentialsString = credentials.getCredentialsString(); + String token = credentials.getToken(); + String apiKey = credentials.getApiKey(); + String context = credentials.getContext(); + ArrayList roles = credentials.getRoles(); + + if (path != null) nonNullMembers++; + if (credentialsString != null) nonNullMembers++; + if (token != null) nonNullMembers++; + if (apiKey != null) nonNullMembers++; + + if (nonNullMembers > 1) { + LogUtil.printErrorLog(ErrorLogs.MULTIPLE_TOKEN_GENERATION_MEANS_PASSED.getLog()); + throw new SkyflowException( + ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MultipleTokenGenerationMeansPassed.getMessage() + ); + } else if (nonNullMembers < 1) { + LogUtil.printErrorLog(ErrorLogs.NO_TOKEN_GENERATION_MEANS_PASSED.getLog()); + throw new SkyflowException( + ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NoTokenGenerationMeansPassed.getMessage() + ); + } else if (path != null && path.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_PATH.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialFilePath.getMessage()); + } else if (credentialsString != null && credentialsString.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_STRING.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialsString.getMessage()); + } else if (token != null && token.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_TOKEN_VALUE.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyToken.getMessage()); + } else if (apiKey != null) { + if (apiKey.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_API_KEY_VALUE.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyApikey.getMessage()); + } else { + Pattern pattern = Pattern.compile(Constants.API_KEY_REGEX); + Matcher matcher = pattern.matcher(apiKey); + if (!matcher.matches()) { + LogUtil.printErrorLog(ErrorLogs.INVALID_API_KEY.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidApikey.getMessage()); + } + } + } else if (roles != null) { + if (roles.isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_ROLES.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoles.getMessage()); + } else { + for (int index = 0; index < roles.size(); index++) { + String role = roles.get(index); + if (role == null || role.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_ROLE_IN_ROLES.getLog(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoleInRoles.getMessage()); + } + } + } + } + if (context != null && context.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_OR_NULL_CONTEXT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyContext.getMessage()); + } + } + + public static void validateDetokenizeRequest(DetokenizeRequest detokenizeRequest) throws SkyflowException { + ArrayList detokenizeData = detokenizeRequest.getDetokenizeData(); + if (detokenizeData == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.DETOKENIZE_DATA_REQUIRED.getLog(), InterfaceName.DETOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidDetokenizeData.getMessage()); + } else if (detokenizeData.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDetokenizeData.getMessage()); + } else { + for (int index = 0; index < detokenizeData.size(); index++) { + String token = detokenizeData.get(index).getToken(); + if (token == null || token.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA.getLog(), + InterfaceName.DETOKENIZE.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenInDetokenizeData.getMessage()); + } + } + } + } + + public static void validateInsertRequest(InsertRequest insertRequest) throws SkyflowException { + String table = insertRequest.getTable(); + ArrayList> values = insertRequest.getValues(); + ArrayList> tokens = insertRequest.getTokens(); + String upsert = insertRequest.getUpsert(); + Boolean homogeneous = insertRequest.getHomogeneous(); + TokenMode tokenMode = insertRequest.getTokenMode(); + + if (table == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.INSERT.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.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); + } else if (values == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.VALUES_IS_REQUIRED.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ValuesKeyError.getMessage()); + } else if (values.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_VALUES.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValues.getMessage()); + } else if (upsert != null) { + if (upsert.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_UPSERT.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyUpsert.getMessage()); + } else if (homogeneous != null && homogeneous) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.HOMOGENOUS_NOT_SUPPORTED_WITH_UPSERT.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException( + ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.HomogenousNotSupportedWithUpsert.getMessage() + ); + } + } + + for (HashMap valuesMap : values) { + for (String key : valuesMap.keySet()) { + if (key == null || key.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_KEY_IN_VALUES.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInValues.getMessage()); + } else { + Object value = valuesMap.get(key); + if (value == null || value.toString().trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_VALUE_IN_VALUES.getLog(), + InterfaceName.INSERT.getName(), key + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInValues.getMessage()); + } + } + } + } + + switch (tokenMode) { + case DISABLE: + if (tokens != null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TokensPassedForTokenModeDisable.getMessage()); + } + break; + case ENABLE: + if (tokens == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), + InterfaceName.INSERT.getName(), TokenMode.ENABLE.toString() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + Utils.parameterizedString(ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE.toString()) + ); + } + validateTokensForInsertRequest(tokens, values, tokenMode); + break; + case ENABLE_STRICT: + if (tokens == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), + InterfaceName.INSERT.getName(), TokenMode.ENABLE_STRICT.toString() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + Utils.parameterizedString(ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE_STRICT.toString()) + ); + } else if (tokens.size() != values.size()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT.getLog(), + InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.InsufficientTokensPassedForTokenModeEnableStrict.getMessage() + ); + } + validateTokensForInsertRequest(tokens, values, tokenMode); + break; + } + } + + public static void validateGetRequest(GetRequest getRequest) throws SkyflowException { + String table = getRequest.getTable(); + ArrayList ids = getRequest.getIds(); + RedactionType redactionType = getRequest.getRedactionType(); + Boolean tokenization = getRequest.getReturnTokens(); + ArrayList fields = getRequest.getFields(); + String offset = getRequest.getOffset(); + String limit = getRequest.getLimit(); + String columnName = getRequest.getColumnName(); + ArrayList columnValues = getRequest.getColumnValues(); + String orderBy = getRequest.getOrderBy(); + + if (table == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.GET.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.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); + } else if (ids != null) { + if (ids.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_IDS.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIds.getMessage()); + } else { + for (int index = 0; index < ids.size(); index++) { + String id = ids.get(index); + if (id == null || id.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_ID_IN_IDS.getLog(), + InterfaceName.GET.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIdInIds.getMessage()); + } + } + } + } + if (fields != null) { + if (fields.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_FIELDS.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyFields.getMessage()); + } else { + for (int index = 0; index < fields.size(); index++) { + String field = fields.get(index); + if (field == null || field.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_FIELD_IN_FIELDS.getLog(), + InterfaceName.GET.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyFieldInFields.getMessage()); + } + } + } + } + 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( + ErrorLogs.TOKENIZATION_NOT_SUPPORTED_WITH_REDACTION.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.RedactionWithTokensNotSupported.getMessage() + ); + } else if (columnName != null || columnValues != null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENIZATION_SUPPORTED_ONLY_WITH_IDS.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.TokensGetColumnNotSupported.getMessage() + ); + } + } + if (offset != null && offset.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OFFSET.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyOffset.getMessage()); + } + if (limit != null && limit.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_LIMIT.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyLimit.getMessage()); + } + if (ids == null && columnName == null && columnValues == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.NEITHER_IDS_NOR_COLUMN_NAME_PASSED.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.UniqueColumnOrIdsKeyError.getMessage()); + } else if (ids != null && (columnName != null || columnValues != null)) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.BOTH_IDS_AND_COLUMN_NAME_PASSED.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.BothIdsAndColumnDetailsSpecified.getMessage()); + } else if (columnName == null && columnValues != null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.COLUMN_NAME_IS_REQUIRED.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnNameKeyError.getMessage()); + } else if (columnName != null && columnValues == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.COLUMN_VALUES_IS_REQUIRED_GET.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnValuesKeyErrorGet.getMessage()); + } else if (columnName != null) { + if (columnName.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_COLUMN_NAME.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnName.getMessage()); + } else if (columnValues.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_COLUMN_VALUES.getLog(), InterfaceName.GET.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnValues.getMessage()); + } else { + for (int index = 0; index < columnValues.size(); index++) { + String columnValue = columnValues.get(index); + if (columnValue == null || columnValue.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES.getLog(), + InterfaceName.GET.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyValueInColumnValues.getMessage()); + } + } + } + } + } + + public static void validateUpdateRequest(UpdateRequest updateRequest) throws SkyflowException { + String table = updateRequest.getTable(); + HashMap data = updateRequest.getData(); + HashMap tokens = updateRequest.getTokens(); + TokenMode tokenMode = updateRequest.getTokenMode(); + + if (table == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.UPDATE.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.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); + } else if (data == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.DATA_IS_REQUIRED.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.DataKeyError.getMessage()); + } else if (data.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_DATA.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyData.getMessage()); + } else if (!data.containsKey("skyflow_id")) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.SKYFLOW_ID_IS_REQUIRED.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.SkyflowIdKeyError.getMessage()); + } else if (!(data.get("skyflow_id") instanceof String)) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_SKYFLOW_ID_TYPE.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidSkyflowIdType.getMessage()); + } else if (data.get("skyflow_id").toString().trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_SKYFLOW_ID.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptySkyflowId.getMessage()); + } else if (tokens != null && tokens.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_TOKENS.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokens.getMessage()); + } + + for (String key : data.keySet()) { + if (key == null || key.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_KEY_IN_VALUES.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInValues.getMessage()); + } else { + Object value = data.get(key); + if (value == null || value.toString().trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_VALUE_IN_VALUES.getLog(), InterfaceName.UPDATE.getName(), key + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyValueInValues.getMessage()); + } + } + } + + switch (tokenMode) { + case DISABLE: + if (tokens != null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE.getLog(), InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.TokensPassedForTokenModeDisable.getMessage()); + } + break; + case ENABLE: + if (tokens == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), + InterfaceName.UPDATE.getName(), TokenMode.ENABLE.toString() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE.toString())); + } + validateTokensMapWithTokenStrict(tokens, data); + break; + case ENABLE_STRICT: + if (tokens == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), + InterfaceName.UPDATE.getName(), TokenMode.ENABLE_STRICT.toString() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE_STRICT.toString())); + } else if (tokens.size() != (data.size() - 1)) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT.getLog(), + InterfaceName.UPDATE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.InsufficientTokensPassedForTokenModeEnableStrict.getMessage()); + } + validateTokensMapWithTokenStrict(tokens, data); + break; + } + } + + public static void validateDeleteRequest(DeleteRequest deleteRequest) throws SkyflowException { + String table = deleteRequest.getTable(); + ArrayList ids = deleteRequest.getIds(); + if (table == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.DELETE.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.DELETE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); + + } else if (ids == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.IDS_IS_REQUIRED.getLog(), InterfaceName.DELETE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.IdsKeyError.getMessage()); + } else if (ids.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_IDS.getLog(), InterfaceName.DELETE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIds.getMessage()); + } else { + for (int index = 0; index < ids.size(); index++) { + String id = ids.get(index); + if (id == null || id.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_ID_IN_IDS.getLog(), + InterfaceName.DELETE.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIdInIds.getMessage()); + } + } + } + } + + public static void validateQueryRequest(QueryRequest queryRequest) throws SkyflowException { + String query = queryRequest.getQuery(); + if (query == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.QUERY_IS_REQUIRED.getLog(), InterfaceName.QUERY.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.QueryKeyError.getMessage()); + } else if (query.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_QUERY.getLog(), InterfaceName.QUERY.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyQuery.getMessage()); + } + } + + public static void validateTokenizeRequest(TokenizeRequest tokenizeRequest) throws SkyflowException { + List columnValues = tokenizeRequest.getColumnValues(); + + if (columnValues == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.COLUMN_VALUES_IS_REQUIRED_TOKENIZE.getLog(), InterfaceName.TOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnValuesKeyErrorTokenize.getMessage()); + } else if (columnValues.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_COLUMN_VALUES.getLog(), InterfaceName.TOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnValues.getMessage()); + } else { + for (int index = 0; index < columnValues.size(); index++) { + ColumnValue value = columnValues.get(index); + if (value.getValue() == null || value.getValue().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES.getLog(), + InterfaceName.TOKENIZE.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInColumnValues.getMessage()); + } else if (value.getColumnGroup() == null || value.getColumnGroup().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_COLUMN_GROUP_IN_COLUMN_VALUES.getLog(), + InterfaceName.TOKENIZE.getName(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.EmptyColumnGroupInColumnValue.getMessage()); + } + } + } + } + + public static void validateDeidentifyTextRequest(DeidentifyTextRequest deidentifyTextRequest) throws SkyflowException { + // Validate required fields + String deidentifyText = deidentifyTextRequest.getText(); + if (deidentifyText == null || deidentifyText.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_TEXT_IN_DEIDENTIFY.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTextInDeIdentify.getMessage()); + } + } + + public static void validateReidentifyTextRequest(ReidentifyTextRequest reidentifyTextRequest) throws SkyflowException { + // Validate required fields + String reidentifyText = reidentifyTextRequest.getText(); + if (reidentifyText == null || reidentifyText.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_TEXT_IN_REIDENTIFY.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTextInReIdentify.getMessage()); + } + } + + private static boolean isInvalidURL(String configURL) { + try { + URL url = new URL(configURL); + if (!url.getProtocol().equals("https")) throw new Exception(); + } catch (Exception e) { + return true; + } + return false; + } + + private static void validateTokensForInsertRequest( + ArrayList> tokens, + ArrayList> values, + TokenMode tokenStrict + ) throws SkyflowException { + if (tokens.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_TOKENS.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokens.getMessage()); + } + + for (int index = 0; index < tokens.size(); index++) { + HashMap tokensMap = tokens.get(index); + HashMap valuesMap = values.get(index); + if (tokensMap.size() != valuesMap.size() && tokenStrict == TokenMode.ENABLE_STRICT) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT.getLog(), + InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.InsufficientTokensPassedForTokenModeEnableStrict.getMessage() + ); + } + validateTokensMapWithTokenStrict(tokensMap, valuesMap, InterfaceName.INSERT.getName()); + } + } + + private static void validateTokensMapWithTokenStrict( + HashMap tokensMap, HashMap valuesMap + ) throws SkyflowException { + validateTokensMapWithTokenStrict(tokensMap, valuesMap, InterfaceName.UPDATE.getName()); + } + + private static void validateTokensMapWithTokenStrict( + HashMap tokensMap, HashMap valuesMap, String interfaceName + ) throws SkyflowException { + for (String key : tokensMap.keySet()) { + if (key == null || key.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_KEY_IN_TOKENS.getLog(), interfaceName + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInTokens.getMessage()); + } else if (!valuesMap.containsKey(key)) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.MISMATCH_OF_FIELDS_AND_TOKENS.getLog(), interfaceName + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MismatchOfFieldsAndTokens.getMessage()); + } else { + Object value = tokensMap.get(key); + if (value == null || value.toString().trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_VALUE_IN_TOKENS.getLog(), + interfaceName, key + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInTokens.getMessage()); + } + } + } + } + + public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) throws SkyflowException { + if (request == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_REQUEST_BODY.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); + } + + File file = request.getFileInput().getFile(); + String filePath = request.getFileInput().getFilePath(); + + if (file == null && filePath == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyFileAndFilePathInDeIdentifyFile.getMessage()); + } + + if (filePath != null && file != null) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.BothFileAndFilePathProvided.getMessage()); + } + + if (filePath != null && filePath.trim().isEmpty()){ + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidFilePath.getMessage()); + } + + if (file != null && (!file.exists() || !file.isFile())) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.FILE_NOT_FOUND_TO_DEIDENTIFY.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FileNotFoundToDeidentify.getMessage()); + } + if (file != null && !file.canRead()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.FILE_NOT_READABLE_TO_DEIDENTIFY.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FileNotReadableToDeidentify.getMessage()); + } + + + // Validate pixelDensity and maxResolution + if (request.getPixelDensity() != null && request.getPixelDensity().doubleValue() <= 0) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_PIXEL_DENSITY_TO_DEIDENTIFY_FILE.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPixelDensityToDeidentifyFile.getMessage()); + } + if (request.getMaxResolution() != null && request.getMaxResolution().doubleValue() <= 0) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_MAX_RESOLUTION.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidMaxResolution.getMessage()); + } + + // Validate AudioBleep + if (request.getBleep() != null) { + if (request.getBleep().getFrequency() == null || request.getBleep().getFrequency() <= 0) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_BLEEP_TO_DEIDENTIFY_AUDIO.getLog(), InterfaceName.DETECT.getName() + )); + 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()); + } + if (request.getBleep().getStopPadding() == null || request.getBleep().getStopPadding() < 0) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); + } + } + + // Validate outputDirectory if provided + if (request.getOutputDirectory() != null) { + File outDir = new File(request.getOutputDirectory()); + if (!outDir.exists() || !outDir.isDirectory()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.OUTPUT_DIRECTORY_NOT_FOUND.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.OutputDirectoryNotFound.getMessage()); + } + if (!outDir.canWrite()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY.getLog(), InterfaceName.DETECT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPermission.getMessage()); + } + } + + // Validate waitTime if provided + if (request.getWaitTime() != null && request.getWaitTime() <= 0) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidWaitTime.getMessage()); + } + if(request.getWaitTime() > 64) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.WaitTimeExceedsLimit.getMessage()); + } + } + + public static void validateGetDetectRunRequest(GetDetectRunRequest request) throws SkyflowException { + if (request == null) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); + } + + String runId = request.getRunId(); + if (runId == null || runId.trim().isEmpty()) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidOrEmptyRunId.getMessage()); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java b/v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java new file mode 100644 index 00000000..b6c26b6d --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java @@ -0,0 +1,11 @@ +package com.skyflow.vault.audit; + +public class ListEventRequest { + // members + + // constructor + public ListEventRequest() { + } + + // getters ans setters +} diff --git a/v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java b/v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java new file mode 100644 index 00000000..2647e617 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java @@ -0,0 +1,10 @@ +package com.skyflow.vault.audit; + +public class ListEventResponse { + // members + + public ListEventResponse() { + } + + // getters ans setters +} diff --git a/v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java b/v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java new file mode 100644 index 00000000..d059245f --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java @@ -0,0 +1,10 @@ +package com.skyflow.vault.bin; + +public class GetBinRequest { + // members + + public GetBinRequest() { + } + + // getters ans setters +} diff --git a/v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java b/v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java new file mode 100644 index 00000000..86210031 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java @@ -0,0 +1,10 @@ +package com.skyflow.vault.bin; + +public class GetBinResponse { + // members + + public GetBinResponse() { + } + + // getters ans setters +} diff --git a/v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java b/v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java new file mode 100644 index 00000000..ea71cd0a --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java @@ -0,0 +1,82 @@ +package com.skyflow.vault.connection; + +import com.skyflow.enums.RequestMethod; + +import java.util.Map; + +public class InvokeConnectionRequest { + + private final InvokeConnectionRequestBuilder builder; + + private InvokeConnectionRequest(InvokeConnectionRequestBuilder builder) { + this.builder = builder; + } + + public static InvokeConnectionRequestBuilder builder() { + return new InvokeConnectionRequestBuilder(); + } + + public RequestMethod getMethod() { + return builder.method; + } + + public Map getPathParams() { + return builder.pathParams; + } + + public Map getQueryParams() { + return builder.queryParams; + } + + public Map getRequestHeaders() { + return builder.requestHeaders; + } + + public Object getRequestBody() { + return builder.requestBody; + } + + public static final class InvokeConnectionRequestBuilder { + private RequestMethod method; + private Map pathParams; + private Map queryParams; + private Map requestHeaders; + private Object requestBody; + + private InvokeConnectionRequestBuilder() { + this.method = RequestMethod.POST; + this.requestBody = new Object(); + } + + public InvokeConnectionRequestBuilder method(RequestMethod method) { + this.method = method == null ? RequestMethod.POST : method; + return this; + } + + public InvokeConnectionRequestBuilder pathParams(Map pathParams) { + this.pathParams = pathParams; + return this; + } + + public InvokeConnectionRequestBuilder queryParams(Map queryParams) { + this.queryParams = queryParams; + return this; + } + + public InvokeConnectionRequestBuilder requestHeaders(Map requestHeaders) { + this.requestHeaders = requestHeaders; + return this; + } + + public InvokeConnectionRequestBuilder requestBody(Object requestBody) { + this.requestBody = requestBody; + return this; + } + + public InvokeConnectionRequest build() { + return new InvokeConnectionRequest(this); + } + + } + +} diff --git a/v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java b/v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java new file mode 100644 index 00000000..a2d44d99 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java @@ -0,0 +1,30 @@ +package com.skyflow.vault.connection; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.HashMap; + +public class InvokeConnectionResponse { + private final Object data; + private final HashMap metadata; + + public InvokeConnectionResponse(Object data, HashMap metadata) { + this.data = data; + this.metadata = metadata; + } + + public Object getData() { + return data; + } + + public HashMap getMetadata() { + return metadata; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + return gson.toJson(this); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/controller/AuditController.java b/v2/src/main/java/com/skyflow/vault/controller/AuditController.java new file mode 100644 index 00000000..2faa04a6 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/controller/AuditController.java @@ -0,0 +1,18 @@ +package com.skyflow.vault.controller; + +import com.skyflow.generated.rest.ApiClient; +import com.skyflow.vault.audit.ListEventRequest; +import com.skyflow.vault.audit.ListEventResponse; + +public class AuditController { + + public AuditController(ApiClient apiClient) { + + } + + // Check for correct return type in python interfaces + public ListEventResponse list(ListEventRequest listEventRequest) { + // return audit events + return null; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java b/v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java new file mode 100644 index 00000000..4eb7a1c8 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java @@ -0,0 +1,16 @@ +package com.skyflow.vault.controller; + +import com.skyflow.generated.rest.ApiClient; +import com.skyflow.vault.bin.GetBinRequest; +import com.skyflow.vault.bin.GetBinResponse; + +public class BinLookupController { + + public BinLookupController(ApiClient apiClient) { + } + + public GetBinResponse get(GetBinRequest getBinRequest) { + // return bin lookup response (card metadata associated with BIN) + return null; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java b/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java new file mode 100644 index 00000000..e75a3b7e --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java @@ -0,0 +1,93 @@ +package com.skyflow.vault.controller; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.skyflow.ConnectionClient; +import com.skyflow.config.ConnectionConfig; +import com.skyflow.config.Credentials; +import com.skyflow.enums.RequestMethod; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.HttpUtility; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.connection.InvokeConnectionRequest; +import com.skyflow.vault.connection.InvokeConnectionResponse; + +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +public final class ConnectionController extends ConnectionClient { + public ConnectionController(ConnectionConfig connectionConfig, Credentials credentials) { + super(connectionConfig, credentials); + } + + public InvokeConnectionResponse invoke(InvokeConnectionRequest invokeConnectionRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.INVOKE_CONNECTION_TRIGGERED.getLog()); + InvokeConnectionResponse connectionResponse; + try { + LogUtil.printInfoLog(InfoLogs.VALIDATING_INVOKE_CONNECTION_REQUEST.getLog()); + Validations.validateInvokeConnectionRequest(invokeConnectionRequest); + setBearerToken(); + String filledURL = Utils.constructConnectionURL(super.getConnectionConfig(), invokeConnectionRequest); + Map headers = new HashMap<>(); + + Map requestHeaders = invokeConnectionRequest.getRequestHeaders(); + if (requestHeaders != null) { + headers = Utils.constructConnectionHeadersMap(invokeConnectionRequest.getRequestHeaders()); + } + if (!headers.containsKey(Constants.SDK_AUTH_HEADER_KEY)) { + headers.put(Constants.SDK_AUTH_HEADER_KEY, token == null ? apiKey : token); + } + headers.put(Constants.SDK_METRICS_HEADER_KEY, Utils.getMetrics().toString()); + + RequestMethod requestMethod = invokeConnectionRequest.getMethod(); + JsonObject requestBody = null; + Object requestBodyObject = invokeConnectionRequest.getRequestBody(); + + if (requestBodyObject != null) { + try { + requestBody = convertObjectToJson(requestBodyObject); + } catch (Exception e) { + LogUtil.printErrorLog(ErrorLogs.INVALID_REQUEST_HEADERS.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); + } + } + + String response = HttpUtility.sendRequest(requestMethod.name(), new URL(filledURL), requestBody, headers); + JsonObject data = JsonParser.parseString(response).getAsJsonObject(); + HashMap metadata = new HashMap<>(); + metadata.put("requestId", HttpUtility.getRequestID()); + connectionResponse = new InvokeConnectionResponse(data, metadata); + LogUtil.printInfoLog(InfoLogs.INVOKE_CONNECTION_REQUEST_RESOLVED.getLog()); + } catch (IOException e) { + LogUtil.printErrorLog(ErrorLogs.INVOKE_CONNECTION_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.getMessage(), e); + } catch (com.skyflow.common.errors.SkyflowException e) { + throw new RuntimeException(e); + } + return connectionResponse; + } + + private JsonObject convertObjectToJson(Object object) { + Gson gson = new Gson(); + JsonElement jsonElement = gson.toJsonTree(object); + + if (jsonElement.isJsonObject()) { + return jsonElement.getAsJsonObject(); + } else { + JsonObject wrapper = new JsonObject(); + wrapper.add("value", jsonElement); + return wrapper; + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/controller/DetectController.java b/v2/src/main/java/com/skyflow/vault/controller/DetectController.java new file mode 100644 index 00000000..7752efd0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/controller/DetectController.java @@ -0,0 +1,375 @@ +package com.skyflow.vault.controller; + +import com.google.gson.*; +import com.skyflow.VaultClient; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.DeidentifyFileStatus; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.core.ApiClientApiException; +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.*; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.detect.*; +import com.skyflow.vault.detect.DeidentifyFileRequest; +import com.skyflow.vault.detect.DeidentifyFileResponse; +import com.skyflow.vault.detect.DeidentifyTextRequest; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.*; + +public final class DetectController extends VaultClient { + private static final Gson gson = new GsonBuilder().serializeNulls().create(); + + public DetectController(VaultConfig vaultConfig, Credentials credentials) { + super(vaultConfig, credentials); + } + + public DeidentifyTextResponse deidentifyText(DeidentifyTextRequest deidentifyTextRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_TRIGGERED.getLog()); + DeidentifyStringResponse deidentifyStringResponse = null; + DeidentifyTextResponse deidentifyTextResponse = null; + try { + // Validate the request + LogUtil.printInfoLog(InfoLogs.VALIDATE_DEIDENTIFY_TEXT_REQUEST.getLog()); + Validations.validateDeidentifyTextRequest(deidentifyTextRequest); + setBearerToken(); + + // Parse the request to DeidentifyStringRequest + String vaultId = super.getVaultConfig().getVaultId(); + DeidentifyStringRequest request = getDeidentifyStringRequest(deidentifyTextRequest, vaultId); + + // Call the API to de-identify the string + deidentifyStringResponse = super.getDetectTextApi().deidentifyString(request); + + // Parse the response to DeIdentifyTextResponse + deidentifyTextResponse = getDeIdentifyTextResponse(deidentifyStringResponse); + LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_REQUEST_RESOLVED.getLog()); + } catch (ApiClientApiException ex) { + String bodyString = gson.toJson(ex.body()); + LogUtil.printErrorLog(ErrorLogs.DEIDENTIFY_TEXT_REQUEST_REJECTED.getLog()); + throw new SkyflowException(ex.statusCode(), ex, ex.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_SUCCESS.getLog()); + return deidentifyTextResponse; + } + + public ReidentifyTextResponse reidentifyText(ReidentifyTextRequest reidentifyTextRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_TRIGGERED.getLog()); + ReidentifyTextResponse reidentifyTextResponse = null; + try { + // Validate the request + LogUtil.printInfoLog(InfoLogs.VALIDATE_REIDENTIFY_TEXT_REQUEST.getLog()); + Validations.validateReidentifyTextRequest(reidentifyTextRequest); + setBearerToken(); + // Parse the request to ReidentifyTextRequest + String vaultId = super.getVaultConfig().getVaultId(); + ReidentifyStringRequest request = getReidentifyStringRequest(reidentifyTextRequest, vaultId); + + // Call the API to re-identify the string + ReidentifyStringResponse reidentifyStringResponse = super.getDetectTextApi().reidentifyString(request); + + // Parse the response to ReidentifyTextResponse + reidentifyTextResponse = new ReidentifyTextResponse(reidentifyStringResponse.getText().orElse(null)); + LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_REQUEST_RESOLVED.getLog()); + } catch (ApiClientApiException ex) { + String bodyString = gson.toJson(ex.body()); + LogUtil.printErrorLog(ErrorLogs.REIDENTIFY_TEXT_REQUEST_REJECTED.getLog()); + throw new SkyflowException(ex.statusCode(), ex, ex.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_SUCCESS.getLog()); + return reidentifyTextResponse; + } + + public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) throws SkyflowException { + DeidentifyFileResponse response; + LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_FILE_TRIGGERED.getLog()); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATE_DEIDENTIFY_FILE_REQUEST.getLog()); + Validations.validateDeidentifyFileRequest(request); + setBearerToken(); + + String vaultId = super.getVaultConfig().getVaultId(); + + File file; + if (request.getFileInput().getFilePath() != null) { + file = new File(request.getFileInput().getFilePath()); + } else { + file = request.getFileInput().getFile(); + } + String fileName = file.getName(); + String fileExtension = getFileExtension(fileName); + String base64Content; + + try { + base64Content = encodeFileToBase64(file); + } catch (IOException ioe) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedToEncodeFile.getMessage()); + } + + + com.skyflow.generated.rest.types.DeidentifyFileResponse apiResponse = processFileByType(fileExtension, base64Content, request, vaultId); + try { + response = pollForResults(apiResponse.getRunId(), request.getWaitTime()); + } catch (Exception ex) { + throw new SkyflowException(ErrorCode.SERVER_ERROR.getCode(), ErrorMessage.PollingForResultsFailed.getMessage()); + } + + if (DeidentifyFileStatus.SUCCESS.value().equalsIgnoreCase(response.getStatus())) { + String base64File = response.getFileBase64(); + if (base64File != null) { + byte[] decodedBytes = Base64.getDecoder().decode(base64File); + String outputDir = request.getOutputDirectory(); + String outputFileName = Constants.PROCESSED_FILE_NAME_PREFIX + fileName; + File outputFile; + if (outputDir != null && !outputDir.isEmpty()) { + outputFile = new File(outputDir, outputFileName); + } else { + outputFile = new File(outputFileName); + } + try { + Files.write(outputFile.toPath(), decodedBytes); + } catch (IOException ioe) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedtoSaveProcessedFile.getMessage()); + } + + } + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.DEIDENTIFY_FILE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + return response; + } + + private String getFileExtension(String fileName) { + return fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); + } + + private String encodeFileToBase64(File file) throws IOException { + byte[] fileContent = Files.readAllBytes(file.toPath()); + return Base64.getEncoder().encodeToString(fileContent); + } + + private DeidentifyFileResponse pollForResults(String runId, Integer maxWaitTime) throws Exception { + int currentWaitTime = 1; + maxWaitTime = maxWaitTime == null ? 64 : maxWaitTime; + + DeidentifyStatusResponse response = null; + + while (true) { + try { + GetRunRequest getRunRequest = GetRunRequest.builder() + .vaultId(super.getVaultConfig().getVaultId()) + .build(); + response = super.getDetectFileAPi() + .getRun(runId, getRunRequest); + + DeidentifyStatusResponseStatus status = response.getStatus(); + + if (DeidentifyFileStatus.IN_PROGRESS.value().equalsIgnoreCase(String.valueOf(status))) { + if (currentWaitTime >= maxWaitTime) { + return new DeidentifyFileResponse(runId, DeidentifyFileStatus.IN_PROGRESS.value()); + } + + int nextWaitTime = currentWaitTime * 2; + int waitTime; + + if (nextWaitTime >= maxWaitTime) { + waitTime = maxWaitTime - currentWaitTime; + currentWaitTime = maxWaitTime; + } else { + waitTime = nextWaitTime; + currentWaitTime = nextWaitTime; + } + + Thread.sleep(waitTime * 1000); + + } else if (status == DeidentifyStatusResponseStatus.SUCCESS || + status == DeidentifyStatusResponseStatus.FAILED) { + return parseDeidentifyFileResponse(response, runId, status.toString()); + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.GET_DETECT_RUN_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + } + + } + + private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(DeidentifyStatusResponse response, + String runId, String status) throws SkyflowException { + DeidentifyFileOutput firstOutput = getFirstOutput(response); + + Object wordCharObj = response.getAdditionalProperties().get("word_character_count"); + Integer wordCount = null; + Integer charCount = null; + + if (wordCharObj instanceof Map) { + Map wordCharMap = (Map) wordCharObj; + Object wc = wordCharMap.get("word_count"); + Object cc = wordCharMap.get("character_count"); + if (wc instanceof Number) { + wordCount = ((Number) wc).intValue(); + } + if (cc instanceof Number) { + charCount = ((Number) cc).intValue(); + } + } + + File processedFileObject = null; + FileInfo fileInfo = null; + Optional processedFileBase64 = firstOutput != null ? firstOutput.getProcessedFile() : Optional.empty(); + Optional processedFileExtension = firstOutput != null ? firstOutput.getProcessedFileExtension() : Optional.empty(); + + if (processedFileBase64.isPresent() && processedFileExtension.isPresent()) { + try { + byte[] decodedBytes = Base64.getDecoder().decode(processedFileBase64.get()); + String suffix = "." + processedFileExtension.get(); + String fileName = Constants.DEIDENTIFIED_FILE_PREFIX + suffix; + processedFileObject = new File(System.getProperty("java.io.tmpdir"), fileName); + Files.write(processedFileObject.toPath(), decodedBytes); + fileInfo = new FileInfo(processedFileObject); + processedFileObject.deleteOnExit(); + } catch (IOException ioe) { + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedToEncodeFile.getMessage()); + } + } + + return new DeidentifyFileResponse( + fileInfo, + firstOutput.getProcessedFile().orElse(null), + firstOutput.getProcessedFileType().get().toString(), + firstOutput.getProcessedFileExtension().get(), + wordCount, + charCount, + response.getSize().map(Double::valueOf).orElse(null), + response.getDuration().map(Double::valueOf).orElse(null), + response.getPages().orElse(null), + response.getSlides().orElse(null), + getEntities(response), + runId, + status, + null + ); + } + + private static synchronized DeidentifyFileOutput getFirstOutput(DeidentifyStatusResponse response) { + List outputs = response.getOutput(); + return outputs != null && !outputs.isEmpty() ? outputs.get(0) : null; + } + + private static synchronized List getEntities(DeidentifyStatusResponse response) { + List entities = new ArrayList<>(); + + List outputs = response.getOutput(); + DeidentifyFileOutput deidentifyFileOutput = outputs != null && !outputs.isEmpty() ? outputs.get(1) : null; + + if (deidentifyFileOutput != null) { + entities.add(new FileEntityInfo( + deidentifyFileOutput.getProcessedFile().orElse(null), + deidentifyFileOutput.getProcessedFileType().orElse(null), + deidentifyFileOutput.getProcessedFileExtension().orElse(null) + )); + } + + return entities; + } + + private com.skyflow.generated.rest.types.DeidentifyFileResponse processFileByType(String fileExtension, String base64Content, DeidentifyFileRequest request, String vaultId) throws SkyflowException { + switch (fileExtension.toLowerCase()) { + case "txt": + com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest textFileRequest = + super.getDeidentifyTextFileRequest(request, vaultId, base64Content); + return super.getDetectFileAPi().deidentifyText(textFileRequest); + + case "mp3": + case "wav": + DeidentifyAudioRequest audioRequest = + super.getDeidentifyAudioRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifyAudio(audioRequest); + + case "pdf": + DeidentifyPdfRequest pdfRequest = + super.getDeidentifyPdfRequest(request, vaultId, base64Content); + + return super.getDetectFileAPi().deidentifyPdf(pdfRequest); + + case "jpg": + case "jpeg": + case "png": + case "bmp": + case "tif": + case "tiff": + DeidentifyImageRequest imageRequest = + super.getDeidentifyImageRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifyImage(imageRequest); + + case "ppt": + case "pptx": + DeidentifyPresentationRequest presentationRequest = + super.getDeidentifyPresentationRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifyPresentation(presentationRequest); + + case "csv": + case "xls": + case "xlsx": + DeidentifySpreadsheetRequest spreadsheetRequest = + super.getDeidentifySpreadsheetRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifySpreadsheet(spreadsheetRequest); + + case "doc": + case "docx": + DeidentifyDocumentRequest documentRequest = + super.getDeidentifyDocumentRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifyDocument(documentRequest); + + case "json": + case "xml": + DeidentifyStructuredTextRequest structuredTextRequest = + super.getDeidentifyStructuredTextRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifyStructuredText(structuredTextRequest); + + default: + com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest genericFileRequest = + super.getDeidentifyGenericFileRequest(request, vaultId, base64Content, fileExtension); + return super.getDetectFileAPi().deidentifyFile(genericFileRequest); + } + } + + public DeidentifyFileResponse getDetectRun(GetDetectRunRequest request) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GET_DETECT_RUN_TRIGGERED.getLog()); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATE_GET_DETECT_RUN_REQUEST.getLog()); + Validations.validateGetDetectRunRequest(request); + setBearerToken(); + String runId = request.getRunId(); + String vaultId = super.getVaultConfig().getVaultId(); + + GetRunRequest getRunRequest = + GetRunRequest.builder() + .vaultId(vaultId) + .build(); + + com.skyflow.generated.rest.types.DeidentifyStatusResponse apiResponse = + super.getDetectFileAPi().getRun(runId, getRunRequest); + + return parseDeidentifyFileResponse(apiResponse, runId, apiResponse.getStatus().toString()); + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.GET_DETECT_RUN_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/controller/VaultController.java b/v2/src/main/java/com/skyflow/vault/controller/VaultController.java new file mode 100644 index 00000000..84e528b0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -0,0 +1,362 @@ +package com.skyflow.vault.controller; + +import com.google.gson.*; +import com.skyflow.VaultClient; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.RedactionType; +import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; +import com.skyflow.generated.rest.resources.records.requests.*; +import com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestOrderBy; +import com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestRedaction; +import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; +import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; +import com.skyflow.generated.rest.types.*; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.data.*; +import com.skyflow.vault.tokens.*; +import java.util.*; + +public final class VaultController extends VaultClient { + private static final Gson gson = new GsonBuilder().serializeNulls().create(); + + public VaultController(VaultConfig vaultConfig, Credentials credentials) { + super(vaultConfig, credentials); + } + + private static synchronized HashMap getFormattedBatchInsertRecord(Object record, int requestIndex) { + HashMap insertRecord = new HashMap<>(); + String jsonString = gson.toJson(record); + JsonObject bodyObject = JsonParser.parseString(jsonString).getAsJsonObject().get("Body").getAsJsonObject(); + JsonArray records = bodyObject.getAsJsonArray("records"); + JsonPrimitive error = bodyObject.getAsJsonPrimitive("error"); + + if (records != null) { + for (JsonElement recordElement : records) { + JsonObject recordObject = recordElement.getAsJsonObject(); + insertRecord.put("skyflowId", recordObject.get("skyflow_id").getAsString()); + JsonElement tokensElement = recordObject.get("tokens"); + if (tokensElement != null) { + insertRecord.putAll(tokensElement.getAsJsonObject().asMap()); + } + } + } + + if (error != null) { + insertRecord.put("error", error.getAsString()); + } + insertRecord.put("requestIndex", requestIndex); + return insertRecord; + } + + private static synchronized HashMap getFormattedBulkInsertRecord(V1RecordMetaProperties record) { + HashMap insertRecord = new HashMap<>(); + if (record.getSkyflowId().isPresent()) { + insertRecord.put("skyflowId", record.getSkyflowId().get()); + } + + if (record.getTokens().isPresent()) { + Map tokensMap = record.getTokens().get(); + insertRecord.putAll(tokensMap); + } + return insertRecord; + } + + private static synchronized HashMap getFormattedGetRecord(V1FieldRecords record) { + HashMap getRecord = new HashMap<>(); + + Optional> fieldsOpt = record.getFields(); + Optional> tokensOpt = record.getTokens(); + + if (fieldsOpt.isPresent()) { + getRecord.putAll(fieldsOpt.get()); + } else if (tokensOpt.isPresent()) { + getRecord.putAll(tokensOpt.get()); + } + return getRecord; + } + + private static synchronized HashMap getFormattedUpdateRecord(V1UpdateRecordResponse record) { + HashMap updateTokens = new HashMap<>(); + + record.getSkyflowId().ifPresent(skyflowId -> updateTokens.put("skyflowId", skyflowId)); + + record.getTokens().ifPresent(tokensMap -> updateTokens.putAll(tokensMap)); + + return updateTokens; + } + + 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()); + } + return queryRecord; + } + + public InsertResponse insert(InsertRequest insertRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); + V1InsertRecordResponse bulkInsertResult = null; + ApiClientHttpResponse batchInsertResult = null; + ArrayList> insertedFields = new ArrayList<>(); + ArrayList> errorFields = new ArrayList<>(); + Boolean continueOnError = insertRequest.getContinueOnError(); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); + Validations.validateInsertRequest(insertRequest); + setBearerToken(); + if (continueOnError) { + RecordServiceBatchOperationBody insertBody = super.getBatchInsertRequestBody(insertRequest); + batchInsertResult = super.getRecordsApi().withRawResponse().recordServiceBatchOperation(super.getVaultConfig().getVaultId(), insertBody); + LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); + Optional>> records = batchInsertResult.body().getResponses(); + + if (records.isPresent()) { + List> recordList = records.get(); + + for (int index = 0; index < recordList.size(); index++) { + Map record = recordList.get(index); + HashMap insertRecord = getFormattedBatchInsertRecord(record, index); + + if (insertRecord.containsKey("skyflowId")) { + insertedFields.add(insertRecord); + } else { + insertRecord.put("requestId", batchInsertResult.headers().get("x-request-id").get(0)); + errorFields.add(insertRecord); + } + } + } + } else { + RecordServiceInsertRecordBody insertBody = super.getBulkInsertRequestBody(insertRequest); + bulkInsertResult = super.getRecordsApi().recordServiceInsertRecord( + super.getVaultConfig().getVaultId(), insertRequest.getTable(), insertBody); + LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); + Optional> records = bulkInsertResult.getRecords(); + if (records.isPresent()) { + for (V1RecordMetaProperties record : records.get()) { + HashMap insertRecord = getFormattedBulkInsertRecord(record); + insertedFields.add(insertRecord); + } + } + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.INSERT_SUCCESS.getLog()); + if (insertedFields.isEmpty()) { + return new InsertResponse(null, errorFields.isEmpty() ? null : errorFields); + } + if (errorFields.isEmpty()) { + return new InsertResponse(insertedFields.isEmpty() ? null : insertedFields, null); + } + return new InsertResponse(insertedFields, errorFields); + } + + public DetokenizeResponse detokenize(DetokenizeRequest detokenizeRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_TRIGGERED.getLog()); + ApiClientHttpResponse result = null; + ArrayList detokenizedFields = new ArrayList<>(); + ArrayList errorRecords = new ArrayList<>(); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATE_DETOKENIZE_REQUEST.getLog()); + Validations.validateDetokenizeRequest(detokenizeRequest); + setBearerToken(); + V1DetokenizePayload payload = super.getDetokenizePayload(detokenizeRequest); + result = super.getTokensApi().withRawResponse().recordServiceDetokenize(super.getVaultConfig().getVaultId(), payload); + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_REQUEST_RESOLVED.getLog()); + Map> responseHeaders = result.headers(); + String requestId = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY).get(0); + Optional> records = result.body().getRecords(); + + if (records.isPresent()) { + List recordList = records.get(); + + for (V1DetokenizeRecordResponse record : recordList) { + if (record.getError().isPresent()) { + DetokenizeRecordResponse recordResponse = new DetokenizeRecordResponse(record, requestId); + errorRecords.add(recordResponse); + } else { + DetokenizeRecordResponse recordResponse = new DetokenizeRecordResponse(record); + detokenizedFields.add(recordResponse); + } + } + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + + if (!errorRecords.isEmpty()) { + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_PARTIAL_SUCCESS.getLog()); + } else { + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_SUCCESS.getLog()); + } + if (detokenizedFields.isEmpty()) { + return new DetokenizeResponse(null, errorRecords.isEmpty() ? null : errorRecords); + } + if (errorRecords.isEmpty()) { + return new DetokenizeResponse(detokenizedFields, null); + } + return new DetokenizeResponse(detokenizedFields, errorRecords); + } + + public GetResponse get(GetRequest getRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.GET_TRIGGERED.getLog()); + V1BulkGetRecordResponse result = null; + ArrayList> data = new ArrayList<>(); + ArrayList> errors = new ArrayList<>(); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATE_GET_REQUEST.getLog()); + Validations.validateGetRequest(getRequest); + setBearerToken(); + RedactionType redactionType = getRequest.getRedactionType(); + RecordServiceBulkGetRecordRequest recordServiceBulkGetRecordRequest = RecordServiceBulkGetRecordRequest.builder() + .skyflowIds(getRequest.getIds()) + .redaction(redactionType != null ? RecordServiceBulkGetRecordRequestRedaction.valueOf(redactionType.toString()) : null) + .tokenization(getRequest.getReturnTokens()) + .offset(getRequest.getOffset()) + .limit(getRequest.getLimit()) + .downloadUrl(getRequest.getDownloadURL()) + .columnName(getRequest.getColumnName()) + .columnValues(getRequest.getColumnValues()) + .orderBy(RecordServiceBulkGetRecordRequestOrderBy.valueOf(getRequest.getOrderBy())) + .build(); + + + result = super.getRecordsApi().recordServiceBulkGetRecord( + super.getVaultConfig().getVaultId(), + getRequest.getTable(), + recordServiceBulkGetRecordRequest + ); + LogUtil.printInfoLog(InfoLogs.GET_REQUEST_RESOLVED.getLog()); + List records = result.getRecords().get(); + if (records != null) { + for (V1FieldRecords record : records) { + data.add(getFormattedGetRecord(record)); + } + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.GET_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.GET_SUCCESS.getLog()); + return new GetResponse(data, null); + } + + public UpdateResponse update(UpdateRequest updateRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.UPDATE_TRIGGERED.getLog()); + V1UpdateRecordResponse result; + String skyflowId; + HashMap tokensMap; + try { + LogUtil.printInfoLog(InfoLogs.VALIDATE_UPDATE_REQUEST.getLog()); + Validations.validateUpdateRequest(updateRequest); + setBearerToken(); + RecordServiceUpdateRecordBody updateBody = super.getUpdateRequestBody(updateRequest); + result = super.getRecordsApi().recordServiceUpdateRecord( + super.getVaultConfig().getVaultId(), + updateRequest.getTable(), + updateRequest.getData().remove("skyflow_id").toString(), + updateBody + ); + LogUtil.printInfoLog(InfoLogs.UPDATE_REQUEST_RESOLVED.getLog()); + skyflowId = String.valueOf(result.getSkyflowId()); + tokensMap = getFormattedUpdateRecord(result); + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.UPDATE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.UPDATE_SUCCESS.getLog()); + return new UpdateResponse(skyflowId, tokensMap); + } + + public DeleteResponse delete(DeleteRequest deleteRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.DELETE_TRIGGERED.getLog()); + V1BulkDeleteRecordResponse result; + try { + LogUtil.printInfoLog(InfoLogs.VALIDATING_DELETE_REQUEST.getLog()); + Validations.validateDeleteRequest(deleteRequest); + setBearerToken(); + RecordServiceBulkDeleteRecordBody deleteBody = RecordServiceBulkDeleteRecordBody.builder().skyflowIds(deleteRequest.getIds()) + .build(); + + result = super.getRecordsApi().recordServiceBulkDeleteRecord( + super.getVaultConfig().getVaultId(), deleteRequest.getTable(), deleteBody); + LogUtil.printInfoLog(InfoLogs.DELETE_REQUEST_RESOLVED.getLog()); + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.DELETE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.DELETE_SUCCESS.getLog()); + return new DeleteResponse(result.getRecordIdResponse().get()); + } + + public QueryResponse query(QueryRequest queryRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.QUERY_TRIGGERED.getLog()); + V1GetQueryResponse result; + ArrayList> fields = new ArrayList<>(); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATING_QUERY_REQUEST.getLog()); + Validations.validateQueryRequest(queryRequest); + setBearerToken(); + result = super.getQueryApi().queryServiceExecuteQuery( + super.getVaultConfig().getVaultId(), QueryServiceExecuteQueryBody.builder().query(queryRequest.getQuery()).build()); + LogUtil.printInfoLog(InfoLogs.QUERY_REQUEST_RESOLVED.getLog()); + if (result.getRecords().isPresent()) { + List records = result.getRecords().get(); // Extract the List from Optional + for (V1FieldRecords record : records) { + fields.add(getFormattedQueryRecord(record)); + } + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.QUERY_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.QUERY_SUCCESS.getLog()); + return new QueryResponse(fields); + } + + public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.TOKENIZE_TRIGGERED.getLog()); + V1TokenizeResponse result = null; + List list = new ArrayList<>(); + try { + LogUtil.printInfoLog(InfoLogs.VALIDATING_TOKENIZE_REQUEST.getLog()); + Validations.validateTokenizeRequest(tokenizeRequest); + setBearerToken(); + V1TokenizePayload payload = super.getTokenizePayload(tokenizeRequest); + result = super.getTokensApi().recordServiceTokenize(super.getVaultConfig().getVaultId(), payload); + LogUtil.printInfoLog(InfoLogs.TOKENIZE_REQUEST_RESOLVED.getLog()); + if (result != null && result.getRecords().isPresent() && !result.getRecords().get().isEmpty()) { + for (V1TokenizeRecordResponse response : result.getRecords().get()) { + if (response.getToken().isPresent()) { + list.add(response.getToken().get()); + } + } + } + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.TOKENIZE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + LogUtil.printInfoLog(InfoLogs.TOKENIZE_SUCCESS.getLog()); + return new TokenizeResponse(list); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/DeleteRequest.java b/v2/src/main/java/com/skyflow/vault/data/DeleteRequest.java new file mode 100644 index 00000000..d61c996f --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/DeleteRequest.java @@ -0,0 +1,45 @@ +package com.skyflow.vault.data; + +import java.util.ArrayList; + +public class DeleteRequest { + private final DeleteRequestBuilder builder; + + private DeleteRequest(DeleteRequestBuilder builder) { + this.builder = builder; + } + + public static DeleteRequestBuilder builder() { + return new DeleteRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public ArrayList getIds() { + return this.builder.ids; + } + + public static final class DeleteRequestBuilder { + private String table; + private ArrayList ids; + + private DeleteRequestBuilder() { + } + + public DeleteRequestBuilder table(String table) { + this.table = table; + return this; + } + + public DeleteRequestBuilder ids(ArrayList ids) { + this.ids = ids; + return this; + } + + public DeleteRequest build() { + return new DeleteRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/DeleteResponse.java b/v2/src/main/java/com/skyflow/vault/data/DeleteResponse.java new file mode 100644 index 00000000..f34d219a --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/DeleteResponse.java @@ -0,0 +1,27 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.util.List; + +public class DeleteResponse { + private final List deletedIds; + + public DeleteResponse(List deletedIds) { + this.deletedIds = deletedIds; + } + + public List getDeletedIds() { + return deletedIds; + } + + @Override + public String toString() { + Gson gson = new Gson(); + JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); + responseObject.add("errors", null); + return responseObject.toString(); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/GetRequest.java b/v2/src/main/java/com/skyflow/vault/data/GetRequest.java new file mode 100644 index 00000000..04626e35 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/GetRequest.java @@ -0,0 +1,140 @@ +package com.skyflow.vault.data; + +import com.skyflow.enums.RedactionType; +import com.skyflow.utils.Constants; + +import java.util.ArrayList; + +public class GetRequest { + private final GetRequestBuilder builder; + + private GetRequest(GetRequestBuilder builder) { + this.builder = builder; + } + + public static GetRequestBuilder builder() { + return new GetRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public ArrayList getIds() { + return this.builder.ids; + } + + public RedactionType getRedactionType() { + return this.builder.redactionType; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public ArrayList getFields() { + return this.builder.fields; + } + + public String getOffset() { + return this.builder.offset; + } + + public String getLimit() { + return this.builder.limit; + } + + public Boolean getDownloadURL() { + return this.builder.downloadURL; + } + + public String getColumnName() { + return this.builder.columnName; + } + + public ArrayList getColumnValues() { + return this.builder.columnValues; + } + + public String getOrderBy() { + return this.builder.orderBy; + } + + public static final class GetRequestBuilder { + private String table; + private ArrayList ids; + private RedactionType redactionType; + private Boolean returnTokens; + private ArrayList fields; + private String offset; + private String limit; + private Boolean downloadURL; + private String columnName; + private ArrayList columnValues; + private String orderBy; + + private GetRequestBuilder() { + this.downloadURL = true; + this.orderBy = Constants.ORDER_ASCENDING; + } + + public GetRequestBuilder table(String table) { + this.table = table; + return this; + } + + public GetRequestBuilder ids(ArrayList ids) { + this.ids = ids; + return this; + } + + public GetRequestBuilder redactionType(RedactionType redactionType) { + this.redactionType = redactionType; + return this; + } + + public GetRequestBuilder returnTokens(Boolean returnTokens) { + this.returnTokens = returnTokens; + return this; + } + + public GetRequestBuilder fields(ArrayList fields) { + this.fields = fields; + return this; + } + + public GetRequestBuilder offset(String offset) { + this.offset = offset; + return this; + } + + public GetRequestBuilder limit(String limit) { + this.limit = limit; + return this; + } + + public GetRequestBuilder downloadURL(Boolean downloadURL) { + this.downloadURL = downloadURL == null || downloadURL; + return this; + } + + public GetRequestBuilder columnName(String columnName) { + this.columnName = columnName; + return this; + } + + public GetRequestBuilder columnValues(ArrayList columnValues) { + this.columnValues = columnValues; + return this; + } + + public GetRequestBuilder orderBy(String orderBy) { + this.orderBy = orderBy == null ? Constants.ORDER_ASCENDING : orderBy; + return this; + } + + public GetRequest build() { + return new GetRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/GetResponse.java b/v2/src/main/java/com/skyflow/vault/data/GetResponse.java new file mode 100644 index 00000000..41821969 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/GetResponse.java @@ -0,0 +1,30 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.HashMap; + +public class GetResponse { + private final ArrayList> data; + private final ArrayList> errors; + + public GetResponse(ArrayList> data, ArrayList> errors) { + this.data = data; + this.errors = errors; + } + + public ArrayList> getData() { + return data; + } + + public ArrayList> getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java new file mode 100644 index 00000000..54093467 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -0,0 +1,111 @@ +package com.skyflow.vault.data; + +import com.skyflow.enums.TokenMode; + +import java.util.ArrayList; +import java.util.HashMap; + +public class InsertRequest { + private final InsertRequestBuilder builder; + + private InsertRequest(InsertRequestBuilder builder) { + this.builder = builder; + } + + public static InsertRequestBuilder builder() { + return new InsertRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public ArrayList> getValues() { + return this.builder.values; + } + + public ArrayList> getTokens() { + return this.builder.tokens; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public String getUpsert() { + return this.builder.upsert; + } + + public Boolean getHomogeneous() { + return this.builder.homogeneous; + } + + public Boolean getContinueOnError() { + return this.builder.continueOnError; + } + + public TokenMode getTokenMode() { + return this.builder.tokenMode; + } + + public static final class InsertRequestBuilder { + private String table; + private ArrayList> values; + private ArrayList> tokens; + private Boolean returnTokens; + private String upsert; + private Boolean homogeneous; + private Boolean continueOnError; + private TokenMode tokenMode; + + private InsertRequestBuilder() { + this.returnTokens = false; + this.continueOnError = false; + this.tokenMode = TokenMode.DISABLE; + } + + public InsertRequestBuilder table(String table) { + this.table = table; + return this; + } + + public InsertRequestBuilder values(ArrayList> values) { + this.values = values; + return this; + } + + public InsertRequestBuilder tokens(ArrayList> tokens) { + this.tokens = tokens; + return this; + } + + public InsertRequestBuilder returnTokens(Boolean returnTokens) { + this.returnTokens = returnTokens != null && returnTokens; + return this; + } + + public InsertRequestBuilder upsert(String upsert) { + this.upsert = upsert; + return this; + } + + public InsertRequestBuilder homogeneous(Boolean homogeneous) { + this.homogeneous = homogeneous; + return this; + } + + public InsertRequestBuilder continueOnError(Boolean continueOnError) { + this.continueOnError = continueOnError != null && continueOnError; + return this; + } + + public InsertRequestBuilder tokenMode(TokenMode tokenMode) { + this.tokenMode = tokenMode == null ? TokenMode.DISABLE : tokenMode; + return this; + } + + public InsertRequest build() { + return new InsertRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v2/src/main/java/com/skyflow/vault/data/InsertResponse.java new file mode 100644 index 00000000..a4f97967 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -0,0 +1,30 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.HashMap; + +public class InsertResponse { + private final ArrayList> insertedFields; + private final ArrayList> errors; + + public InsertResponse(ArrayList> insertedFields, ArrayList> errors) { + this.insertedFields = insertedFields; + this.errors = errors; + } + + public ArrayList> getInsertedFields() { + return insertedFields; + } + + public ArrayList> getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/QueryRequest.java b/v2/src/main/java/com/skyflow/vault/data/QueryRequest.java new file mode 100644 index 00000000..2aaa200d --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/QueryRequest.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.data; + +public class QueryRequest { + private final QueryRequestBuilder builder; + + private QueryRequest(QueryRequestBuilder builder) { + this.builder = builder; + } + + public static QueryRequestBuilder builder() { + return new QueryRequestBuilder(); + } + + public String getQuery() { + return this.builder.query; + } + + public static final class QueryRequestBuilder { + private String query; + + private QueryRequestBuilder() { + } + + public QueryRequestBuilder query(String query) { + this.query = query; + return this; + } + + public QueryRequest build() { + return new QueryRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/QueryResponse.java b/v2/src/main/java/com/skyflow/vault/data/QueryResponse.java new file mode 100644 index 00000000..7a1bca51 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/QueryResponse.java @@ -0,0 +1,32 @@ +package com.skyflow.vault.data; + +import com.google.gson.*; + +import java.util.ArrayList; +import java.util.HashMap; + +public class QueryResponse { + private final ArrayList> fields; + private ArrayList> tokenizedData; + + public QueryResponse(ArrayList> fields) { + this.fields = fields; + } + + public ArrayList> getFields() { + return fields; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + JsonObject responseObject = gson.toJsonTree(this).getAsJsonObject(); + JsonArray fieldsArray = responseObject.get("fields").getAsJsonArray(); + for (JsonElement fieldElement : fieldsArray) { + fieldElement.getAsJsonObject().add("tokenizedData", new JsonObject()); + } + responseObject.add("errors", null); + responseObject.remove("tokenizedData"); + return responseObject.toString(); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/UpdateRequest.java b/v2/src/main/java/com/skyflow/vault/data/UpdateRequest.java new file mode 100644 index 00000000..94789121 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/UpdateRequest.java @@ -0,0 +1,79 @@ +package com.skyflow.vault.data; + +import com.skyflow.enums.TokenMode; + +import java.util.HashMap; + +public class UpdateRequest { + private final UpdateRequestBuilder builder; + + private UpdateRequest(UpdateRequestBuilder builder) { + this.builder = builder; + } + + public static UpdateRequestBuilder builder() { + return new UpdateRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public HashMap getData() { + return this.builder.data; + } + + public HashMap getTokens() { + return this.builder.tokens; + } + + public TokenMode getTokenMode() { + return this.builder.tokenMode; + } + + public static final class UpdateRequestBuilder { + private String table; + private Boolean returnTokens; + private HashMap data; + private HashMap tokens; + private TokenMode tokenMode; + + private UpdateRequestBuilder() { + this.returnTokens = false; + this.tokenMode = TokenMode.DISABLE; + } + + public UpdateRequestBuilder table(String table) { + this.table = table; + return this; + } + + public UpdateRequestBuilder returnTokens(Boolean returnTokens) { + this.returnTokens = returnTokens != null && returnTokens; + return this; + } + + public UpdateRequestBuilder data(HashMap data) { + this.data = data; + return this; + } + + public UpdateRequestBuilder tokens(HashMap tokens) { + this.tokens = tokens; + return this; + } + + public UpdateRequestBuilder tokenMode(TokenMode tokenStrict) { + this.tokenMode = tokenStrict == null ? TokenMode.DISABLE : tokenStrict; + return this; + } + + public UpdateRequest build() { + return new UpdateRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/data/UpdateResponse.java b/v2/src/main/java/com/skyflow/vault/data/UpdateResponse.java new file mode 100644 index 00000000..b1013cb9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/data/UpdateResponse.java @@ -0,0 +1,39 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.util.HashMap; + +public class UpdateResponse { + private final String skyflowId; + private final HashMap tokens; + + public UpdateResponse(String skyflowId, HashMap tokens) { + this.skyflowId = skyflowId; + this.tokens = tokens; + } + + public String getSkyflowId() { + return skyflowId; + } + + public HashMap getTokens() { + return tokens; + } + + @Override + public String toString() { + Gson gson = new Gson(); + JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); + JsonObject tokensObject = responseObject.remove("tokens").getAsJsonObject(); + for (String key : tokensObject.keySet()) { + responseObject.add(key, tokensObject.get(key)); + } + JsonObject finalResponseObject = new JsonObject(); + finalResponseObject.add("updatedField", responseObject); + finalResponseObject.add("errors", null); + return finalResponseObject.toString(); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/AudioBleep.java b/v2/src/main/java/com/skyflow/vault/detect/AudioBleep.java new file mode 100644 index 00000000..1a75f93b --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/AudioBleep.java @@ -0,0 +1,64 @@ +package com.skyflow.vault.detect; + +public class AudioBleep { + private final AudioBleepBuilder builder; + + private AudioBleep(AudioBleepBuilder builder) { + this.builder = builder; + } + + public static AudioBleepBuilder builder() { + return new AudioBleepBuilder(); + } + + public Double getGain() { + return this.builder.gain; + } + + public Double getFrequency() { + return this.builder.frequency; + } + + public Double getStartPadding() { + return this.builder.startPadding; + } + + public Double getStopPadding() { + return this.builder.stopPadding; + } + + public static final class AudioBleepBuilder { + private Double gain; + private Double frequency; + private Double startPadding; + private Double stopPadding; + + private AudioBleepBuilder() { + // Default constructor + } + + public AudioBleepBuilder gain(Double gain) { + this.gain = gain; + return this; + } + + public AudioBleepBuilder frequency(Double frequency) { + this.frequency = frequency; + return this; + } + + public AudioBleepBuilder startPadding(Double startPadding) { + this.startPadding = startPadding; + return this; + } + + public AudioBleepBuilder stopPadding(Double stopPadding) { + this.stopPadding = stopPadding; + return this; + } + + public AudioBleep build() { + return new AudioBleep(this); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/DateTransformation.java b/v2/src/main/java/com/skyflow/vault/detect/DateTransformation.java new file mode 100644 index 00000000..819927d2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/DateTransformation.java @@ -0,0 +1,30 @@ +package com.skyflow.vault.detect; + + +import com.skyflow.enums.DetectEntities; + +import java.util.List; + +public class DateTransformation { + private final int max; + private final int min; + private final List entities; + + public DateTransformation(int max, int min, List entities) { + this.max = max; + this.min = min; + this.entities = entities; + } + + public int getMax() { + return max; + } + + public int getMin() { + return min; + } + + public List getEntities() { + return entities; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java new file mode 100644 index 00000000..3ebc450e --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java @@ -0,0 +1,192 @@ +package com.skyflow.vault.detect; + +import com.skyflow.enums.DetectEntities; +import com.skyflow.enums.DetectOutputTranscriptions; +import com.skyflow.enums.MaskingMethod; +import java.util.List; + +public class DeidentifyFileRequest { + private final DeidentifyFileRequestBuilder builder; + + private DeidentifyFileRequest(DeidentifyFileRequestBuilder builder) { + this.builder = builder; + } + + public static DeidentifyFileRequestBuilder builder() { + return new DeidentifyFileRequestBuilder(); + } + + public FileInput getFileInput() { + return this.builder.fileInput; + } + + public List getEntities() { + return this.builder.entities; + } + + public List getAllowRegexList() { + return this.builder.allowRegexList; + } + + public List getRestrictRegexList() { + return this.builder.restrictRegexList; + } + + public TokenFormat getTokenFormat() { + return this.builder.tokenFormat; + } + + public Transformations getTransformations() { + return this.builder.transformations; + } + + public Boolean getOutputProcessedImage() { + return this.builder.outputProcessedImage; + } + + public Boolean getOutputOcrText() { + return this.builder.outputOcrText; + } + + public MaskingMethod getMaskingMethod() { + return this.builder.maskingMethod; + } + + public Number getPixelDensity() { + return this.builder.pixelDensity; + } + + public Number getMaxResolution() { + return this.builder.maxResolution; + } + + public Boolean getOutputProcessedAudio() { + return this.builder.outputProcessedAudio; + } + + public DetectOutputTranscriptions getOutputTranscription() { + return this.builder.outputTranscription; + } + + public AudioBleep getBleep() { + return this.builder.bleep; + } + + public String getOutputDirectory() { + return this.builder.outputDirectory; + } + + public Integer getWaitTime() { + return this.builder.waitTime; + } + + public static final class DeidentifyFileRequestBuilder { + private List entities; + private List allowRegexList; + private List restrictRegexList; + private TokenFormat tokenFormat; + private Transformations transformations; + private Boolean outputProcessedImage; + private Boolean outputOcrText; + private MaskingMethod maskingMethod; + private Number pixelDensity; + private Number maxResolution; + private Boolean outputProcessedAudio; + private DetectOutputTranscriptions outputTranscription; + private AudioBleep bleep; + private FileInput fileInput; + private String outputDirectory; + private Integer waitTime; + + private DeidentifyFileRequestBuilder() { + // Set default values + this.outputProcessedImage = false; + this.outputOcrText = false; + this.outputProcessedAudio = false; + } + + public DeidentifyFileRequestBuilder file(FileInput fileInput) { + this.fileInput = fileInput; + return this; + } + + public DeidentifyFileRequestBuilder entities(List entities) { + this.entities = entities; + return this; + } + + public DeidentifyFileRequestBuilder allowRegexList(List allowRegexList) { + this.allowRegexList = allowRegexList; + return this; + } + + public DeidentifyFileRequestBuilder restrictRegexList(List restrictRegexList) { + this.restrictRegexList = restrictRegexList; + return this; + } + + public DeidentifyFileRequestBuilder tokenFormat(TokenFormat tokenFormat) { + this.tokenFormat = tokenFormat; + return this; + } + + public DeidentifyFileRequestBuilder transformations(Transformations transformations) { + this.transformations = transformations; + return this; + } + + public DeidentifyFileRequestBuilder outputProcessedImage(Boolean outputProcessedImage) { + this.outputProcessedImage = outputProcessedImage != null ? outputProcessedImage : false; + return this; + } + + public DeidentifyFileRequestBuilder outputOcrText(Boolean outputOcrText) { + this.outputOcrText = outputOcrText != null ? outputOcrText : false; + return this; + } + + public DeidentifyFileRequestBuilder maskingMethod(MaskingMethod maskingMethod) { + this.maskingMethod = maskingMethod; + return this; + } + + public DeidentifyFileRequestBuilder pixelDensity(Number pixelDensity) { + this.pixelDensity = pixelDensity; + return this; + } + + public DeidentifyFileRequestBuilder maxResolution(Number maxResolution) { + this.maxResolution = maxResolution; + return this; + } + + public DeidentifyFileRequestBuilder outputProcessedAudio(Boolean outputProcessedAudio) { + this.outputProcessedAudio = outputProcessedAudio != null ? outputProcessedAudio : false; + return this; + } + + public DeidentifyFileRequestBuilder outputTranscription(DetectOutputTranscriptions outputTranscription) { + this.outputTranscription = outputTranscription; + return this; + } + + public DeidentifyFileRequestBuilder bleep(AudioBleep bleep) { + this.bleep = bleep; + return this; + } + + public DeidentifyFileRequestBuilder outputDirectory(String outputDirectory) { + this.outputDirectory = outputDirectory; + return this; + } + + public DeidentifyFileRequestBuilder waitTime(Integer waitTime) { + this.waitTime = waitTime; + return this; + } + + public DeidentifyFileRequest build() { + return new DeidentifyFileRequest(this); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java new file mode 100644 index 00000000..5471599c --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java @@ -0,0 +1,111 @@ +package com.skyflow.vault.detect; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.List; + +public class DeidentifyFileResponse { + private final FileInfo file; + private final String fileBase64; + private final String type; + private final String extension; + private final Integer wordCount; + private final Integer charCount; + private final Double sizeInKb; + private final Double durationInSeconds; + private final Integer pageCount; + private final Integer slideCount; + 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) { + this.file = file; + this.fileBase64 = fileBase64; + this.type = type; + this.extension = extension; + this.wordCount = wordCount; + this.charCount = charCount; + this.sizeInKb = sizeInKb; + this.durationInSeconds = durationInSeconds; + this.pageCount = pageCount; + this.slideCount = slideCount; + 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); + } + + public FileInfo getFile() { + return file; + } + + public String getFileBase64(){ + return fileBase64; + } + + public String getType() { + return type; + } + + public String getExtension() { + return extension; + } + + public Integer getWordCount() { + return wordCount; + } + + public Integer getCharCount() { + return charCount; + } + + public Double getSizeInKb() { + return sizeInKb; + } + + public Double getDurationInSeconds() { + return durationInSeconds; + } + + public Integer getPageCount() { + return pageCount; + } + + public Integer getSlideCount() { + return slideCount; + } + + public List getEntities() { + return entities; + } + + public String getRunId() { + return runId; + } + + public String getStatus() { + return status; + } + + public List getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + return gson.toJson(this); + } + +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java new file mode 100644 index 00000000..5f57e3a9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java @@ -0,0 +1,88 @@ +package com.skyflow.vault.detect; + + +import com.skyflow.enums.DetectEntities; + +import java.util.List; + +public class DeidentifyTextRequest { + private final DeidentifyTextRequestBuilder builder; + + private DeidentifyTextRequest(DeidentifyTextRequestBuilder builder) { + this.builder = builder; + } + + public static DeidentifyTextRequestBuilder builder() { + return new DeidentifyTextRequestBuilder(); + } + + public String getText() { + return this.builder.text; + } + + public List getEntities() { + return this.builder.entities; + } + + public List getAllowRegexList() { + return this.builder.allowRegexList; + } + + public List getRestrictRegexList() { + return this.builder.restrictRegexList; + } + + public TokenFormat getTokenFormat() { + return this.builder.tokenFormat; + } + + public Transformations getTransformations() { + return this.builder.transformations; + } + + public static final class DeidentifyTextRequestBuilder { + private String text; + private List entities; + private List allowRegexList; + private List restrictRegexList; + private TokenFormat tokenFormat; + private Transformations transformations; + + private DeidentifyTextRequestBuilder() { + } + + public DeidentifyTextRequestBuilder text(String text) { + this.text = text; + return this; + } + + public DeidentifyTextRequestBuilder entities(List entities) { + this.entities = entities; + return this; + } + + public DeidentifyTextRequestBuilder allowRegexList(List allowRegexList) { + this.allowRegexList = allowRegexList; + return this; + } + + public DeidentifyTextRequestBuilder restrictRegexList(List restrictRegexList) { + this.restrictRegexList = restrictRegexList; + return this; + } + + public DeidentifyTextRequestBuilder tokenFormat(TokenFormat tokenFormat) { + this.tokenFormat = tokenFormat; + return this; + } + + public DeidentifyTextRequestBuilder transformations(Transformations transformations) { + this.transformations = transformations; + return this; + } + + public DeidentifyTextRequest build() { + return new DeidentifyTextRequest(this); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java new file mode 100644 index 00000000..6b6118e0 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java @@ -0,0 +1,44 @@ +package com.skyflow.vault.detect; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.List; + +public class DeidentifyTextResponse { + private final String processedText; + private final List entities; + private final int wordCount; + private final int charCount; + + public DeidentifyTextResponse(String processedText, List entities, int wordCount, int charCount) { + this.processedText = processedText; + this.entities = entities; + this.wordCount = wordCount; + this.charCount = charCount; + } + + public String getProcessedText() { + return processedText; + } + + public List getEntities() { + return entities; + } + + public int getWordCount() { + return wordCount; + } + + public int getCharCount() { + return charCount; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + return gson.toJson(this); + } + +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/EntityInfo.java b/v2/src/main/java/com/skyflow/vault/detect/EntityInfo.java new file mode 100644 index 00000000..becb5c5e --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/EntityInfo.java @@ -0,0 +1,46 @@ +package com.skyflow.vault.detect; + + +import java.util.Map; + +public class EntityInfo { + private final String token; + private final String value; + private final TextIndex textIndex; + private final TextIndex processedIndex; + private final String entity; + private final Map scores; + + public EntityInfo(String token, String value, TextIndex textIndex, TextIndex processedIndex, String entity, Map scores) { + this.token = token; + this.value = value; + this.textIndex = textIndex; + this.processedIndex = processedIndex; + this.entity = entity; + this.scores = scores; + } + + public String getToken() { + return token; + } + + public String getValue() { + return value; + } + + public TextIndex getTextIndex() { + return textIndex; + } + + public TextIndex getProcessedIndex() { + return processedIndex; + } + + public String getEntity() { + return entity; + } + + public Map getScores() { + return scores; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java b/v2/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java new file mode 100644 index 00000000..e177a99a --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java @@ -0,0 +1,19 @@ +package com.skyflow.vault.detect; + +import com.skyflow.generated.rest.types.DeidentifyFileOutputProcessedFileType; + +public class FileEntityInfo { + private final String file; + private final String type; + private final String extension; + + public FileEntityInfo(String file, DeidentifyFileOutputProcessedFileType type, String extension) { + this.file = file; + this.type = String.valueOf(type); + this.extension = extension; + } + + public String getFile() { return file; } + public String getType() { return type; } + public String getExtension() { return extension; } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/FileInfo.java b/v2/src/main/java/com/skyflow/vault/detect/FileInfo.java new file mode 100644 index 00000000..2f13c4f2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/FileInfo.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.detect; + +import java.io.File; + +public class FileInfo { + private String name; + private long size; + private String type; + private long lastModified; + + public FileInfo(File file) { + this.name = file.getName(); + this.size = file.length(); + this.type = ""; + this.lastModified = file.lastModified(); + } + + public String getName() { + return name; + } + + public long getSize() { + return size; + } + + public String getType() { + return type; + } + + public long getLastModified() { + return lastModified; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/FileInput.java b/v2/src/main/java/com/skyflow/vault/detect/FileInput.java new file mode 100644 index 00000000..3ff1a77e --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/FileInput.java @@ -0,0 +1,46 @@ +package com.skyflow.vault.detect; + +import java.io.File; + +public class FileInput { + private final FileInputBuilder builder; + + private FileInput(FileInputBuilder builder) { + this.builder = builder; + } + + public static FileInputBuilder builder() { + return new FileInputBuilder(); + } + + public File getFile() { + return this.builder.file; + } + + public String getFilePath() { + return this.builder.filePath; + } + + public static final class FileInputBuilder { + private File file; + private String filePath; + + private FileInputBuilder() { + // Default constructor + } + + public FileInputBuilder file(File file) { + this.file = file; + return this; + } + + public FileInputBuilder filePath(String filePath) { + this.filePath = filePath; + return this; + } + + public FileInput build() { + return new FileInput(this); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java b/v2/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java new file mode 100644 index 00000000..cebec9f2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.detect; + +public class GetDetectRunRequest { + private final String runId; + + private GetDetectRunRequest(GetDetectRunRequestBuilder builder) { + this.runId = builder.runId; + } + + public static GetDetectRunRequestBuilder builder() { + return new GetDetectRunRequestBuilder(); + } + + public String getRunId() { + return this.runId; + } + + public static final class GetDetectRunRequestBuilder { + private String runId; + + private GetDetectRunRequestBuilder() { + } + + public GetDetectRunRequestBuilder runId(String runId) { + this.runId = runId; + return this; + } + + public GetDetectRunRequest build() { + return new GetDetectRunRequest(this); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java b/v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java new file mode 100644 index 00000000..cc0e216a --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java @@ -0,0 +1,68 @@ +package com.skyflow.vault.detect; + + +import com.skyflow.enums.DetectEntities; + +import java.util.List; + +public class ReidentifyTextRequest { + private final ReidentifyTextRequestBuilder builder; + + private ReidentifyTextRequest(ReidentifyTextRequestBuilder builder) { + this.builder = builder; + } + + public static ReidentifyTextRequestBuilder builder() { + return new ReidentifyTextRequestBuilder(); + } + + public String getText() { + return this.builder.text; + } + + public List getRedactedEntities() { + return this.builder.redactedEntities; + } + + public List getMaskedEntities() { + return this.builder.maskedEntities; + } + + public List getPlainTextEntities() { + return this.builder.plainTextEntities; + } + + public static final class ReidentifyTextRequestBuilder { + private String text; + private List redactedEntities; + private List maskedEntities; + private List plainTextEntities; + + private ReidentifyTextRequestBuilder() { + } + + public ReidentifyTextRequestBuilder text(String text) { + this.text = text; + return this; + } + + public ReidentifyTextRequestBuilder redactedEntities(List redactedEntities) { + this.redactedEntities = redactedEntities; + return this; + } + + public ReidentifyTextRequestBuilder maskedEntities(List maskedEntities) { + this.maskedEntities = maskedEntities; + return this; + } + + public ReidentifyTextRequestBuilder plainTextEntities(List plainTextEntities) { + this.plainTextEntities = plainTextEntities; + return this; + } + + public ReidentifyTextRequest build() { + return new ReidentifyTextRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java b/v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java new file mode 100644 index 00000000..3a517968 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java @@ -0,0 +1,23 @@ +package com.skyflow.vault.detect; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class ReidentifyTextResponse { + private final String processedText; + + public ReidentifyTextResponse(String processedText) { + this.processedText = processedText; + } + + public String getProcessedText() { + return processedText; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + return gson.toJson(this); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/TextIndex.java b/v2/src/main/java/com/skyflow/vault/detect/TextIndex.java new file mode 100644 index 00000000..6fe99c1d --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/TextIndex.java @@ -0,0 +1,29 @@ +package com.skyflow.vault.detect; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class TextIndex { + private final Integer start; + private final Integer end; + + public TextIndex(Integer start, Integer end) { + this.start = start; + this.end = end; + } + + public int getStart() { + return start; + } + + public int getEnd() { + return end; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + return gson.toJson(this); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/detect/TokenFormat.java b/v2/src/main/java/com/skyflow/vault/detect/TokenFormat.java new file mode 100644 index 00000000..8809d0a3 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/TokenFormat.java @@ -0,0 +1,71 @@ +package com.skyflow.vault.detect; + + +import com.skyflow.enums.DetectEntities; +import com.skyflow.enums.TokenType; + +import java.util.List; + + +public class TokenFormat { + private final TokenFormatBuilder builder; + + private TokenFormat(TokenFormatBuilder builder) { + this.builder = builder; + } + + public static TokenFormatBuilder builder() { + return new TokenFormatBuilder(); + } + + public TokenType getDefault() { + return this.builder.defaultType; + } + + public List getVaultToken() { + return this.builder.vaultToken; + } + + public List getEntityUniqueCounter() { + return this.builder.entityUniqueCounter; + } + + public List getEntityOnly() { + return this.builder.entityOnly; + } + + public static final class TokenFormatBuilder { + private TokenType defaultType; + private List vaultToken; + private List entityUniqueCounter; + private List entityOnly; + + private TokenFormatBuilder() { + this.defaultType = TokenType.ENTITY_UNIQUE_COUNTER; + } + + public TokenFormatBuilder defaultType(TokenType defaultType) { + this.defaultType = defaultType != null ? defaultType : TokenType.ENTITY_UNIQUE_COUNTER; + return this; + } + + public TokenFormatBuilder vaultToken(List vaultToken) { + this.vaultToken = vaultToken; + return this; + } + + public TokenFormatBuilder entityUniqueCounter(List entityUniqueCounter) { + this.entityUniqueCounter = entityUniqueCounter; + return this; + } + + public TokenFormatBuilder entityOnly(List entityOnly) { + this.entityOnly = entityOnly; + return this; + } + + public TokenFormat build() { + return new TokenFormat(this); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/detect/Transformations.java b/v2/src/main/java/com/skyflow/vault/detect/Transformations.java new file mode 100644 index 00000000..2e219101 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/detect/Transformations.java @@ -0,0 +1,14 @@ +package com.skyflow.vault.detect; + + +public class Transformations { + private final DateTransformation shiftDates; + + public Transformations(DateTransformation shiftDates) { + this.shiftDates = shiftDates; + } + + public DateTransformation getShiftDates() { + return shiftDates; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/tokens/ColumnValue.java b/v2/src/main/java/com/skyflow/vault/tokens/ColumnValue.java new file mode 100644 index 00000000..3fa08b2e --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/ColumnValue.java @@ -0,0 +1,45 @@ +package com.skyflow.vault.tokens; + +public class ColumnValue { + + private final ColumnValueBuilder builder; + + private ColumnValue(ColumnValueBuilder builder) { + this.builder = builder; + } + + public static ColumnValueBuilder builder() { + return new ColumnValueBuilder(); + } + + public String getValue() { + return this.builder.value; + } + + public String getColumnGroup() { + return this.builder.columnGroup; + } + + public static final class ColumnValueBuilder { + private String value; + private String columnGroup; + + private ColumnValueBuilder() { + } + + public ColumnValueBuilder value(String value) { + this.value = value; + return this; + } + + public ColumnValueBuilder columnGroup(String columnGroup) { + this.columnGroup = columnGroup; + return this; + } + + public ColumnValue build() { + return new ColumnValue(this); + } + } + +} diff --git a/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java new file mode 100644 index 00000000..33bba2b9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java @@ -0,0 +1,26 @@ +package com.skyflow.vault.tokens; + +import com.skyflow.enums.RedactionType; + +public class DetokenizeData { + private final String token; + private final RedactionType redactionType; + + public DetokenizeData(String token) { + this.token = token; + this.redactionType = RedactionType.PLAIN_TEXT; + } + + public DetokenizeData(String token, RedactionType redactionType) { + this.token = token; + this.redactionType = redactionType == null ? RedactionType.PLAIN_TEXT : redactionType; + } + + public String getToken() { + return this.token; + } + + public RedactionType getRedactionType() { + return this.redactionType; + } +} diff --git a/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java new file mode 100644 index 00000000..7d2ae73c --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java @@ -0,0 +1,54 @@ +package com.skyflow.vault.tokens; + + +import com.skyflow.generated.rest.types.V1DetokenizeRecordResponse; + +public class DetokenizeRecordResponse { + private final String token; + private final String value; + private final String type; + private final String error; + private final String requestId; + + public DetokenizeRecordResponse(V1DetokenizeRecordResponse record) { + this(record, null); + } + + public DetokenizeRecordResponse(V1DetokenizeRecordResponse record, String requestId) { + this.token = record.getToken().orElse(null); + + this.value = record.getValue() + .filter(val -> val != null && !val.toString().isEmpty()) + .orElse(null); + + this.type = record.getValueType() + .map(Enum::toString) + .filter(val -> !"NONE".equals(val)) + .orElse(null); + + this.error = record.getError().orElse(null); + + this.requestId = requestId; + } + + + public String getError() { + return error; + } + + public String getToken() { + return token; + } + + public String getValue() { + return value; + } + + public String getType() { + return type; + } + + public String getRequestId() { + return requestId; + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java new file mode 100644 index 00000000..186a18d2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java @@ -0,0 +1,57 @@ +package com.skyflow.vault.tokens; + +import java.util.ArrayList; + +public class DetokenizeRequest { + private final DetokenizeRequestBuilder builder; + + private DetokenizeRequest(DetokenizeRequestBuilder builder) { + this.builder = builder; + } + + public static DetokenizeRequestBuilder builder() { + return new DetokenizeRequestBuilder(); + } + + public ArrayList getDetokenizeData() { + return this.builder.detokenizeData; + } + + public Boolean getContinueOnError() { + return this.builder.continueOnError; + } + + public Boolean getDownloadURL() { + return this.builder.downloadURL; + } + + public static final class DetokenizeRequestBuilder { + private ArrayList detokenizeData; + private Boolean continueOnError; + private Boolean downloadURL; + + private DetokenizeRequestBuilder() { + this.continueOnError = false; + this.downloadURL = false; + } + + public DetokenizeRequestBuilder detokenizeData(ArrayList detokenizeData) { + this.detokenizeData = detokenizeData; + return this; + } + + public DetokenizeRequestBuilder continueOnError(Boolean continueOnError) { + this.continueOnError = continueOnError != null && continueOnError; + return this; + } + + public DetokenizeRequestBuilder downloadURL(Boolean downloadURL) { + this.downloadURL = downloadURL; + return this; + } + + public DetokenizeRequest build() { + return new DetokenizeRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java new file mode 100644 index 00000000..31ff64b2 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java @@ -0,0 +1,29 @@ +package com.skyflow.vault.tokens; + +import com.google.gson.Gson; + +import java.util.ArrayList; + +public class DetokenizeResponse { + private final ArrayList detokenizedFields; + private final ArrayList errors; + + public DetokenizeResponse(ArrayList detokenizedFields, ArrayList errors) { + this.detokenizedFields = detokenizedFields; + this.errors = errors; + } + + public ArrayList getDetokenizedFields() { + return detokenizedFields; + } + + public ArrayList getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/v2/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java b/v2/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java new file mode 100644 index 00000000..8f6da5d9 --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java @@ -0,0 +1,35 @@ +package com.skyflow.vault.tokens; + +import java.util.List; + +public class TokenizeRequest { + private final TokenizeRequestBuilder builder; + + private TokenizeRequest(TokenizeRequestBuilder builder) { + this.builder = builder; + } + + public static TokenizeRequestBuilder builder() { + return new TokenizeRequestBuilder(); + } + + public List getColumnValues() { + return this.builder.columnValues; + } + + public static final class TokenizeRequestBuilder { + private List columnValues; + + private TokenizeRequestBuilder() { + } + + public TokenizeRequestBuilder values(List columnValues) { + this.columnValues = columnValues; + return this; + } + + public TokenizeRequest build() { + return new TokenizeRequest(this); + } + } +} diff --git a/v2/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java b/v2/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java new file mode 100644 index 00000000..d8d8072b --- /dev/null +++ b/v2/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.tokens; + +import com.google.gson.*; + +import java.util.List; + +public class TokenizeResponse { + private final List tokens; + + public TokenizeResponse(List tokens) { + this.tokens = tokens; + } + + public List getTokens() { + return tokens; + } + + @Override + public String toString() { + Gson gson = new Gson(); + JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); + JsonArray tokensArray = responseObject.remove("tokens").getAsJsonArray(); + JsonArray newTokensArray = new JsonArray(); + for (JsonElement token : tokensArray) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("token", token.getAsString()); + newTokensArray.add(jsonObject); + } + responseObject.add("tokens", newTokensArray); + responseObject.add("errors", null); + return responseObject.toString(); + } +} diff --git a/v3/pom.xml b/v3/pom.xml new file mode 100644 index 00000000..47ab8dbd --- /dev/null +++ b/v3/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.skyflow + skyflow-java + 2.0.0-beta.2 + + + v3 + + + 8 + 8 + UTF-8 + + + + + + com.skyflow.common + common + 1.0.0 + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + com.skyflow.common:common + + + + + + + + + + \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vaultLH/ApiClient.java b/v3/src/main/java/com/skyflow/vaultLH/ApiClient.java new file mode 100644 index 00000000..3a5036c8 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/ApiClient.java @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH; + +import com.skyflow.vaultLH.core.ClientOptions; +import com.skyflow.vaultLH.core.Suppliers; +import com.skyflow.vaultLH.resources.recordservice.RecordserviceClient; + +import java.util.function.Supplier; + +public class ApiClient { + protected final ClientOptions clientOptions; + + protected final Supplier recordserviceClient; + + public ApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.recordserviceClient = Suppliers.memoize(() -> new RecordserviceClient(clientOptions)); + } + + public RecordserviceClient recordservice() { + return this.recordserviceClient.get(); + } + + public static ApiClientBuilder builder() { + return new ApiClientBuilder(); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java b/v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java new file mode 100644 index 00000000..143854e7 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH; + +import com.skyflow.vaultLH.core.ClientOptions; +import com.skyflow.vaultLH.core.Environment; +import okhttp3.OkHttpClient; + +public final class ApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private Environment environment; + + public ApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public ApiClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public ApiClientBuilder maxRetries(int maxRetries) { + this.clientOptionsBuilder.maxRetries(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public ApiClientBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public ApiClient build() { + clientOptionsBuilder.environment(this.environment); + return new ApiClient(clientOptionsBuilder.build()); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java b/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java new file mode 100644 index 00000000..3dc250fb --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH; + +import com.skyflow.vaultLH.core.ClientOptions; +import com.skyflow.vaultLH.core.Suppliers; +import com.skyflow.vaultLH.resources.recordservice.AsyncRecordserviceClient; + +import java.util.function.Supplier; + +public class AsyncApiClient { + protected final ClientOptions clientOptions; + + protected final Supplier recordserviceClient; + + public AsyncApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.recordserviceClient = Suppliers.memoize(() -> new AsyncRecordserviceClient(clientOptions)); + } + + public AsyncRecordserviceClient recordservice() { + return this.recordserviceClient.get(); + } + + public static AsyncApiClientBuilder builder() { + return new AsyncApiClientBuilder(); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java b/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java new file mode 100644 index 00000000..2c3117a7 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH; + +import com.skyflow.vaultLH.core.ClientOptions; +import com.skyflow.vaultLH.core.Environment; +import okhttp3.OkHttpClient; + +public final class AsyncApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private Environment environment; + + public AsyncApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public AsyncApiClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public AsyncApiClientBuilder maxRetries(int maxRetries) { + this.clientOptionsBuilder.maxRetries(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public AsyncApiClientBuilder httpClient(OkHttpClient httpClient) { + this.clientOptionsBuilder.httpClient(httpClient); + return this; + } + + public AsyncApiClient build() { + clientOptionsBuilder.environment(this.environment); + return new AsyncApiClient(clientOptionsBuilder.build()); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java new file mode 100644 index 00000000..7a47d49f --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.Response; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class ApiClientApiException extends ApiClientException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + private final Map> headers; + + public ApiClientApiException(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + } + + public ApiClientApiException(String message, int statusCode, Object body, Response rawResponse) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + /** + * @return the headers + */ + public Map> headers() { + return this.headers; + } + + @Override + public String toString() { + return "ApiClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + + "}"; + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java new file mode 100644 index 00000000..4e108d3f --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +/** + * This class serves as the base exception for all errors in the SDK. + */ +public class ApiClientException extends RuntimeException { + public ApiClientException(String message) { + super(message); + } + + public ApiClientException(String message, Exception e) { + super(message, e); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java new file mode 100644 index 00000000..17e505c5 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.Response; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public final class ApiClientHttpResponse { + + private final T body; + + private final Map> headers; + + public ApiClientHttpResponse(T body, Response rawResponse) { + this.body = body; + + Map> headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + this.headers = headers; + } + + public T body() { + return this.body; + } + + public Map> headers() { + return headers; + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java b/v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java new file mode 100644 index 00000000..ea1434c2 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.OkHttpClient; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final int timeout; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + int timeout) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("X-Fern-Language", "JAVA"); + put("X-Fern-SDK-Name", "com.skyflow.fern:api-sdk"); + put("X-Fern-SDK-Version", "0.0.275"); + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.timeout = timeout; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int maxRetries = 2; + + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { + this.timeout = timeout; + return this; + } + + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + public ClientOptions build() { + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor(this.maxRetries)); + } + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java b/v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java new file mode 100644 index 00000000..a8beea13 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; + +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQueries; + +/** + * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. + */ +class DateTimeDeserializer extends JsonDeserializer { + private static final SimpleModule MODULE; + + static { + MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); + } + + /** + * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. + * + * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. + */ + public static SimpleModule getModule() { + return MODULE; + } + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonToken token = parser.currentToken(); + if (token == JsonToken.VALUE_NUMBER_INT) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); + } else { + TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( + parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); + + if (temporal.query(TemporalQueries.offset()) == null) { + return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); + } else { + return OffsetDateTime.from(temporal); + } + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Environment.java b/v3/src/main/java/com/skyflow/vaultLH/core/Environment.java new file mode 100644 index 00000000..2b6492f1 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/Environment.java @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +public final class Environment { + private final String url; + + private Environment(String url) { + this.url = url; + } + + public String getUrl() { + return this.url; + } + + public static Environment custom(String url) { + return new Environment(url); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java b/v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java new file mode 100644 index 00000000..2ff273c3 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.MediaType; +import okhttp3.RequestBody; +import org.jetbrains.annotations.Nullable; + +import java.io.InputStream; +import java.util.Objects; + +/** + * Represents a file stream with associated metadata for file uploads. + */ +public class FileStream { + private final InputStream inputStream; + private final String fileName; + private final MediaType contentType; + + /** + * Constructs a FileStream with the given input stream and optional metadata. + * + * @param inputStream The input stream of the file content. Must not be null. + * @param fileName The name of the file, or null if unknown. + * @param contentType The MIME type of the file content, or null if unknown. + * @throws NullPointerException if inputStream is null + */ + public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { + this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); + this.fileName = fileName; + this.contentType = contentType; + } + + public FileStream(InputStream inputStream) { + this(inputStream, null, null); + } + + public InputStream getInputStream() { + return inputStream; + } + + @Nullable + public String getFileName() { + return fileName; + } + + @Nullable + public MediaType getContentType() { + return contentType; + } + + /** + * Creates a RequestBody suitable for use with OkHttp client. + * + * @return A RequestBody instance representing this file stream. + */ + public RequestBody toRequestBody() { + return new InputStreamRequestBody(contentType, inputStream); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java b/v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java new file mode 100644 index 00000000..5c462dac --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java @@ -0,0 +1,80 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.internal.Util; +import okio.BufferedSink; +import okio.Okio; +import okio.Source; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; + +/** + * A custom implementation of OkHttp's RequestBody that wraps an InputStream. + * This class allows streaming of data from an InputStream directly to an HTTP request body, + * which is useful for file uploads or sending large amounts of data without loading it all into memory. + */ +public class InputStreamRequestBody extends RequestBody { + private final InputStream inputStream; + private final MediaType contentType; + + /** + * Constructs an InputStreamRequestBody with the specified content type and input stream. + * + * @param contentType the MediaType of the content, or null if not known + * @param inputStream the InputStream containing the data to be sent + * @throws NullPointerException if inputStream is null + */ + public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { + this.contentType = contentType; + this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); + } + + /** + * Returns the content type of this request body. + * + * @return the MediaType of the content, or null if not specified + */ + @Nullable + @Override + public MediaType contentType() { + return contentType; + } + + /** + * Returns the content length of this request body, if known. + * This method attempts to determine the length using the InputStream's available() method, + * which may not always accurately reflect the total length of the stream. + * + * @return the content length, or -1 if the length is unknown + * @throws IOException if an I/O error occurs + */ + @Override + public long contentLength() throws IOException { + return inputStream.available() == 0 ? -1 : inputStream.available(); + } + + /** + * Writes the content of the InputStream to the given BufferedSink. + * This method is responsible for transferring the data from the InputStream to the network request. + * + * @param sink the BufferedSink to write the content to + * @throws IOException if an I/O error occurs during writing + */ + @Override + public void writeTo(BufferedSink sink) throws IOException { + Source source = null; + try { + source = Okio.source(inputStream); + sink.writeAll(source); + } finally { + Util.closeQuietly(Objects.requireNonNull(source)); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java b/v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java new file mode 100644 index 00000000..9f30207c --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java b/v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java new file mode 100644 index 00000000..e5e4d5b3 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import java.util.Optional; +import java.util.function.Function; + +public final class Nullable { + + private final Either, Null> value; + + private Nullable() { + this.value = Either.left(Optional.empty()); + } + + private Nullable(T value) { + if (value == null) { + this.value = Either.right(Null.INSTANCE); + } else { + this.value = Either.left(Optional.of(value)); + } + } + + public static Nullable ofNull() { + return new Nullable<>(null); + } + + public static Nullable of(T value) { + return new Nullable<>(value); + } + + public static Nullable empty() { + return new Nullable<>(); + } + + public static Nullable ofOptional(Optional value) { + if (value.isPresent()) { + return of(value.get()); + } else { + return empty(); + } + } + + public boolean isNull() { + return this.value.isRight(); + } + + public boolean isEmpty() { + return this.value.isLeft() && !this.value.getLeft().isPresent(); + } + + public T get() { + if (this.isNull()) { + return null; + } + + return this.value.getLeft().get(); + } + + public Nullable map(Function mapper) { + if (this.isNull()) { + return Nullable.ofNull(); + } + + return Nullable.ofOptional(this.value.getLeft().map(mapper)); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Nullable)) { + return false; + } + + if (((Nullable) other).isNull() && this.isNull()) { + return true; + } + + return this.value.getLeft().equals(((Nullable) other).value.getLeft()); + } + + private static final class Either { + private L left = null; + private R right = null; + + private Either(L left, R right) { + if (left != null && right != null) { + throw new IllegalArgumentException("Left and right argument cannot both be non-null."); + } + + if (left == null && right == null) { + throw new IllegalArgumentException("Left and right argument cannot both be null."); + } + + if (left != null) { + this.left = left; + } + + if (right != null) { + this.right = right; + } + } + + public static Either left(L left) { + return new Either<>(left, null); + } + + public static Either right(R right) { + return new Either<>(null, right); + } + + public boolean isLeft() { + return this.left != null; + } + + public boolean isRight() { + return this.right != null; + } + + public L getLeft() { + if (!this.isLeft()) { + throw new IllegalArgumentException("Cannot get left from right Either."); + } + return this.left; + } + + public R getRight() { + if (!this.isRight()) { + throw new IllegalArgumentException("Cannot get right from left Either."); + } + return this.right; + } + } + + private static final class Null { + private static final Null INSTANCE = new Null(); + + private Null() {} + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java b/v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java new file mode 100644 index 00000000..e1cc5eb3 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import java.util.Optional; + +public final class NullableNonemptyFilter { + @Override + public boolean equals(Object o) { + boolean isOptionalEmpty = isOptionalEmpty(o); + + return isOptionalEmpty; + } + + private boolean isOptionalEmpty(Object o) { + return o instanceof Optional && !((Optional) o).isPresent(); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java b/v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java new file mode 100644 index 00000000..c9b2e7c6 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +import java.io.IOException; + +public final class ObjectMappers { + public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .addModule(new JavaTimeModule()) + .addModule(DateTimeDeserializer.getModule()) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + private ObjectMappers() {} + + public static String stringify(Object o) { + try { + return JSON_MAPPER + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .writerWithDefaultPrettyPrinter() + .writeValueAsString(o); + } catch (IOException e) { + return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java b/v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java new file mode 100644 index 00000000..c813cc0b --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import okhttp3.HttpUrl; +import okhttp3.MultipartBody; + +import java.util.*; + +public class QueryStringMapper { + + private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; + + public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + httpUrl.addQueryParameter(key, valueNode.textValue()); + } else { + httpUrl.addQueryParameter(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); + } else { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); + } + } + } + + public static void addFormDataPart( + MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + multipartBody.addFormDataPart(key, valueNode.textValue()); + } else { + multipartBody.addFormDataPart(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().textValue()); + } else { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().toString()); + } + } + } + + public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator> fields = object.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + + String key = "[" + field.getKey() + "]"; + + if (field.getValue().isObject()) { + List> flatField = + flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); + addAll(flat, flatField, key); + } else if (field.getValue().isArray()) { + List> flatField = + flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); + addAll(flat, flatField, ""); + } else { + flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); + } + } + + return flat; + } + + private static List> flattenArray( + ArrayNode array, String key, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator elements = array.elements(); + + int index = 0; + while (elements.hasNext()) { + JsonNode element = elements.next(); + + String indexKey = key + "[" + index + "]"; + + if (arraysAsRepeats) { + indexKey = key; + } + + if (element.isObject()) { + List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else if (element.isArray()) { + List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else { + flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); + } + + index++; + } + + return flat; + } + + private static void addAll( + List> target, List> source, String prefix) { + for (Map.Entry entry : source) { + Map.Entry entryToAdd = + new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); + target.add(entryToAdd); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java b/v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java new file mode 100644 index 00000000..3dd2c6d9 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +public final class RequestOptions { + private final Optional timeout; + + private final TimeUnit timeoutTimeUnit; + + private final Map headers; + + private final Map> headerSuppliers; + + private RequestOptions( + Optional timeout, + TimeUnit timeoutTimeUnit, + Map headers, + Map> headerSuppliers) { + this.timeout = timeout; + this.timeoutTimeUnit = timeoutTimeUnit; + this.headers = headers; + this.headerSuppliers = headerSuppliers; + } + + public Optional getTimeout() { + return timeout; + } + + public TimeUnit getTimeoutTimeUnit() { + return timeoutTimeUnit; + } + + public Map getHeaders() { + Map headers = new HashMap<>(); + headers.putAll(this.headers); + this.headerSuppliers.forEach((key, supplier) -> { + headers.put(key, supplier.get()); + }); + return headers; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Optional timeout = Optional.empty(); + + private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + public Builder timeout(Integer timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { + this.timeout = Optional.of(timeout); + this.timeoutTimeUnit = timeoutTimeUnit; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + public RequestOptions build() { + return new RequestOptions(timeout, timeoutTimeUnit, headers, headerSuppliers); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java b/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java new file mode 100644 index 00000000..254debd6 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java @@ -0,0 +1,46 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.Response; + +import java.io.FilterInputStream; +import java.io.IOException; + +/** + * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the stream is closed. + * + * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. + * It retrieves the InputStream from the Response and overrides the close method to close + * both the InputStream and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyInputStream extends FilterInputStream { + private final Response response; + + /** + * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp + * Response object. + * + * @param response the OkHttp Response object from which the InputStream is retrieved + * @throws IOException if an I/O error occurs while retrieving the InputStream + */ + public ResponseBodyInputStream(Response response) throws IOException { + super(response.body().byteStream()); + this.response = response; + } + + /** + * Closes the InputStream and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the stream is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the stream is closed + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java b/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java new file mode 100644 index 00000000..f36ac01a --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.Response; + +import java.io.FilterReader; +import java.io.IOException; + +/** + * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the reader is closed. + * + * This class extends FilterReader and takes an OkHttp Response object as a parameter. + * It retrieves the Reader from the Response and overrides the close method to close + * both the Reader and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyReader extends FilterReader { + private final Response response; + + /** + * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. + * + * @param response the OkHttp Response object from which the Reader is retrieved + * @throws IOException if an I/O error occurs while retrieving the Reader + */ + public ResponseBodyReader(Response response) throws IOException { + super(response.body().charStream()); + this.response = response; + } + + /** + * Closes the Reader and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the reader is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the reader is closed + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java b/v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java new file mode 100644 index 00000000..81dc3d05 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import okhttp3.Interceptor; +import okhttp3.Response; + +import java.io.IOException; +import java.time.Duration; +import java.util.Optional; +import java.util.Random; + +public class RetryInterceptor implements Interceptor { + + private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private final ExponentialBackoff backoff; + private final Random random = new Random(); + + public RetryInterceptor(int maxRetries) { + this.backoff = new ExponentialBackoff(maxRetries); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Response response = chain.proceed(chain.request()); + + if (shouldRetry(response.code())) { + return retryChain(response, chain); + } + + return response; + } + + private Response retryChain(Response response, Chain chain) throws IOException { + Optional nextBackoff = this.backoff.nextBackoff(); + while (nextBackoff.isPresent()) { + try { + Thread.sleep(nextBackoff.get().toMillis()); + } catch (InterruptedException e) { + throw new IOException("Interrupted while trying request", e); + } + response.close(); + response = chain.proceed(chain.request()); + if (shouldRetry(response.code())) { + nextBackoff = this.backoff.nextBackoff(); + } else { + return response; + } + } + + return response; + } + + private static boolean shouldRetry(int statusCode) { + return statusCode == 408 || statusCode == 429 || statusCode >= 500; + } + + private final class ExponentialBackoff { + + private final int maxNumRetries; + + private int retryNumber = 0; + + ExponentialBackoff(int maxNumRetries) { + this.maxNumRetries = maxNumRetries; + } + + public Optional nextBackoff() { + retryNumber += 1; + if (retryNumber > maxNumRetries) { + return Optional.empty(); + } + + int upperBound = (int) Math.pow(2, retryNumber); + return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Stream.java b/v3/src/main/java/com/skyflow/vaultLH/core/Stream.java new file mode 100644 index 00000000..3b6225b8 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/Stream.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import java.io.Reader; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Scanner; + +/** + * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing + * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. + *

+ * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a + * {@code Scanner} to block during iteration if the next object is not available. + * + * @param The type of objects in the stream. + */ +public final class Stream implements Iterable { + /** + * The {@link Class} of the objects in the stream. + */ + private final Class valueType; + /** + * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. + */ + private final Scanner scanner; + + /** + * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. + * + * @param valueType The class of the objects in the stream. + * @param reader The reader that provides the streamed data. + * @param delimiter The delimiter used to separate elements in the stream. + */ + public Stream(Class valueType, Reader reader, String delimiter) { + this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.valueType = valueType; + } + + /** + * Returns an iterator over the elements in this stream that blocks during iteration when the next object is + * not yet available. + * + * @return An iterator that can be used to traverse the elements in the stream. + */ + @Override + public Iterator iterator() { + return new Iterator() { + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Removing elements from {@code Stream} is not supported. + * + * @throws UnsupportedOperationException Always, as removal is not supported. + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java b/v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java new file mode 100644 index 00000000..cb921e80 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.core; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public final class Suppliers { + private Suppliers() {} + + public static Supplier memoize(Supplier delegate) { + AtomicReference value = new AtomicReference<>(); + return () -> { + T val = value.get(); + if (val == null) { + val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); + } + return val; + }; + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java new file mode 100644 index 00000000..5066a298 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java @@ -0,0 +1,535 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.vaultLH.core.*; +import com.skyflow.vaultLH.resources.recordservice.requests.*; +import com.skyflow.vaultLH.types.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; + +public class AsyncRawRecordserviceClient { + protected final ClientOptions clientOptions; + + public AsyncRawRecordserviceClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Executes a query on the specified vault. + */ + public CompletableFuture> executequery() { + return executequery(ExecuteQueryRequest.builder().build()); + } + + /** + * Executes a query on the specified vault. + */ + public CompletableFuture> executequery(ExecuteQueryRequest request) { + return executequery(request, null); + } + + /** + * Executes a query on the specified vault. + */ + public CompletableFuture> executequery( + ExecuteQueryRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/query") + .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(), ExecuteQueryResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> delete() { + return delete(DeleteRequest.builder().build()); + } + + public CompletableFuture> delete(DeleteRequest request) { + return delete(request, null); + } + + public CompletableFuture> delete( + DeleteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/delete") + .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(), DeleteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> get() { + return get(GetRequest.builder().build()); + } + + public CompletableFuture> get(GetRequest request) { + return get(request, null); + } + + public CompletableFuture> get( + GetRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/get") + .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(), GetResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> insert() { + return insert(InsertRequest.builder().build()); + } + + public CompletableFuture> insert(InsertRequest request) { + return insert(request, null); + } + + public CompletableFuture> insert( + InsertRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/insert") + .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(), InsertResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> update() { + return update(UpdateRequest.builder().build()); + } + + public CompletableFuture> update(UpdateRequest request) { + return update(request, null); + } + + public CompletableFuture> update( + UpdateRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/update") + .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(), UpdateResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> deletetoken() { + return deletetoken(DeleteTokenRequest.builder().build()); + } + + public CompletableFuture> deletetoken(DeleteTokenRequest request) { + return deletetoken(request, null); + } + + public CompletableFuture> deletetoken( + DeleteTokenRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/tokens/delete") + .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(), DeleteTokenResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> detokenize() { + return detokenize(DetokenizeRequest.builder().build()); + } + + public CompletableFuture> detokenize(DetokenizeRequest request) { + return detokenize(request, null); + } + + public CompletableFuture> detokenize( + DetokenizeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/tokens/detokenize") + .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(), DetokenizeResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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; + } + + public CompletableFuture> tokenize() { + return tokenize(TokenizeRequest.builder().build()); + } + + public CompletableFuture> tokenize(TokenizeRequest request) { + return tokenize(request, null); + } + + public CompletableFuture> tokenize( + TokenizeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/tokens/get") + .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(), TokenizeResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java new file mode 100644 index 00000000..ec2371c1 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java @@ -0,0 +1,136 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice; + +import com.skyflow.vaultLH.core.ClientOptions; +import com.skyflow.vaultLH.core.RequestOptions; +import com.skyflow.vaultLH.resources.recordservice.requests.*; +import com.skyflow.vaultLH.types.*; + +import java.util.concurrent.CompletableFuture; + +public class AsyncRecordserviceClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRecordserviceClient rawClient; + + public AsyncRecordserviceClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRecordserviceClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRecordserviceClient withRawResponse() { + return this.rawClient; + } + + /** + * Executes a query on the specified vault. + */ + public CompletableFuture executequery() { + return this.rawClient.executequery().thenApply(response -> response.body()); + } + + /** + * Executes a query on the specified vault. + */ + public CompletableFuture executequery(ExecuteQueryRequest request) { + return this.rawClient.executequery(request).thenApply(response -> response.body()); + } + + /** + * Executes a query on the specified vault. + */ + public CompletableFuture executequery( + ExecuteQueryRequest request, RequestOptions requestOptions) { + return this.rawClient.executequery(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + public CompletableFuture delete(DeleteRequest request) { + return this.rawClient.delete(request).thenApply(response -> response.body()); + } + + public CompletableFuture delete(DeleteRequest request, RequestOptions requestOptions) { + return this.rawClient.delete(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture get() { + return this.rawClient.get().thenApply(response -> response.body()); + } + + public CompletableFuture get(GetRequest request) { + return this.rawClient.get(request).thenApply(response -> response.body()); + } + + public CompletableFuture get(GetRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture insert() { + return this.rawClient.insert().thenApply(response -> response.body()); + } + + public CompletableFuture insert(InsertRequest request) { + return this.rawClient.insert(request).thenApply(response -> response.body()); + } + + public CompletableFuture insert(InsertRequest request, RequestOptions requestOptions) { + return this.rawClient.insert(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture update() { + return this.rawClient.update().thenApply(response -> response.body()); + } + + public CompletableFuture update(UpdateRequest request) { + return this.rawClient.update(request).thenApply(response -> response.body()); + } + + public CompletableFuture update(UpdateRequest request, RequestOptions requestOptions) { + return this.rawClient.update(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deletetoken() { + return this.rawClient.deletetoken().thenApply(response -> response.body()); + } + + public CompletableFuture deletetoken(DeleteTokenRequest request) { + return this.rawClient.deletetoken(request).thenApply(response -> response.body()); + } + + public CompletableFuture deletetoken( + DeleteTokenRequest request, RequestOptions requestOptions) { + return this.rawClient.deletetoken(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture detokenize() { + return this.rawClient.detokenize().thenApply(response -> response.body()); + } + + public CompletableFuture detokenize(DetokenizeRequest request) { + return this.rawClient.detokenize(request).thenApply(response -> response.body()); + } + + public CompletableFuture detokenize(DetokenizeRequest request, RequestOptions requestOptions) { + return this.rawClient.detokenize(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture tokenize() { + return this.rawClient.tokenize().thenApply(response -> response.body()); + } + + public CompletableFuture tokenize(TokenizeRequest request) { + return this.rawClient.tokenize(request).thenApply(response -> response.body()); + } + + public CompletableFuture tokenize(TokenizeRequest request, RequestOptions requestOptions) { + return this.rawClient.tokenize(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java new file mode 100644 index 00000000..8bc46f02 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java @@ -0,0 +1,418 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.vaultLH.core.*; +import com.skyflow.vaultLH.resources.recordservice.requests.*; +import com.skyflow.vaultLH.types.*; +import okhttp3.*; + +import java.io.IOException; + +public class RawRecordserviceClient { + protected final ClientOptions clientOptions; + + public RawRecordserviceClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Executes a query on the specified vault. + */ + public ApiClientHttpResponse executequery() { + return executequery(ExecuteQueryRequest.builder().build()); + } + + /** + * Executes a query on the specified vault. + */ + public ApiClientHttpResponse executequery(ExecuteQueryRequest request) { + return executequery(request, null); + } + + /** + * Executes a query on the specified vault. + */ + public ApiClientHttpResponse executequery( + ExecuteQueryRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/query") + .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(), ExecuteQueryResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse delete() { + return delete(DeleteRequest.builder().build()); + } + + public ApiClientHttpResponse delete(DeleteRequest request) { + return delete(request, null); + } + + public ApiClientHttpResponse delete(DeleteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/delete") + .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(), DeleteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse get() { + return get(GetRequest.builder().build()); + } + + public ApiClientHttpResponse get(GetRequest request) { + return get(request, null); + } + + public ApiClientHttpResponse get(GetRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/get") + .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(), GetResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse insert() { + return insert(InsertRequest.builder().build()); + } + + public ApiClientHttpResponse insert(InsertRequest request) { + return insert(request, null); + } + + public ApiClientHttpResponse insert(InsertRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/insert") + .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(), InsertResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse update() { + return update(UpdateRequest.builder().build()); + } + + public ApiClientHttpResponse update(UpdateRequest request) { + return update(request, null); + } + + public ApiClientHttpResponse update(UpdateRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/records/update") + .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(), UpdateResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse deletetoken() { + return deletetoken(DeleteTokenRequest.builder().build()); + } + + public ApiClientHttpResponse deletetoken(DeleteTokenRequest request) { + return deletetoken(request, null); + } + + public ApiClientHttpResponse deletetoken( + DeleteTokenRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/tokens/delete") + .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(), DeleteTokenResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse detokenize() { + return detokenize(DetokenizeRequest.builder().build()); + } + + public ApiClientHttpResponse detokenize(DetokenizeRequest request) { + return detokenize(request, null); + } + + public ApiClientHttpResponse detokenize( + DetokenizeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/tokens/detokenize") + .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(), DetokenizeResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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); + } + } + + public ApiClientHttpResponse tokenize() { + return tokenize(TokenizeRequest.builder().build()); + } + + public ApiClientHttpResponse tokenize(TokenizeRequest request) { + return tokenize(request, null); + } + + public ApiClientHttpResponse tokenize(TokenizeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/tokens/get") + .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(), TokenizeResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + 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/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java new file mode 100644 index 00000000..a939d023 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice; + +import com.skyflow.vaultLH.core.ClientOptions; +import com.skyflow.vaultLH.core.RequestOptions; +import com.skyflow.vaultLH.resources.recordservice.requests.*; +import com.skyflow.vaultLH.types.*; + +public class RecordserviceClient { + protected final ClientOptions clientOptions; + + private final RawRecordserviceClient rawClient; + + public RecordserviceClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawRecordserviceClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRecordserviceClient withRawResponse() { + return this.rawClient; + } + + /** + * Executes a query on the specified vault. + */ + public ExecuteQueryResponse executequery() { + return this.rawClient.executequery().body(); + } + + /** + * Executes a query on the specified vault. + */ + public ExecuteQueryResponse executequery(ExecuteQueryRequest request) { + return this.rawClient.executequery(request).body(); + } + + /** + * Executes a query on the specified vault. + */ + public ExecuteQueryResponse executequery(ExecuteQueryRequest request, RequestOptions requestOptions) { + return this.rawClient.executequery(request, requestOptions).body(); + } + + public DeleteResponse delete() { + return this.rawClient.delete().body(); + } + + public DeleteResponse delete(DeleteRequest request) { + return this.rawClient.delete(request).body(); + } + + public DeleteResponse delete(DeleteRequest request, RequestOptions requestOptions) { + return this.rawClient.delete(request, requestOptions).body(); + } + + public GetResponse get() { + return this.rawClient.get().body(); + } + + public GetResponse get(GetRequest request) { + return this.rawClient.get(request).body(); + } + + public GetResponse get(GetRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).body(); + } + + public InsertResponse insert() { + return this.rawClient.insert().body(); + } + + public InsertResponse insert(InsertRequest request) { + return this.rawClient.insert(request).body(); + } + + public InsertResponse insert(InsertRequest request, RequestOptions requestOptions) { + return this.rawClient.insert(request, requestOptions).body(); + } + + public UpdateResponse update() { + return this.rawClient.update().body(); + } + + public UpdateResponse update(UpdateRequest request) { + return this.rawClient.update(request).body(); + } + + public UpdateResponse update(UpdateRequest request, RequestOptions requestOptions) { + return this.rawClient.update(request, requestOptions).body(); + } + + public DeleteTokenResponse deletetoken() { + return this.rawClient.deletetoken().body(); + } + + public DeleteTokenResponse deletetoken(DeleteTokenRequest request) { + return this.rawClient.deletetoken(request).body(); + } + + public DeleteTokenResponse deletetoken(DeleteTokenRequest request, RequestOptions requestOptions) { + return this.rawClient.deletetoken(request, requestOptions).body(); + } + + public DetokenizeResponse detokenize() { + return this.rawClient.detokenize().body(); + } + + public DetokenizeResponse detokenize(DetokenizeRequest request) { + return this.rawClient.detokenize(request).body(); + } + + public DetokenizeResponse detokenize(DetokenizeRequest request, RequestOptions requestOptions) { + return this.rawClient.detokenize(request, requestOptions).body(); + } + + public TokenizeResponse tokenize() { + return this.rawClient.tokenize().body(); + } + + public TokenizeResponse tokenize(TokenizeRequest request) { + return this.rawClient.tokenize(request).body(); + } + + public TokenizeResponse tokenize(TokenizeRequest request, RequestOptions requestOptions) { + return this.rawClient.tokenize(request, requestOptions).body(); + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java new file mode 100644 index 00000000..0dcd903a --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteRequest.Builder.class) +public final class DeleteRequest { + private final Optional vaultId; + + private final Optional tableName; + + private final Optional> skyflowIDs; + + private final Map additionalProperties; + + private DeleteRequest( + Optional vaultId, + Optional tableName, + Optional> skyflowIDs, + Map additionalProperties) { + this.vaultId = vaultId; + this.tableName = tableName; + this.skyflowIDs = skyflowIDs; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault where data is being deleted + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Name of the table where data is being deleted + */ + @JsonProperty("tableName") + public Optional getTableName() { + return tableName; + } + + /** + * @return Skyflow ID for the record to be deleted + */ + @JsonProperty("skyflowIDs") + public Optional> getSkyflowIDs() { + return skyflowIDs; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteRequest && equalTo((DeleteRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteRequest other) { + return vaultId.equals(other.vaultId) + && tableName.equals(other.tableName) + && skyflowIDs.equals(other.skyflowIDs); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.tableName, this.skyflowIDs); + } + + @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(); + + private Optional tableName = Optional.empty(); + + private Optional> skyflowIDs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteRequest other) { + vaultId(other.getVaultId()); + tableName(other.getTableName()); + skyflowIDs(other.getSkyflowIDs()); + return this; + } + + /** + *

ID of the vault where data is being deleted

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Name of the table where data is being deleted

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

Skyflow ID for the record to be deleted

+ */ + @JsonSetter(value = "skyflowIDs", nulls = Nulls.SKIP) + public Builder skyflowIDs(Optional> skyflowIDs) { + this.skyflowIDs = skyflowIDs; + return this; + } + + public Builder skyflowIDs(List skyflowIDs) { + this.skyflowIDs = Optional.ofNullable(skyflowIDs); + return this; + } + + public DeleteRequest build() { + return new DeleteRequest(vaultId, tableName, skyflowIDs, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java new file mode 100644 index 00000000..6cbab965 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTokenRequest.Builder.class) +public final class DeleteTokenRequest { + private final Optional vaultId; + + private final Optional> tokens; + + private final Map additionalProperties; + + private DeleteTokenRequest( + Optional vaultId, Optional> tokens, Map additionalProperties) { + this.vaultId = vaultId; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return Vault ID + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Token value + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTokenRequest && equalTo((DeleteTokenRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTokenRequest other) { + return vaultId.equals(other.vaultId) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.tokens); + } + + @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(); + + private Optional> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteTokenRequest other) { + vaultId(other.getVaultId()); + tokens(other.getTokens()); + return this; + } + + /** + *

Vault ID

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Token value

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(List tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public DeleteTokenRequest build() { + return new DeleteTokenRequest(vaultId, tokens, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java new file mode 100644 index 00000000..57cf43f3 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.vaultLH.types.TokenGroupRedactions; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetokenizeRequest.Builder.class) +public final class DetokenizeRequest { + private final Optional vaultId; + + private final Optional> tokens; + + private final Optional> tokenGroupRedactions; + + private final Map additionalProperties; + + private DetokenizeRequest( + Optional vaultId, + Optional> tokens, + Optional> tokenGroupRedactions, + Map additionalProperties) { + this.vaultId = vaultId; + this.tokens = tokens; + this.tokenGroupRedactions = tokenGroupRedactions; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault where detokenizing + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Token to be detokenized + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + /** + * @return List of token groups to be redacted. + */ + @JsonProperty("tokenGroupRedactions") + public Optional> getTokenGroupRedactions() { + return tokenGroupRedactions; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetokenizeRequest && equalTo((DetokenizeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetokenizeRequest other) { + return vaultId.equals(other.vaultId) + && tokens.equals(other.tokens) + && tokenGroupRedactions.equals(other.tokenGroupRedactions); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.tokens, this.tokenGroupRedactions); + } + + @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(); + + private Optional> tokens = Optional.empty(); + + private Optional> tokenGroupRedactions = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DetokenizeRequest other) { + vaultId(other.getVaultId()); + tokens(other.getTokens()); + tokenGroupRedactions(other.getTokenGroupRedactions()); + return this; + } + + /** + *

ID of the vault where detokenizing

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Token to be detokenized

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

List of token groups to be redacted.

+ */ + @JsonSetter(value = "tokenGroupRedactions", nulls = Nulls.SKIP) + public Builder tokenGroupRedactions(Optional> tokenGroupRedactions) { + this.tokenGroupRedactions = tokenGroupRedactions; + return this; + } + + public Builder tokenGroupRedactions(List tokenGroupRedactions) { + this.tokenGroupRedactions = Optional.ofNullable(tokenGroupRedactions); + return this; + } + + public DetokenizeRequest build() { + return new DetokenizeRequest(vaultId, tokens, tokenGroupRedactions, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java new file mode 100644 index 00000000..eb1572aa --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = ExecuteQueryRequest.Builder.class) +public final class ExecuteQueryRequest { + private final Optional vaultId; + + private final Optional query; + + private final Map additionalProperties; + + private ExecuteQueryRequest( + Optional vaultId, Optional query, Map additionalProperties) { + this.vaultId = vaultId; + this.query = query; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault where data is being inserted + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Query to execute. + */ + @JsonProperty("query") + public Optional getQuery() { + return query; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExecuteQueryRequest && equalTo((ExecuteQueryRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExecuteQueryRequest other) { + return vaultId.equals(other.vaultId) && query.equals(other.query); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.query); + } + + @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(); + + private Optional query = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ExecuteQueryRequest other) { + vaultId(other.getVaultId()); + query(other.getQuery()); + return this; + } + + /** + *

ID of the vault where data is being inserted

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Query to execute.

+ */ + @JsonSetter(value = "query", nulls = Nulls.SKIP) + public Builder query(Optional query) { + this.query = query; + return this; + } + + public Builder query(String query) { + this.query = Optional.ofNullable(query); + return this; + } + + public ExecuteQueryRequest build() { + return new ExecuteQueryRequest(vaultId, query, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java new file mode 100644 index 00000000..03fa9b32 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java @@ -0,0 +1,284 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.vaultLH.types.ColumnRedactions; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetRequest.Builder.class) +public final class GetRequest { + private final Optional vaultId; + + private final Optional tableName; + + private final Optional> skyflowIDs; + + private final Optional> columnRedactions; + + private final Optional> columns; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private GetRequest( + Optional vaultId, + Optional tableName, + Optional> skyflowIDs, + Optional> columnRedactions, + Optional> columns, + Optional limit, + Optional offset, + Map additionalProperties) { + this.vaultId = vaultId; + this.tableName = tableName; + this.skyflowIDs = skyflowIDs; + this.columnRedactions = columnRedactions; + this.columns = columns; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault where data is being fetched + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Name of the table where data is being fetched + */ + @JsonProperty("tableName") + public Optional getTableName() { + return tableName; + } + + /** + * @return Skyflow ID for the record to be fetched + */ + @JsonProperty("skyflowIDs") + public Optional> getSkyflowIDs() { + return skyflowIDs; + } + + /** + * @return List of columns to be redacted. + */ + @JsonProperty("columnRedactions") + public Optional> getColumnRedactions() { + return columnRedactions; + } + + /** + * @return List of columns to be fetched. + */ + @JsonProperty("columns") + public Optional> getColumns() { + return columns; + } + + /** + * @return Limit for the number of records to be fetched + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Offset for the number of records to be fetched + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetRequest && equalTo((GetRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetRequest other) { + return vaultId.equals(other.vaultId) + && tableName.equals(other.tableName) + && skyflowIDs.equals(other.skyflowIDs) + && columnRedactions.equals(other.columnRedactions) + && columns.equals(other.columns) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @Override + public int hashCode() { + return Objects.hash( + this.vaultId, + this.tableName, + this.skyflowIDs, + this.columnRedactions, + this.columns, + this.limit, + this.offset); + } + + @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(); + + private Optional tableName = Optional.empty(); + + private Optional> skyflowIDs = Optional.empty(); + + private Optional> columnRedactions = Optional.empty(); + + private Optional> columns = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetRequest other) { + vaultId(other.getVaultId()); + tableName(other.getTableName()); + skyflowIDs(other.getSkyflowIDs()); + columnRedactions(other.getColumnRedactions()); + columns(other.getColumns()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + /** + *

ID of the vault where data is being fetched

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Name of the table where data is being fetched

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

Skyflow ID for the record to be fetched

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

List of columns to be redacted.

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

List of columns to be fetched.

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

Limit for the number of records to be fetched

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

Offset for the number of records to be fetched

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public GetRequest build() { + return new GetRequest( + vaultId, tableName, skyflowIDs, columnRedactions, columns, limit, offset, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java new file mode 100644 index 00000000..eb1bb342 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.vaultLH.types.InsertRecordData; +import com.skyflow.vaultLH.types.Upsert; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InsertRequest.Builder.class) +public final class InsertRequest { + private final Optional vaultId; + + private final Optional tableName; + + private final Optional> records; + + private final Optional upsert; + + private final Map additionalProperties; + + private InsertRequest( + Optional vaultId, + Optional tableName, + Optional> records, + Optional upsert, + Map additionalProperties) { + this.vaultId = vaultId; + this.tableName = tableName; + this.records = records; + this.upsert = upsert; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault where data is being inserted + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Name of the table where data is being inserted + */ + @JsonProperty("tableName") + public Optional getTableName() { + return tableName; + } + + /** + * @return List of data row wise that is to be inserted in the vault + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @JsonProperty("upsert") + public Optional getUpsert() { + return upsert; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InsertRequest && equalTo((InsertRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InsertRequest other) { + return vaultId.equals(other.vaultId) + && tableName.equals(other.tableName) + && records.equals(other.records) + && upsert.equals(other.upsert); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.tableName, this.records, this.upsert); + } + + @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(); + + private Optional tableName = Optional.empty(); + + private Optional> records = Optional.empty(); + + private Optional upsert = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InsertRequest other) { + vaultId(other.getVaultId()); + tableName(other.getTableName()); + records(other.getRecords()); + upsert(other.getUpsert()); + return this; + } + + /** + *

ID of the vault where data is being inserted

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Name of the table where data is being inserted

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

List of data row wise that is to be inserted in the vault

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + @JsonSetter(value = "upsert", nulls = Nulls.SKIP) + public Builder upsert(Optional upsert) { + this.upsert = upsert; + return this; + } + + public Builder upsert(Upsert upsert) { + this.upsert = Optional.ofNullable(upsert); + return this; + } + + public InsertRequest build() { + return new InsertRequest(vaultId, tableName, records, upsert, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java new file mode 100644 index 00000000..a57f4246 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.vaultLH.types.TokenizeRequestObject; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TokenizeRequest.Builder.class) +public final class TokenizeRequest { + private final Optional vaultId; + + private final Optional> data; + + private final Map additionalProperties; + + private TokenizeRequest( + Optional vaultId, + Optional> data, + Map additionalProperties) { + this.vaultId = vaultId; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return Vault ID. + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Data to be tokenized + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenizeRequest && equalTo((TokenizeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenizeRequest other) { + return vaultId.equals(other.vaultId) && data.equals(other.data); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.data); + } + + @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(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenizeRequest other) { + vaultId(other.getVaultId()); + data(other.getData()); + return this; + } + + /** + *

Vault ID.

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Data to be tokenized

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public TokenizeRequest build() { + return new TokenizeRequest(vaultId, data, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java new file mode 100644 index 00000000..96027644 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.resources.recordservice.requests; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.vaultLH.types.EnumUpdateType; +import com.skyflow.vaultLH.types.UpdateRecordData; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateRequest.Builder.class) +public final class UpdateRequest { + private final Optional vaultId; + + private final Optional tableName; + + private final Optional> records; + + private final Optional updateType; + + private final Map additionalProperties; + + private UpdateRequest( + Optional vaultId, + Optional tableName, + Optional> records, + Optional updateType, + Map additionalProperties) { + this.vaultId = vaultId; + this.tableName = tableName; + this.records = records; + this.updateType = updateType; + this.additionalProperties = additionalProperties; + } + + /** + * @return ID of the vault where data is being updated + */ + @JsonProperty("vaultID") + public Optional getVaultId() { + return vaultId; + } + + /** + * @return Name of the table where data is being updated + */ + @JsonProperty("tableName") + public Optional getTableName() { + return tableName; + } + + /** + * @return List of data row wise that is to be updated in the vault + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @JsonProperty("updateType") + public Optional getUpdateType() { + return updateType; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateRequest && equalTo((UpdateRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateRequest other) { + return vaultId.equals(other.vaultId) + && tableName.equals(other.tableName) + && records.equals(other.records) + && updateType.equals(other.updateType); + } + + @Override + public int hashCode() { + return Objects.hash(this.vaultId, this.tableName, this.records, this.updateType); + } + + @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(); + + private Optional tableName = Optional.empty(); + + private Optional> records = Optional.empty(); + + private Optional updateType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateRequest other) { + vaultId(other.getVaultId()); + tableName(other.getTableName()); + records(other.getRecords()); + updateType(other.getUpdateType()); + return this; + } + + /** + *

ID of the vault where data is being updated

+ */ + @JsonSetter(value = "vaultID", 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; + } + + /** + *

Name of the table where data is being updated

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

List of data row wise that is to be updated in the vault

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + @JsonSetter(value = "updateType", nulls = Nulls.SKIP) + public Builder updateType(Optional updateType) { + this.updateType = updateType; + return this; + } + + public Builder updateType(EnumUpdateType updateType) { + this.updateType = Optional.ofNullable(updateType); + return this; + } + + public UpdateRequest build() { + return new UpdateRequest(vaultId, tableName, records, updateType, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java b/v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java new file mode 100644 index 00000000..14a09d6d --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = ColumnRedactions.Builder.class) +public final class ColumnRedactions { + private final Optional columnName; + + private final Optional redaction; + + private final Map additionalProperties; + + private ColumnRedactions( + Optional columnName, Optional redaction, Map additionalProperties) { + this.columnName = columnName; + this.redaction = redaction; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the column to be redacted + */ + @JsonProperty("columnName") + public Optional getColumnName() { + return columnName; + } + + /** + * @return Name of the redaction. Eg: plain_text, redacted, mask1 + */ + @JsonProperty("redaction") + public Optional getRedaction() { + return redaction; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ColumnRedactions && equalTo((ColumnRedactions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ColumnRedactions other) { + return columnName.equals(other.columnName) && redaction.equals(other.redaction); + } + + @Override + public int hashCode() { + return Objects.hash(this.columnName, this.redaction); + } + + @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 columnName = Optional.empty(); + + private Optional redaction = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ColumnRedactions other) { + columnName(other.getColumnName()); + redaction(other.getRedaction()); + return this; + } + + /** + *

Name of the column to be redacted

+ */ + @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; + } + + /** + *

Name of the redaction. Eg: plain_text, redacted, mask1

+ */ + @JsonSetter(value = "redaction", nulls = Nulls.SKIP) + public Builder redaction(Optional redaction) { + this.redaction = redaction; + return this; + } + + public Builder redaction(String redaction) { + this.redaction = Optional.ofNullable(redaction); + return this; + } + + public ColumnRedactions build() { + return new ColumnRedactions(columnName, redaction, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java new file mode 100644 index 00000000..514e1d06 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteResponse.Builder.class) +public final class DeleteResponse { + private final Optional> records; + + private final Map additionalProperties; + + private DeleteResponse(Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of deleted records with skyflow ID and any partial errors. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteResponse && equalTo((DeleteResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

List of deleted records with skyflow ID and any partial errors.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public DeleteResponse build() { + return new DeleteResponse(records, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java new file mode 100644 index 00000000..a40b18e9 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = DeleteResponseObject.Builder.class) +public final class DeleteResponseObject { + private final Optional skyflowId; + + private final Optional error; + + private final Optional httpCode; + + private final Map additionalProperties; + + private DeleteResponseObject( + Optional skyflowId, + Optional error, + Optional httpCode, + Map additionalProperties) { + this.skyflowId = skyflowId; + this.error = error; + this.httpCode = httpCode; + this.additionalProperties = additionalProperties; + } + + /** + * @return Skyflow ID for the deleted record + */ + @JsonProperty("skyflowID") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return Partial Error message if any + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + /** + * @return HTTP status code of the response + */ + @JsonProperty("httpCode") + public Optional getHttpCode() { + return httpCode; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteResponseObject && equalTo((DeleteResponseObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteResponseObject other) { + return skyflowId.equals(other.skyflowId) && error.equals(other.error) && httpCode.equals(other.httpCode); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.error, this.httpCode); + } + + @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 error = Optional.empty(); + + private Optional httpCode = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteResponseObject other) { + skyflowId(other.getSkyflowId()); + error(other.getError()); + httpCode(other.getHttpCode()); + return this; + } + + /** + *

Skyflow ID for the deleted record

+ */ + @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; + } + + /** + *

Partial Error message if any

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

HTTP status code of the response

+ */ + @JsonSetter(value = "httpCode", nulls = Nulls.SKIP) + public Builder httpCode(Optional httpCode) { + this.httpCode = httpCode; + return this; + } + + public Builder httpCode(Integer httpCode) { + this.httpCode = Optional.ofNullable(httpCode); + return this; + } + + public DeleteResponseObject build() { + return new DeleteResponseObject(skyflowId, error, httpCode, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java new file mode 100644 index 00000000..849ec5ee --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTokenResponse.Builder.class) +public final class DeleteTokenResponse { + private final Optional> tokens; + + private final Map additionalProperties; + + private DeleteTokenResponse( + Optional> tokens, Map additionalProperties) { + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return Tokens data for Delete + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTokenResponse && equalTo((DeleteTokenResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTokenResponse other) { + return tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.tokens); + } + + @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> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteTokenResponse other) { + tokens(other.getTokens()); + return this; + } + + /** + *

Tokens data for Delete

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(List tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public DeleteTokenResponse build() { + return new DeleteTokenResponse(tokens, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java new file mode 100644 index 00000000..0a994b6c --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = DeleteTokenResponseObject.Builder.class) +public final class DeleteTokenResponseObject { + private final Optional value; + + private final Optional error; + + private final Optional httpCode; + + private final Map additionalProperties; + + private DeleteTokenResponseObject( + Optional value, + Optional error, + Optional httpCode, + Map additionalProperties) { + this.value = value; + this.error = error; + this.httpCode = httpCode; + this.additionalProperties = additionalProperties; + } + + /** + * @return Token value + */ + @JsonProperty("value") + public Optional getValue() { + return value; + } + + /** + * @return Error if deletion failed + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + /** + * @return HTTP status code of the response + */ + @JsonProperty("httpCode") + public Optional getHttpCode() { + return httpCode; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTokenResponseObject && equalTo((DeleteTokenResponseObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTokenResponseObject other) { + return value.equals(other.value) && error.equals(other.error) && httpCode.equals(other.httpCode); + } + + @Override + public int hashCode() { + return Objects.hash(this.value, this.error, this.httpCode); + } + + @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 value = Optional.empty(); + + private Optional error = Optional.empty(); + + private Optional httpCode = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteTokenResponseObject other) { + value(other.getValue()); + error(other.getError()); + httpCode(other.getHttpCode()); + return this; + } + + /** + *

Token value

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

Error if deletion failed

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

HTTP status code of the response

+ */ + @JsonSetter(value = "httpCode", nulls = Nulls.SKIP) + public Builder httpCode(Optional httpCode) { + this.httpCode = httpCode; + return this; + } + + public Builder httpCode(Integer httpCode) { + this.httpCode = Optional.ofNullable(httpCode); + return this; + } + + public DeleteTokenResponseObject build() { + return new DeleteTokenResponseObject(value, error, httpCode, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java new file mode 100644 index 00000000..b52a0b92 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetokenizeResponse.Builder.class) +public final class DetokenizeResponse { + private final Optional> response; + + private final Map additionalProperties; + + private DetokenizeResponse( + Optional> response, Map additionalProperties) { + this.response = response; + this.additionalProperties = additionalProperties; + } + + /** + * @return Detokenized data + */ + @JsonProperty("response") + public Optional> getResponse() { + return response; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetokenizeResponse && equalTo((DetokenizeResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetokenizeResponse other) { + return response.equals(other.response); + } + + @Override + public int hashCode() { + return Objects.hash(this.response); + } + + @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> response = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DetokenizeResponse other) { + response(other.getResponse()); + return this; + } + + /** + *

Detokenized data

+ */ + @JsonSetter(value = "response", nulls = Nulls.SKIP) + public Builder response(Optional> response) { + this.response = response; + return this; + } + + public Builder response(List response) { + this.response = Optional.ofNullable(response); + return this; + } + + public DetokenizeResponse build() { + return new DetokenizeResponse(response, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java b/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java new file mode 100644 index 00000000..76835758 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java @@ -0,0 +1,243 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = DetokenizeResponseObject.Builder.class) +public final class DetokenizeResponseObject { + private final Optional token; + + private final Optional value; + + private final Optional tokenGroupName; + + private final Optional error; + + private final Optional httpCode; + + private final Optional> metadata; + + private final Map additionalProperties; + + private DetokenizeResponseObject( + Optional token, + Optional value, + Optional tokenGroupName, + Optional error, + Optional httpCode, + Optional> metadata, + Map additionalProperties) { + this.token = token; + this.value = value; + this.tokenGroupName = tokenGroupName; + this.error = error; + this.httpCode = httpCode; + this.metadata = metadata; + this.additionalProperties = additionalProperties; + } + + /** + * @return Token to be detokenized + */ + @JsonProperty("token") + public Optional getToken() { + return token; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + /** + * @return Token group name + */ + @JsonProperty("tokenGroupName") + public Optional getTokenGroupName() { + return tokenGroupName; + } + + /** + * @return Error if detokenization failed + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + /** + * @return HTTP status code of the response + */ + @JsonProperty("httpCode") + public Optional getHttpCode() { + return httpCode; + } + + /** + * @return Additional metadata associated with the token, such as tableName or skyflowID + */ + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetokenizeResponseObject && equalTo((DetokenizeResponseObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetokenizeResponseObject other) { + return token.equals(other.token) + && value.equals(other.value) + && tokenGroupName.equals(other.tokenGroupName) + && error.equals(other.error) + && httpCode.equals(other.httpCode) + && metadata.equals(other.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(this.token, this.value, this.tokenGroupName, this.error, this.httpCode, this.metadata); + } + + @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 token = Optional.empty(); + + private Optional value = Optional.empty(); + + private Optional tokenGroupName = Optional.empty(); + + private Optional error = Optional.empty(); + + private Optional httpCode = Optional.empty(); + + private Optional> metadata = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DetokenizeResponseObject other) { + token(other.getToken()); + value(other.getValue()); + tokenGroupName(other.getTokenGroupName()); + error(other.getError()); + httpCode(other.getHttpCode()); + metadata(other.getMetadata()); + return this; + } + + /** + *

Token to be detokenized

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

Token group name

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

Error if detokenization failed

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

HTTP status code of the response

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

Additional metadata associated with the token, such as tableName or skyflowID

+ */ + @JsonSetter(value = "metadata", nulls = Nulls.SKIP) + public Builder metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + public Builder metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public DetokenizeResponseObject build() { + return new DetokenizeResponseObject( + token, value, tokenGroupName, error, httpCode, metadata, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java b/v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java new file mode 100644 index 00000000..8167e99c --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EnumDataType { + UNDEFINED_DATATYPE("UNDEFINED_DATATYPE"), + + STRING("STRING"), + + NUMBER("NUMBER"), + + BOOL("BOOL"), + + JSON("JSON"); + + private final String value; + + EnumDataType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java b/v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java new file mode 100644 index 00000000..8c416624 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EnumUpdateType { + UPDATE("UPDATE"), + + REPLACE("REPLACE"); + + private final String value; + + EnumUpdateType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java new file mode 100644 index 00000000..db676077 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = ExecuteQueryRecordResponse.Builder.class) +public final class ExecuteQueryRecordResponse { + private final Optional> data; + + private final Map additionalProperties; + + private ExecuteQueryRecordResponse(Optional> data, Map additionalProperties) { + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return Fields and values for the record. For example, {'field_1':'value_1', 'field_2':'value_2'}. + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExecuteQueryRecordResponse && equalTo((ExecuteQueryRecordResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExecuteQueryRecordResponse other) { + return data.equals(other.data); + } + + @Override + public int hashCode() { + return Objects.hash(this.data); + } + + @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> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ExecuteQueryRecordResponse other) { + data(other.getData()); + return this; + } + + /** + *

Fields and values for the record. For example, {'field_1':'value_1', 'field_2':'value_2'}.

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(Map data) { + this.data = Optional.ofNullable(data); + return this; + } + + public ExecuteQueryRecordResponse build() { + return new ExecuteQueryRecordResponse(data, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java new file mode 100644 index 00000000..d8aea21a --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExecuteQueryResponse.Builder.class) +public final class ExecuteQueryResponse { + private final Optional> records; + + private final Map additionalProperties; + + private ExecuteQueryResponse( + Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return Records corresponding to the specified query. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExecuteQueryResponse && equalTo((ExecuteQueryResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExecuteQueryResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ExecuteQueryResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

Records corresponding to the specified query.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public ExecuteQueryResponse build() { + return new ExecuteQueryResponse(records, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java new file mode 100644 index 00000000..71f9e184 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetResponse.Builder.class) +public final class GetResponse { + private final Optional> records; + + private final Map additionalProperties; + + private GetResponse(Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of fetched records with skyflow ID, tokens, data, and any partial errors + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetResponse && equalTo((GetResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

List of fetched records with skyflow ID, tokens, data, and any partial errors

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public GetResponse build() { + return new GetResponse(records, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java b/v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java new file mode 100644 index 00000000..e5635b40 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java @@ -0,0 +1,127 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = InsertRecordData.Builder.class) +public final class InsertRecordData { + private final Optional> data; + + private final Optional> tokens; + + private final Map additionalProperties; + + private InsertRecordData( + Optional> data, + Optional> tokens, + Map additionalProperties) { + this.data = data; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return Columns names and values + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + /** + * @return Tokens data for the columns if any + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InsertRecordData && equalTo((InsertRecordData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InsertRecordData other) { + return data.equals(other.data) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.data, this.tokens); + } + + @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> data = Optional.empty(); + + private Optional> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InsertRecordData other) { + data(other.getData()); + tokens(other.getTokens()); + return this; + } + + /** + *

Columns names and values

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

Tokens data for the columns if any

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(Map tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public InsertRecordData build() { + return new InsertRecordData(data, tokens, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java new file mode 100644 index 00000000..45cd8889 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InsertResponse.Builder.class) +public final class InsertResponse { + private final Optional> records; + + private final Map additionalProperties; + + private InsertResponse(Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of inserted records with skyflow ID, tokens, data, and any partial errors. + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InsertResponse && equalTo((InsertResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InsertResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InsertResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

List of inserted records with skyflow ID, tokens, data, and any partial errors.

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public InsertResponse build() { + return new InsertResponse(records, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java b/v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java new file mode 100644 index 00000000..ca2d1dd5 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = ProtobufAny.Builder.class) +public final class ProtobufAny { + private final Optional type; + + private final Map additionalProperties; + + private ProtobufAny(Optional type, Map additionalProperties) { + this.type = type; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("@type") + public Optional getType() { + return type; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProtobufAny && equalTo((ProtobufAny) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProtobufAny other) { + return type.equals(other.type); + } + + @Override + public int hashCode() { + return Objects.hash(this.type); + } + + @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 type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ProtobufAny other) { + type(other.getType()); + return this; + } + + @JsonSetter(value = "@type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + public ProtobufAny build() { + return new ProtobufAny(type, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java b/v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java new file mode 100644 index 00000000..bf3f5614 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java @@ -0,0 +1,248 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = RecordResponseObject.Builder.class) +public final class RecordResponseObject { + private final Optional skyflowId; + + private final Optional> tokens; + + private final Optional> data; + + private final Optional> hashedData; + + private final Optional error; + + private final Optional httpCode; + + private final Map additionalProperties; + + private RecordResponseObject( + Optional skyflowId, + Optional> tokens, + Optional> data, + Optional> hashedData, + Optional error, + Optional httpCode, + Map additionalProperties) { + this.skyflowId = skyflowId; + this.tokens = tokens; + this.data = data; + this.hashedData = hashedData; + this.error = error; + this.httpCode = httpCode; + this.additionalProperties = additionalProperties; + } + + /** + * @return Skyflow ID for the inserted record + */ + @JsonProperty("skyflowID") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return Tokens data for the columns if any + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + /** + * @return Columns names and values + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + /** + * @return Hashed Data for the columns if any + */ + @JsonProperty("hashedData") + public Optional> getHashedData() { + return hashedData; + } + + /** + * @return Partial Error message if any + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + /** + * @return HTTP status code of the response + */ + @JsonProperty("httpCode") + public Optional getHttpCode() { + return httpCode; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RecordResponseObject && equalTo((RecordResponseObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RecordResponseObject other) { + return skyflowId.equals(other.skyflowId) + && tokens.equals(other.tokens) + && data.equals(other.data) + && hashedData.equals(other.hashedData) + && error.equals(other.error) + && httpCode.equals(other.httpCode); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.tokens, this.data, this.hashedData, this.error, this.httpCode); + } + + @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> tokens = Optional.empty(); + + private Optional> data = Optional.empty(); + + private Optional> hashedData = Optional.empty(); + + private Optional error = Optional.empty(); + + private Optional httpCode = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RecordResponseObject other) { + skyflowId(other.getSkyflowId()); + tokens(other.getTokens()); + data(other.getData()); + hashedData(other.getHashedData()); + error(other.getError()); + httpCode(other.getHttpCode()); + return this; + } + + /** + *

Skyflow ID for the inserted record

+ */ + @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; + } + + /** + *

Tokens data for the columns if any

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

Columns names and values

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

Hashed Data for the columns if any

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

Partial Error message if any

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

HTTP status code of the response

+ */ + @JsonSetter(value = "httpCode", nulls = Nulls.SKIP) + public Builder httpCode(Optional httpCode) { + this.httpCode = httpCode; + return this; + } + + public Builder httpCode(Integer httpCode) { + this.httpCode = Optional.ofNullable(httpCode); + return this; + } + + public RecordResponseObject build() { + return new RecordResponseObject(skyflowId, tokens, data, hashedData, error, httpCode, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java b/v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java new file mode 100644 index 00000000..bf8517e1 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java @@ -0,0 +1,135 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RpcStatus.Builder.class) +public final class RpcStatus { + private final Optional code; + + private final Optional message; + + private final Optional> details; + + private final Map additionalProperties; + + private RpcStatus( + Optional code, + Optional message, + Optional> details, + Map additionalProperties) { + this.code = code; + this.message = message; + this.details = details; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("code") + public Optional getCode() { + return code; + } + + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @JsonProperty("details") + public Optional> getDetails() { + return details; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RpcStatus && equalTo((RpcStatus) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RpcStatus other) { + return code.equals(other.code) && message.equals(other.message) && details.equals(other.details); + } + + @Override + public int hashCode() { + return Objects.hash(this.code, this.message, this.details); + } + + @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 code = Optional.empty(); + + private Optional message = Optional.empty(); + + private Optional> details = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RpcStatus other) { + code(other.getCode()); + message(other.getMessage()); + details(other.getDetails()); + return this; + } + + @JsonSetter(value = "code", nulls = Nulls.SKIP) + public Builder code(Optional code) { + this.code = code; + return this; + } + + public Builder code(Integer code) { + this.code = Optional.ofNullable(code); + return this; + } + + @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; + } + + @JsonSetter(value = "details", nulls = Nulls.SKIP) + public Builder details(Optional> details) { + this.details = details; + return this; + } + + public Builder details(List details) { + this.details = Optional.ofNullable(details); + return this; + } + + public RpcStatus build() { + return new RpcStatus(code, message, details, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java b/v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java new file mode 100644 index 00000000..ba471b8a --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = TokenGroupRedactions.Builder.class) +public final class TokenGroupRedactions { + private final Optional tokenGroupName; + + private final Optional redaction; + + private final Map additionalProperties; + + private TokenGroupRedactions( + Optional tokenGroupName, Optional redaction, Map additionalProperties) { + this.tokenGroupName = tokenGroupName; + this.redaction = redaction; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name of the token group to be redacted + */ + @JsonProperty("tokenGroupName") + public Optional getTokenGroupName() { + return tokenGroupName; + } + + /** + * @return Name of the redaction. Eg: plain_text, redacted, mask1 + */ + @JsonProperty("redaction") + public Optional getRedaction() { + return redaction; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenGroupRedactions && equalTo((TokenGroupRedactions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenGroupRedactions other) { + return tokenGroupName.equals(other.tokenGroupName) && redaction.equals(other.redaction); + } + + @Override + public int hashCode() { + return Objects.hash(this.tokenGroupName, this.redaction); + } + + @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 tokenGroupName = Optional.empty(); + + private Optional redaction = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenGroupRedactions other) { + tokenGroupName(other.getTokenGroupName()); + redaction(other.getRedaction()); + return this; + } + + /** + *

Name of the token group to be redacted

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

Name of the redaction. Eg: plain_text, redacted, mask1

+ */ + @JsonSetter(value = "redaction", nulls = Nulls.SKIP) + public Builder redaction(Optional redaction) { + this.redaction = redaction; + return this; + } + + public Builder redaction(String redaction) { + this.redaction = Optional.ofNullable(redaction); + return this; + } + + public TokenGroupRedactions build() { + return new TokenGroupRedactions(tokenGroupName, redaction, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java new file mode 100644 index 00000000..6fef6c9f --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TokenizeRequestObject.Builder.class) +public final class TokenizeRequestObject { + private final Optional value; + + private final Optional dataType; + + private final Optional> tokenGroupNames; + + private final Map additionalProperties; + + private TokenizeRequestObject( + Optional value, + Optional dataType, + Optional> tokenGroupNames, + Map additionalProperties) { + this.value = value; + this.dataType = dataType; + this.tokenGroupNames = tokenGroupNames; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + @JsonProperty("dataType") + public Optional getDataType() { + return dataType; + } + + /** + * @return List of token group names + */ + @JsonProperty("tokenGroupNames") + public Optional> getTokenGroupNames() { + return tokenGroupNames; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenizeRequestObject && equalTo((TokenizeRequestObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenizeRequestObject other) { + return value.equals(other.value) + && dataType.equals(other.dataType) + && tokenGroupNames.equals(other.tokenGroupNames); + } + + @Override + public int hashCode() { + return Objects.hash(this.value, this.dataType, this.tokenGroupNames); + } + + @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 value = Optional.empty(); + + private Optional dataType = Optional.empty(); + + private Optional> tokenGroupNames = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenizeRequestObject other) { + value(other.getValue()); + dataType(other.getDataType()); + tokenGroupNames(other.getTokenGroupNames()); + return this; + } + + @JsonSetter(value = "value", nulls = Nulls.SKIP) + public Builder value(Optional value) { + this.value = value; + return this; + } + + public Builder value(Object value) { + this.value = Optional.ofNullable(value); + return this; + } + + @JsonSetter(value = "dataType", nulls = Nulls.SKIP) + public Builder dataType(Optional dataType) { + this.dataType = dataType; + return this; + } + + public Builder dataType(EnumDataType dataType) { + this.dataType = Optional.ofNullable(dataType); + return this; + } + + /** + *

List of token group names

+ */ + @JsonSetter(value = "tokenGroupNames", nulls = Nulls.SKIP) + public Builder tokenGroupNames(Optional> tokenGroupNames) { + this.tokenGroupNames = tokenGroupNames; + return this; + } + + public Builder tokenGroupNames(List tokenGroupNames) { + this.tokenGroupNames = Optional.ofNullable(tokenGroupNames); + return this; + } + + public TokenizeRequestObject build() { + return new TokenizeRequestObject(value, dataType, tokenGroupNames, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java new file mode 100644 index 00000000..20688f36 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TokenizeResponse.Builder.class) +public final class TokenizeResponse { + private final Optional> response; + + private final Map additionalProperties; + + private TokenizeResponse( + Optional> response, Map additionalProperties) { + this.response = response; + this.additionalProperties = additionalProperties; + } + + /** + * @return Tokenized data + */ + @JsonProperty("response") + public Optional> getResponse() { + return response; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenizeResponse && equalTo((TokenizeResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenizeResponse other) { + return response.equals(other.response); + } + + @Override + public int hashCode() { + return Objects.hash(this.response); + } + + @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> response = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenizeResponse other) { + response(other.getResponse()); + return this; + } + + /** + *

Tokenized data

+ */ + @JsonSetter(value = "response", nulls = Nulls.SKIP) + public Builder response(Optional> response) { + this.response = response; + return this; + } + + public Builder response(List response) { + this.response = Optional.ofNullable(response); + return this; + } + + public TokenizeResponse build() { + return new TokenizeResponse(response, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java new file mode 100644 index 00000000..0339565d --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TokenizeResponseObject.Builder.class) +public final class TokenizeResponseObject { + private final Optional value; + + private final Optional> tokens; + + private final Map additionalProperties; + + private TokenizeResponseObject( + Optional value, + Optional> tokens, + Map additionalProperties) { + this.value = value; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + /** + * @return Token value + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenizeResponseObject && equalTo((TokenizeResponseObject) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenizeResponseObject other) { + return value.equals(other.value) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.value, this.tokens); + } + + @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 value = Optional.empty(); + + private Optional> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenizeResponseObject other) { + value(other.getValue()); + tokens(other.getTokens()); + return this; + } + + @JsonSetter(value = "value", nulls = Nulls.SKIP) + public Builder value(Optional value) { + this.value = value; + return this; + } + + public Builder value(Object value) { + this.value = Optional.ofNullable(value); + return this; + } + + /** + *

Token value

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(List tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public TokenizeResponseObject build() { + return new TokenizeResponseObject(value, tokens, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java new file mode 100644 index 00000000..ee03df38 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = TokenizeResponseObjectToken.Builder.class) +public final class TokenizeResponseObjectToken { + private final Optional tokenGroupName; + + private final Optional token; + + private final Optional error; + + private final Optional httpCode; + + private final Map additionalProperties; + + private TokenizeResponseObjectToken( + Optional tokenGroupName, + Optional token, + Optional error, + Optional httpCode, + Map additionalProperties) { + this.tokenGroupName = tokenGroupName; + this.token = token; + this.error = error; + this.httpCode = httpCode; + this.additionalProperties = additionalProperties; + } + + /** + * @return Token group Name + */ + @JsonProperty("tokenGroupName") + public Optional getTokenGroupName() { + return tokenGroupName; + } + + /** + * @return Token value + */ + @JsonProperty("token") + public Optional getToken() { + return token; + } + + /** + * @return Error if tokenization failed + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + /** + * @return HTTP status code of the response + */ + @JsonProperty("httpCode") + public Optional getHttpCode() { + return httpCode; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TokenizeResponseObjectToken && equalTo((TokenizeResponseObjectToken) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TokenizeResponseObjectToken other) { + return tokenGroupName.equals(other.tokenGroupName) + && token.equals(other.token) + && error.equals(other.error) + && httpCode.equals(other.httpCode); + } + + @Override + public int hashCode() { + return Objects.hash(this.tokenGroupName, this.token, this.error, this.httpCode); + } + + @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 tokenGroupName = Optional.empty(); + + private Optional token = Optional.empty(); + + private Optional error = Optional.empty(); + + private Optional httpCode = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TokenizeResponseObjectToken other) { + tokenGroupName(other.getTokenGroupName()); + token(other.getToken()); + error(other.getError()); + httpCode(other.getHttpCode()); + return this; + } + + /** + *

Token group Name

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

Token value

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

Error if tokenization failed

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

HTTP status code of the response

+ */ + @JsonSetter(value = "httpCode", nulls = Nulls.SKIP) + public Builder httpCode(Optional httpCode) { + this.httpCode = httpCode; + return this; + } + + public Builder httpCode(Integer httpCode) { + this.httpCode = Optional.ofNullable(httpCode); + return this; + } + + public TokenizeResponseObjectToken build() { + return new TokenizeResponseObjectToken(tokenGroupName, token, error, httpCode, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java b/v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java new file mode 100644 index 00000000..8a41303b --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.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 = UpdateRecordData.Builder.class) +public final class UpdateRecordData { + private final Optional skyflowId; + + private final Optional> data; + + private final Optional> tokens; + + private final Map additionalProperties; + + private UpdateRecordData( + Optional skyflowId, + Optional> data, + Optional> tokens, + Map additionalProperties) { + this.skyflowId = skyflowId; + this.data = data; + this.tokens = tokens; + this.additionalProperties = additionalProperties; + } + + /** + * @return Skyflow ID for the record to be updated + */ + @JsonProperty("skyflowID") + public Optional getSkyflowId() { + return skyflowId; + } + + /** + * @return List of data row wise that is to be updated in the vault + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + /** + * @return Tokens data for the columns if any + */ + @JsonProperty("tokens") + public Optional> getTokens() { + return tokens; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateRecordData && equalTo((UpdateRecordData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateRecordData other) { + return skyflowId.equals(other.skyflowId) && data.equals(other.data) && tokens.equals(other.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(this.skyflowId, this.data, this.tokens); + } + + @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> data = Optional.empty(); + + private Optional> tokens = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateRecordData other) { + skyflowId(other.getSkyflowId()); + data(other.getData()); + tokens(other.getTokens()); + return this; + } + + /** + *

Skyflow ID for the record to be updated

+ */ + @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; + } + + /** + *

List of data row wise that is to be updated in the vault

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

Tokens data for the columns if any

+ */ + @JsonSetter(value = "tokens", nulls = Nulls.SKIP) + public Builder tokens(Optional> tokens) { + this.tokens = tokens; + return this; + } + + public Builder tokens(Map tokens) { + this.tokens = Optional.ofNullable(tokens); + return this; + } + + public UpdateRecordData build() { + return new UpdateRecordData(skyflowId, data, tokens, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java b/v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java new file mode 100644 index 00000000..f77ef04d --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateResponse.Builder.class) +public final class UpdateResponse { + private final Optional> records; + + private final Map additionalProperties; + + private UpdateResponse(Optional> records, Map additionalProperties) { + this.records = records; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of updated records with skyflow ID, tokens, data, and any partial errors + */ + @JsonProperty("records") + public Optional> getRecords() { + return records; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateResponse && equalTo((UpdateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateResponse other) { + return records.equals(other.records); + } + + @Override + public int hashCode() { + return Objects.hash(this.records); + } + + @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> records = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateResponse other) { + records(other.getRecords()); + return this; + } + + /** + *

List of updated records with skyflow ID, tokens, data, and any partial errors

+ */ + @JsonSetter(value = "records", nulls = Nulls.SKIP) + public Builder records(Optional> records) { + this.records = records; + return this; + } + + public Builder records(List records) { + this.records = Optional.ofNullable(records); + return this; + } + + public UpdateResponse build() { + return new UpdateResponse(records, additionalProperties); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java b/v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java new file mode 100644 index 00000000..db3c4d77 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.vaultLH.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.skyflow.vaultLH.core.ObjectMappers; + +import java.util.*; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Upsert.Builder.class) +public final class Upsert { + private final Optional updateType; + + private final Optional> uniqueColumns; + + private final Map additionalProperties; + + private Upsert( + Optional updateType, + Optional> uniqueColumns, + Map additionalProperties) { + this.updateType = updateType; + this.uniqueColumns = uniqueColumns; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("updateType") + public Optional getUpdateType() { + return updateType; + } + + /** + * @return Name of a unique columns in the table. Uses upsert operations to check if a record exists based on the unique column's value. If a matching record exists, the record updates with the values you provide. If a matching record doesn't exist, the upsert operation inserts a new record. + */ + @JsonProperty("uniqueColumns") + public Optional> getUniqueColumns() { + return uniqueColumns; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Upsert && equalTo((Upsert) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Upsert other) { + return updateType.equals(other.updateType) && uniqueColumns.equals(other.uniqueColumns); + } + + @Override + public int hashCode() { + return Objects.hash(this.updateType, this.uniqueColumns); + } + + @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 updateType = Optional.empty(); + + private Optional> uniqueColumns = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Upsert other) { + updateType(other.getUpdateType()); + uniqueColumns(other.getUniqueColumns()); + return this; + } + + @JsonSetter(value = "updateType", nulls = Nulls.SKIP) + public Builder updateType(Optional updateType) { + this.updateType = updateType; + return this; + } + + public Builder updateType(EnumUpdateType updateType) { + this.updateType = Optional.ofNullable(updateType); + return this; + } + + /** + *

Name of a unique columns in the table. Uses upsert operations to check if a record exists based on the unique column's value. If a matching record exists, the record updates with the values you provide. If a matching record doesn't exist, the upsert operation inserts a new record.

+ */ + @JsonSetter(value = "uniqueColumns", nulls = Nulls.SKIP) + public Builder uniqueColumns(Optional> uniqueColumns) { + this.uniqueColumns = uniqueColumns; + return this; + } + + public Builder uniqueColumns(List uniqueColumns) { + this.uniqueColumns = Optional.ofNullable(uniqueColumns); + return this; + } + + public Upsert build() { + return new Upsert(updateType, uniqueColumns, additionalProperties); + } + } +} From 19dbe0c96ebb24237825b10f51b4c8f661c9affc Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Thu, 14 Aug 2025 22:14:44 +0530 Subject: [PATCH 02/97] SK-2237 Refactored code based on multi-module strategy --- common/pom.xml | 2 +- .../com/skyflow/common/ApiClientBuilder.java | 67 - .../skyflow/common/AsyncApiClientBuilder.java | 67 - .../common/core/ApiClientApiException.java | 73 - .../common/core/ApiClientHttpResponse.java | 37 - .../common/core/DateTimeDeserializer.java | 55 - .../com/skyflow/common/core/FileStream.java | 60 - .../common/core/InputStreamRequestBody.java | 79 - .../com/skyflow/common/core/MediaTypes.java | 13 - .../com/skyflow/common/core/Nullable.java | 140 -- .../skyflow/common/core/ObjectMappers.java | 36 - .../common/core/QueryStringMapper.java | 142 -- .../skyflow/common/core/RequestOptions.java | 101 -- .../common/core/ResponseBodyInputStream.java | 45 - .../common/core/ResponseBodyReader.java | 44 - .../skyflow/common/core/RetryInterceptor.java | 78 - .../com/skyflow/common/core/Suppliers.java | 23 - .../com/skyflow/common/enums/LogLevel.java | 9 - .../com/skyflow/common/errors/ErrorCode.java | 18 - .../skyflow/common/errors/ErrorMessage.java | 162 -- .../com/skyflow/common/errors/HttpStatus.java | 15 - .../common/errors/SkyflowException.java | 135 -- .../com/skyflow/common/logs/ErrorLogs.java | 140 -- .../com/skyflow/common/logs/InfoLogs.java | 105 -- .../AsyncAuthenticationClient.java | 45 - .../AsyncRawAuthenticationClient.java | 131 -- .../authentication/AuthenticationClient.java | 44 - .../RawAuthenticationClient.java | 110 -- .../requests/V1GetAuthTokenRequest.java | 335 ---- .../serviceaccount/util/BearerToken.java | 229 --- .../util/SignedDataTokenResponse.java | 29 - .../serviceaccount/util/SignedDataTokens.java | 213 --- .../common/serviceaccount/util/Token.java | 46 - .../skyflow/common/types/GooglerpcStatus.java | 144 -- .../com/skyflow/common/types/ProtobufAny.java | 95 - .../common/types/V1GetAuthTokenResponse.java | 130 -- .../com/skyflow/common/utils/Constants.java | 31 - .../skyflow/common/utils/logger/LogUtil.java | 100 -- .../java/com/skyflow/config/Credentials.java | 0 .../java/com/skyflow/config/VaultConfig.java | 0 .../src}/main/java/com/skyflow/enums/Env.java | 0 .../java/com/skyflow/enums/InterfaceName.java | 0 .../main/java/com/skyflow/enums/LogLevel.java | 0 .../java/com/skyflow/errors/ErrorCode.java | 0 .../java/com/skyflow/errors/ErrorMessage.java | 6 +- .../java/com/skyflow/errors/HttpStatus.java | 0 .../com/skyflow/errors/SkyflowException.java | 6 +- .../{common => generated/rest}/ApiClient.java | 8 +- .../generated/rest/ApiClientBuilder.java | 0 .../rest}/AsyncApiClient.java | 8 +- .../generated/rest/AsyncApiClientBuilder.java | 0 .../rest/core/ApiClientApiException.java | 0 .../rest/core/ApiClientException.java | 0 .../rest/core/ApiClientHttpResponse.java | 0 .../rest}/core/ClientOptions.java | 4 +- .../rest/core/DateTimeDeserializer.java | 0 .../rest}/core/Environment.java | 2 +- .../generated/rest/core/FileStream.java | 0 .../rest/core/InputStreamRequestBody.java | 0 .../generated/rest/core/MediaTypes.java | 0 .../skyflow/generated/rest/core/Nullable.java | 0 .../rest/core/NullableNonemptyFilter.java | 0 .../generated/rest/core/ObjectMappers.java | 0 .../rest/core/QueryStringMapper.java | 0 .../generated/rest/core/RequestOptions.java | 0 .../rest/core/ResponseBodyInputStream.java | 0 .../rest/core/ResponseBodyReader.java | 0 .../generated/rest/core/RetryInterceptor.java | 0 .../skyflow/generated/rest/core/Stream.java | 0 .../generated/rest/core/Suppliers.java | 0 .../rest}/errors/BadRequestError.java | 4 +- .../generated/rest}/errors/HttpStatus.java | 2 +- .../rest}/errors/NotFoundError.java | 4 +- .../rest}/errors/UnauthorizedError.java | 4 +- .../AsyncAuthenticationClient.java | 0 .../AsyncRawAuthenticationClient.java | 11 +- .../authentication/AuthenticationClient.java | 0 .../RawAuthenticationClient.java | 14 +- .../requests/V1GetAuthTokenRequest.java | 0 .../generated/rest/types/GooglerpcStatus.java | 0 .../generated/rest/types/ProtobufAny.java | 0 .../rest/types/V1GetAuthTokenResponse.java | 0 .../main/java/com/skyflow/logs/ErrorLogs.java | 0 .../main/java/com/skyflow/logs/InfoLogs.java | 0 .../serviceaccount/util/BearerToken.java | 19 +- .../util/SignedDataTokenResponse.java | 4 +- .../serviceaccount/util/SignedDataTokens.java | 13 +- .../skyflow/serviceaccount/util/Token.java | 0 .../java/com/skyflow/utils/BaseConstants.java | 17 +- .../utils/Utils.java => utils/BaseUtils.java} | 63 +- .../java/com/skyflow/utils/SdkVersion.java | 13 + .../com/skyflow/utils/logger/LogUtil.java | 6 +- .../utils/validations/BaseValidations.java | 108 ++ .../test/java/com/skyflow/api/TestClient.java | 11 - .../api/core/QueryStringMapperTest.java | 341 ---- .../com/skyflow/config/CredentialsTests.java | 34 +- .../com/skyflow/config/VaultConfigTests.java | 18 +- .../skyflow/errors/SkyflowExceptionTest.java | 10 +- .../serviceaccount/util/BearerTokenTests.java | 8 +- .../util/SignedDataTokensTests.java | 12 +- .../serviceaccount/util/TokenTests.java | 10 +- .../invalidPrivateKeyCredentials.json | 0 .../resources/invalidTokenURICredentials.json | 0 .../test/resources/noClientIDCredentials.json | 0 .../test/resources/noKeyIDCredentials.json | 0 .../resources/noPrivateKeyCredentials.json | 0 .../test/resources/noTokenURICredentials.json | 0 .../src}/test/resources/notJson.txt | 0 pom.xml | 6 - src/main/java/com/skyflow/Skyflow.java | 307 ---- src/main/java/com/skyflow/VaultClient.java | 819 --------- .../com/skyflow/config/ConnectionConfig.java | 38 - .../com/skyflow/config/ManagementConfig.java | 11 - .../skyflow/enums/DeidentifyFileStatus.java | 16 - .../com/skyflow/enums/DetectEntities.java | 83 - .../enums/DetectOutputTranscriptions.java | 24 - .../java/com/skyflow/enums/MaskingMethod.java | 21 - .../java/com/skyflow/enums/RedactionType.java | 26 - .../java/com/skyflow/enums/RequestMethod.java | 22 - .../java/com/skyflow/enums/TokenMode.java | 24 - .../java/com/skyflow/enums/TokenType.java | 27 - .../java/com/skyflow/errors/ErrorMessage.java | 162 -- .../com/skyflow/generated/rest/ApiClient.java | 92 - .../generated/rest/AsyncApiClient.java | 92 - .../generated/rest/core/ClientOptions.java | 170 -- .../generated/rest/core/Environment.java | 24 - .../rest/core/QueryStringMapperTest.java | 339 ---- .../rest/errors/BadRequestError.java | 32 - .../rest/errors/InternalServerError.java | 33 - .../generated/rest/errors/NotFoundError.java | 32 - .../rest/errors/UnauthorizedError.java | 32 - .../resources/audit/AsyncAuditClient.java | 45 - .../resources/audit/AsyncRawAuditClient.java | 296 --- .../rest/resources/audit/AuditClient.java | 44 - .../rest/resources/audit/RawAuditClient.java | 277 --- .../AuditServiceListAuditEventsRequest.java | 1589 ----------------- ...AuditEventsRequestFilterOpsActionType.java | 56 - ...entsRequestFilterOpsContextAccessType.java | 28 - ...ventsRequestFilterOpsContextActorType.java | 26 - ...EventsRequestFilterOpsContextAuthMode.java | 28 - ...ditEventsRequestFilterOpsResourceType.java | 80 - ...eListAuditEventsRequestSortOpsOrderBy.java | 24 - .../binlookup/AsyncBinLookupClient.java | 52 - .../binlookup/AsyncRawBinLookupClient.java | 118 -- .../resources/binlookup/BinLookupClient.java | 50 - .../binlookup/RawBinLookupClient.java | 98 - .../binlookup/requests/V1BinListRequest.java | 189 -- .../deprecated/AsyncDeprecatedClient.java | 89 - .../deprecated/AsyncRawDeprecatedClient.java | 271 --- .../deprecated/DeprecatedClient.java | 87 - .../deprecated/RawDeprecatedClient.java | 222 --- .../DetectServiceDetectStatusRequest.java | 101 -- .../DetectServiceDetectTextRequest.java | 526 ------ .../requests/V1DetectFileRequest.java | 634 ------- .../resources/files/AsyncFilesClient.java | 188 -- .../resources/files/AsyncRawFilesClient.java | 929 ---------- .../rest/resources/files/FilesClient.java | 180 -- .../rest/resources/files/RawFilesClient.java | 714 -------- .../requests/DeidentifyAudioRequest.java | 582 ------ .../requests/DeidentifyDocumentRequest.java | 310 ---- .../files/requests/DeidentifyFileRequest.java | 310 ---- .../requests/DeidentifyImageRequest.java | 446 ----- .../files/requests/DeidentifyPdfRequest.java | 400 ----- .../DeidentifyPresentationRequest.java | 310 ---- .../DeidentifySpreadsheetRequest.java | 310 ---- .../DeidentifyStructuredTextRequest.java | 310 ---- .../files/requests/DeidentifyTextRequest.java | 310 ---- .../files/requests/GetRunRequest.java | 112 -- .../types/DeidentifyAudioRequestFile.java | 145 -- .../DeidentifyAudioRequestFileDataFormat.java | 24 - ...entifyAudioRequestOutputTranscription.java | 30 - .../types/DeidentifyDocumentRequestFile.java | 147 -- ...identifyDocumentRequestFileDataFormat.java | 26 - .../types/DeidentifyFileRequestFile.java | 145 -- .../DeidentifyFileRequestFileDataFormat.java | 58 - .../types/DeidentifyImageRequestFile.java | 145 -- .../DeidentifyImageRequestFileDataFormat.java | 32 - .../DeidentifyImageRequestMaskingMethod.java | 24 - .../files/types/DeidentifyPdfRequestFile.java | 120 -- .../DeidentifyPresentationRequestFile.java | 147 -- ...tifyPresentationRequestFileDataFormat.java | 24 - .../DeidentifySpreadsheetRequestFile.java | 147 -- ...ntifySpreadsheetRequestFileDataFormat.java | 26 - .../DeidentifyStructuredTextRequestFile.java | 148 -- ...fyStructuredTextRequestFileDataFormat.java | 24 - .../types/DeidentifyTextRequestFile.java | 120 -- .../resources/query/AsyncQueryClient.java | 53 - .../resources/query/AsyncRawQueryClient.java | 121 -- .../rest/resources/query/QueryClient.java | 51 - .../rest/resources/query/RawQueryClient.java | 102 -- .../QueryServiceExecuteQueryBody.java | 101 -- .../records/AsyncRawRecordsClient.java | 956 ---------- .../resources/records/AsyncRecordsClient.java | 317 ---- .../resources/records/RawRecordsClient.java | 800 --------- .../rest/resources/records/RecordsClient.java | 312 ---- .../FileServiceUploadFileRequest.java | 59 - .../RecordServiceBatchOperationBody.java | 160 -- .../RecordServiceBulkDeleteRecordBody.java | 103 -- .../RecordServiceBulkGetRecordRequest.java | 413 ----- .../RecordServiceGetRecordRequest.java | 202 --- .../RecordServiceInsertRecordBody.java | 221 --- .../RecordServiceUpdateRecordBody.java | 151 -- ...ordServiceBulkGetRecordRequestOrderBy.java | 26 - ...dServiceBulkGetRecordRequestRedaction.java | 28 - ...ecordServiceGetRecordRequestRedaction.java | 28 - .../strings/AsyncRawStringsClient.java | 217 --- .../resources/strings/AsyncStringsClient.java | 60 - .../resources/strings/RawStringsClient.java | 171 -- .../rest/resources/strings/StringsClient.java | 57 - .../requests/DeidentifyStringRequest.java | 309 ---- .../requests/ReidentifyStringRequest.java | 192 -- .../types/ReidentifyStringRequestFormat.java | 163 -- .../tokens/AsyncRawTokensClient.java | 206 --- .../resources/tokens/AsyncTokensClient.java | 79 - .../resources/tokens/RawTokensClient.java | 172 -- .../rest/resources/tokens/TokensClient.java | 77 - .../tokens/requests/V1DetokenizePayload.java | 166 -- .../tokens/requests/V1TokenizePayload.java | 104 -- .../types/AdvancedOptionsColumnMapping.java | 194 -- .../types/AdvancedOptionsEntityColumnMap.java | 126 -- .../types/AdvancedOptionsVaultSchema.java | 135 -- .../types/AudioConfigTranscriptionType.java | 40 - .../types/AuditEventAuditResourceType.java | 80 - .../rest/types/AuditEventContext.java | 440 ----- .../generated/rest/types/AuditEventData.java | 101 -- .../rest/types/AuditEventHttpInfo.java | 130 -- .../rest/types/BatchRecordMethod.java | 30 - .../rest/types/ContextAccessType.java | 26 - .../generated/rest/types/ContextAuthMode.java | 28 - .../rest/types/DeidentifyFileOutput.java | 164 -- ...DeidentifyFileOutputProcessedFileType.java | 40 - .../rest/types/DeidentifyFileResponse.java | 112 -- .../rest/types/DeidentifyStatusResponse.java | 521 ------ .../DeidentifyStatusResponseOutputType.java | 26 - .../types/DeidentifyStatusResponseStatus.java | 26 - .../rest/types/DeidentifyStringResponse.java | 242 --- .../rest/types/DetectDataAccuracy.java | 36 - .../rest/types/DetectDataEntities.java | 146 -- .../rest/types/DetectFileRequestDataType.java | 24 - .../types/DetectRequestDeidentifyOption.java | 26 - .../generated/rest/types/DetectedEntity.java | 217 --- .../DetokenizeRecordResponseValueType.java | 38 - .../generated/rest/types/EntityLocation.java | 194 -- .../generated/rest/types/EntityType.java | 146 -- .../generated/rest/types/ErrorResponse.java | 102 -- .../rest/types/ErrorResponseError.java | 240 --- .../ProcessedFileOutputProcessedFileType.java | 40 - .../rest/types/RedactionEnumRedaction.java | 28 - .../rest/types/ReidentifyStringResponse.java | 101 -- .../rest/types/RequestActionType.java | 56 - .../generated/rest/types/TokenType.java | 188 -- .../rest/types/TokenTypeDefault.java | 26 - .../rest/types/TokenTypeWithoutVault.java | 158 -- .../types/TokenTypeWithoutVaultDefault.java | 24 - .../generated/rest/types/Transformations.java | 101 -- .../rest/types/TransformationsShiftDates.java | 162 -- ...nsformationsShiftDatesEntityTypesItem.java | 26 - .../rest/types/V1AdvancedOptions.java | 157 -- .../generated/rest/types/V1AudioConfig.java | 151 -- .../generated/rest/types/V1AudioOptions.java | 234 --- .../rest/types/V1AuditAfterOptions.java | 130 -- .../rest/types/V1AuditEventResponse.java | 187 -- .../generated/rest/types/V1AuditResponse.java | 127 -- .../rest/types/V1AuditResponseEvent.java | 238 --- .../types/V1AuditResponseEventRequest.java | 339 ---- .../rest/types/V1BatchOperationResponse.java | 133 -- .../generated/rest/types/V1BatchRecord.java | 382 ---- .../rest/types/V1BinListResponse.java | 102 -- .../types/V1BulkDeleteRecordResponse.java | 103 -- .../rest/types/V1BulkGetRecordResponse.java | 102 -- .../skyflow/generated/rest/types/V1Byot.java | 26 - .../skyflow/generated/rest/types/V1Card.java | 362 ---- .../rest/types/V1DeleteFileResponse.java | 130 -- .../rest/types/V1DeleteRecordResponse.java | 130 -- .../rest/types/V1DetectFileResponse.java | 101 -- .../rest/types/V1DetectStatusResponse.java | 156 -- .../types/V1DetectStatusResponseStatus.java | 28 - .../rest/types/V1DetectTextRequest.java | 522 ------ .../rest/types/V1DetectTextResponse.java | 133 -- .../rest/types/V1DetokenizeRecordRequest.java | 126 -- .../types/V1DetokenizeRecordResponse.java | 187 -- .../rest/types/V1DetokenizeResponse.java | 103 -- .../generated/rest/types/V1FieldRecords.java | 132 -- .../rest/types/V1FileAvScanStatus.java | 38 - .../rest/types/V1FileDataFormat.java | 58 - .../types/V1GetFileScanStatusResponse.java | 96 - .../rest/types/V1GetQueryResponse.java | 102 -- .../generated/rest/types/V1ImageOptions.java | 132 -- .../rest/types/V1InsertRecordResponse.java | 103 -- .../generated/rest/types/V1Locations.java | 193 -- .../generated/rest/types/V1MemberType.java | 26 - .../generated/rest/types/V1PdfConfig.java | 95 - .../generated/rest/types/V1PdfOptions.java | 130 -- .../rest/types/V1ProcessedFileOutput.java | 151 -- .../rest/types/V1RecordMetaProperties.java | 132 -- .../rest/types/V1ResponseEntities.java | 218 --- .../rest/types/V1TokenizeRecordRequest.java | 130 -- .../rest/types/V1TokenizeRecordResponse.java | 101 -- .../rest/types/V1TokenizeResponse.java | 103 -- .../rest/types/V1UpdateRecordResponse.java | 132 -- .../rest/types/V1VaultFieldMapping.java | 163 -- .../rest/types/V1VaultSchemaConfig.java | 155 -- .../java/com/skyflow/utils/HttpUtility.java | 165 -- src/main/java/com/skyflow/utils/Utils.java | 202 --- .../utils/validations/Validations.java | 892 --------- .../skyflow/vault/audit/ListEventRequest.java | 11 - .../vault/audit/ListEventResponse.java | 10 - .../com/skyflow/vault/bin/GetBinRequest.java | 10 - .../com/skyflow/vault/bin/GetBinResponse.java | 10 - .../connection/InvokeConnectionRequest.java | 82 - .../connection/InvokeConnectionResponse.java | 30 - .../vault/controller/AuditController.java | 18 - .../vault/controller/BinLookupController.java | 16 - .../controller/ConnectionController.java | 91 - .../vault/controller/DetectController.java | 375 ---- .../vault/controller/VaultController.java | 362 ---- .../com/skyflow/vault/data/DeleteRequest.java | 45 - .../skyflow/vault/data/DeleteResponse.java | 27 - .../com/skyflow/vault/data/GetRequest.java | 140 -- .../com/skyflow/vault/data/GetResponse.java | 30 - .../com/skyflow/vault/data/InsertRequest.java | 111 -- .../skyflow/vault/data/InsertResponse.java | 30 - .../com/skyflow/vault/data/QueryRequest.java | 33 - .../com/skyflow/vault/data/QueryResponse.java | 32 - .../com/skyflow/vault/data/UpdateRequest.java | 79 - .../skyflow/vault/data/UpdateResponse.java | 40 - .../com/skyflow/vault/detect/AudioBleep.java | 64 - .../vault/detect/DateTransformation.java | 30 - .../vault/detect/DeidentifyFileRequest.java | 192 -- .../vault/detect/DeidentifyFileResponse.java | 112 -- .../vault/detect/DeidentifyTextRequest.java | 88 - .../vault/detect/DeidentifyTextResponse.java | 44 - .../com/skyflow/vault/detect/EntityInfo.java | 46 - .../skyflow/vault/detect/FileEntityInfo.java | 19 - .../com/skyflow/vault/detect/FileInfo.java | 33 - .../com/skyflow/vault/detect/FileInput.java | 46 - .../vault/detect/GetDetectRunRequest.java | 33 - .../vault/detect/ReidentifyTextRequest.java | 68 - .../vault/detect/ReidentifyTextResponse.java | 23 - .../com/skyflow/vault/detect/TextIndex.java | 29 - .../com/skyflow/vault/detect/TokenFormat.java | 71 - .../skyflow/vault/detect/Transformations.java | 14 - .../com/skyflow/vault/tokens/ColumnValue.java | 45 - .../skyflow/vault/tokens/DetokenizeData.java | 26 - .../tokens/DetokenizeRecordResponse.java | 54 - .../vault/tokens/DetokenizeRequest.java | 57 - .../vault/tokens/DetokenizeResponse.java | 29 - .../skyflow/vault/tokens/TokenizeRequest.java | 35 - .../vault/tokens/TokenizeResponse.java | 33 - v2/pom.xml | 27 +- .../com/example/ConcurrentBatchProcessor.java | 120 ++ .../java/com/skyflow/ConnectionClient.java | 4 +- v2/src/main/java/com/skyflow/VaultClient.java | 20 +- .../java/com/skyflow/config/Credentials.java | 66 - .../com/skyflow/config/ManagementConfig.java | 11 - .../java/com/skyflow/config/VaultConfig.java | 49 - v2/src/main/java/com/skyflow/enums/Env.java | 8 - .../java/com/skyflow/enums/InterfaceName.java | 24 - .../main/java/com/skyflow/enums/LogLevel.java | 9 - .../java/com/skyflow/errors/ErrorCode.java | 18 - .../com/skyflow/errors/SkyflowException.java | 135 -- .../java/com/skyflow/utils/Constants.java | 26 +- v2/src/main/java/com/skyflow/utils/Utils.java | 109 +- .../utils/validations/Validations.java | 111 +- .../skyflow/vault/audit/ListEventRequest.java | 11 - .../vault/audit/ListEventResponse.java | 10 - .../com/skyflow/vault/bin/GetBinRequest.java | 10 - .../com/skyflow/vault/bin/GetBinResponse.java | 10 - .../vault/controller/AuditController.java | 18 - .../vault/controller/BinLookupController.java | 16 - .../controller/ConnectionController.java | 2 - .../vault/controller/DetectController.java | 2 +- .../com/skyflow/ConnectionClientTests.java | 0 .../test/java/com/skyflow/SkyflowTests.java | 0 .../java/com/skyflow/VaultClientTests.java | 1 + .../skyflow/config/ConnectionConfigTests.java | 0 .../com/skyflow/utils/HttpUtilityTests.java | 0 .../java/com/skyflow/utils/UtilsTests.java | 48 +- .../connection/InvokeConnectionTests.java | 0 .../controller/ConnectionControllerTests.java | 0 .../controller/DetectControllerFileTests.java | 0 .../controller/DetectControllerTests.java | 0 .../controller/VaultControllerTests.java | 0 .../com/skyflow/vault/data/DeleteTests.java | 0 .../java/com/skyflow/vault/data/GetTests.java | 0 .../com/skyflow/vault/data/InsertTests.java | 0 .../com/skyflow/vault/data/QueryTests.java | 0 .../com/skyflow/vault/data/UpdateTests.java | 0 .../detect/DeidentifyFileRequestTest.java | 0 .../detect/DeidentifyFileResponseTest.java | 0 .../vault/detect/DeidentifyTextTests.java | 0 .../vault/detect/FileEntityInfoTest.java | 0 .../skyflow/vault/detect/FileInfoTest.java | 0 .../vault/detect/ReidentifyTextTests.java | 0 .../skyflow/vault/tokens/DetokenizeTests.java | 0 .../skyflow/vault/tokens/TokenizeTests.java | 0 v2/v2.iml | 9 + v3/pom.xml | 29 +- v3/src/main/java/com/skyflow/Skyflow.java | 150 ++ .../main/java/com/skyflow/VaultClient.java | 52 +- .../rest}/ApiClient.java | 8 +- .../rest}/ApiClientBuilder.java | 6 +- .../rest}/AsyncApiClient.java | 8 +- .../rest}/AsyncApiClientBuilder.java | 6 +- .../rest}/core/ApiClientApiException.java | 2 +- .../rest}/core/ApiClientException.java | 2 +- .../rest}/core/ApiClientHttpResponse.java | 2 +- .../rest}/core/ClientOptions.java | 2 +- .../rest}/core/DateTimeDeserializer.java | 2 +- .../rest}/core/Environment.java | 2 +- .../rest}/core/FileStream.java | 2 +- .../rest}/core/InputStreamRequestBody.java | 2 +- .../rest}/core/MediaTypes.java | 2 +- .../rest}/core/Nullable.java | 2 +- .../rest}/core/NullableNonemptyFilter.java | 2 +- .../rest}/core/ObjectMappers.java | 2 +- .../rest}/core/QueryStringMapper.java | 2 +- .../rest}/core/RequestOptions.java | 2 +- .../rest}/core/ResponseBodyInputStream.java | 2 +- .../rest}/core/ResponseBodyReader.java | 2 +- .../rest}/core/RetryInterceptor.java | 2 +- .../skyflow/generated/rest}/core/Stream.java | 2 +- .../rest}/core/Suppliers.java | 2 +- .../AsyncRawRecordserviceClient.java | 8 +- .../AsyncRecordserviceClient.java | 10 +- .../recordservice/RawRecordserviceClient.java | 8 +- .../recordservice/RecordserviceClient.java | 10 +- .../recordservice/requests/DeleteRequest.java | 4 +- .../requests/DeleteTokenRequest.java | 4 +- .../requests/DetokenizeRequest.java | 6 +- .../requests/ExecuteQueryRequest.java | 4 +- .../recordservice/requests/GetRequest.java | 6 +- .../recordservice/requests/InsertRequest.java | 8 +- .../requests/TokenizeRequest.java | 6 +- .../recordservice/requests/UpdateRequest.java | 8 +- .../rest}/types/ColumnRedactions.java | 4 +- .../rest}/types/DeleteResponse.java | 4 +- .../rest}/types/DeleteResponseObject.java | 4 +- .../rest}/types/DeleteTokenResponse.java | 4 +- .../types/DeleteTokenResponseObject.java | 4 +- .../rest}/types/DetokenizeResponse.java | 4 +- .../rest}/types/DetokenizeResponseObject.java | 4 +- .../rest}/types/EnumDataType.java | 2 +- .../rest}/types/EnumUpdateType.java | 2 +- .../types/ExecuteQueryRecordResponse.java | 4 +- .../rest}/types/ExecuteQueryResponse.java | 4 +- .../rest}/types/GetResponse.java | 4 +- .../rest}/types/InsertRecordData.java | 4 +- .../rest}/types/InsertResponse.java | 4 +- .../rest}/types/ProtobufAny.java | 4 +- .../rest}/types/RecordResponseObject.java | 4 +- .../rest}/types/RpcStatus.java | 4 +- .../rest}/types/TokenGroupRedactions.java | 4 +- .../rest}/types/TokenizeRequestObject.java | 4 +- .../rest}/types/TokenizeResponse.java | 4 +- .../rest}/types/TokenizeResponseObject.java | 4 +- .../types/TokenizeResponseObjectToken.java | 4 +- .../rest}/types/UpdateRecordData.java | 4 +- .../rest}/types/UpdateResponse.java | 4 +- .../rest}/types/Upsert.java | 4 +- .../java/com/skyflow/utils/Constants.java | 7 + v3/src/main/java/com/skyflow/utils/Utils.java | 56 + .../utils/validations/Validations.java | 9 + .../vault/controller/VaultController.java | 17 + .../vaultLH/core/ApiClientException.java | 17 - .../vaultLH/core/NullableNonemptyFilter.java | 19 - .../java/com/skyflow/vaultLH/core/Stream.java | 97 - 467 files changed, 854 insertions(+), 40638 deletions(-) delete mode 100644 common/src/main/java/com/skyflow/common/ApiClientBuilder.java delete mode 100644 common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java delete mode 100644 common/src/main/java/com/skyflow/common/core/ApiClientApiException.java delete mode 100644 common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java delete mode 100644 common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java delete mode 100644 common/src/main/java/com/skyflow/common/core/FileStream.java delete mode 100644 common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java delete mode 100644 common/src/main/java/com/skyflow/common/core/MediaTypes.java delete mode 100644 common/src/main/java/com/skyflow/common/core/Nullable.java delete mode 100644 common/src/main/java/com/skyflow/common/core/ObjectMappers.java delete mode 100644 common/src/main/java/com/skyflow/common/core/QueryStringMapper.java delete mode 100644 common/src/main/java/com/skyflow/common/core/RequestOptions.java delete mode 100644 common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java delete mode 100644 common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java delete mode 100644 common/src/main/java/com/skyflow/common/core/RetryInterceptor.java delete mode 100644 common/src/main/java/com/skyflow/common/core/Suppliers.java delete mode 100644 common/src/main/java/com/skyflow/common/enums/LogLevel.java delete mode 100644 common/src/main/java/com/skyflow/common/errors/ErrorCode.java delete mode 100644 common/src/main/java/com/skyflow/common/errors/ErrorMessage.java delete mode 100644 common/src/main/java/com/skyflow/common/errors/HttpStatus.java delete mode 100644 common/src/main/java/com/skyflow/common/errors/SkyflowException.java delete mode 100644 common/src/main/java/com/skyflow/common/logs/ErrorLogs.java delete mode 100644 common/src/main/java/com/skyflow/common/logs/InfoLogs.java delete mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java delete mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java delete mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java delete mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java delete mode 100644 common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java delete mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java delete mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java delete mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java delete mode 100644 common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java delete mode 100644 common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java delete mode 100644 common/src/main/java/com/skyflow/common/types/ProtobufAny.java delete mode 100644 common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java delete mode 100644 common/src/main/java/com/skyflow/common/utils/Constants.java delete mode 100644 common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java rename {src => common/src}/main/java/com/skyflow/config/Credentials.java (100%) rename {src => common/src}/main/java/com/skyflow/config/VaultConfig.java (100%) rename {src => common/src}/main/java/com/skyflow/enums/Env.java (100%) rename {src => common/src}/main/java/com/skyflow/enums/InterfaceName.java (100%) rename {src => common/src}/main/java/com/skyflow/enums/LogLevel.java (100%) rename {src => common/src}/main/java/com/skyflow/errors/ErrorCode.java (100%) rename {v2 => common}/src/main/java/com/skyflow/errors/ErrorMessage.java (98%) rename {src => common/src}/main/java/com/skyflow/errors/HttpStatus.java (100%) rename {src => common/src}/main/java/com/skyflow/errors/SkyflowException.java (96%) rename common/src/main/java/com/skyflow/{common => generated/rest}/ApiClient.java (75%) rename {src => common/src}/main/java/com/skyflow/generated/rest/ApiClientBuilder.java (100%) rename common/src/main/java/com/skyflow/{common => generated/rest}/AsyncApiClient.java (75%) rename {src => common/src}/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/ApiClientException.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java (100%) rename common/src/main/java/com/skyflow/{common => generated/rest}/core/ClientOptions.java (97%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java (100%) rename common/src/main/java/com/skyflow/{common => generated/rest}/core/Environment.java (93%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/FileStream.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/MediaTypes.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/Nullable.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/ObjectMappers.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/RequestOptions.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/Stream.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/core/Suppliers.java (100%) rename common/src/main/java/com/skyflow/{common => generated/rest}/errors/BadRequestError.java (87%) rename {v2/src/main/java/com/skyflow => common/src/main/java/com/skyflow/generated/rest}/errors/HttpStatus.java (85%) rename common/src/main/java/com/skyflow/{common => generated/rest}/errors/NotFoundError.java (87%) rename common/src/main/java/com/skyflow/{common => generated/rest}/errors/UnauthorizedError.java (87%) rename {src => common/src}/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java (93%) rename {src => common/src}/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java (90%) rename {src => common/src}/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/types/ProtobufAny.java (100%) rename {src => common/src}/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java (100%) rename {src => common/src}/main/java/com/skyflow/logs/ErrorLogs.java (100%) rename {src => common/src}/main/java/com/skyflow/logs/InfoLogs.java (100%) rename {src => common/src}/main/java/com/skyflow/serviceaccount/util/BearerToken.java (94%) rename {src => common/src}/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java (83%) rename {src => common/src}/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java (96%) rename {src => common/src}/main/java/com/skyflow/serviceaccount/util/Token.java (100%) rename src/main/java/com/skyflow/utils/Constants.java => common/src/main/java/com/skyflow/utils/BaseConstants.java (85%) rename common/src/main/java/com/skyflow/{common/utils/Utils.java => utils/BaseUtils.java} (55%) create mode 100644 common/src/main/java/com/skyflow/utils/SdkVersion.java rename {src => common/src}/main/java/com/skyflow/utils/logger/LogUtil.java (96%) create mode 100644 common/src/main/java/com/skyflow/utils/validations/BaseValidations.java delete mode 100644 common/src/test/java/com/skyflow/api/TestClient.java delete mode 100644 common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java rename {src => common/src}/test/java/com/skyflow/config/CredentialsTests.java (89%) rename {src => common/src}/test/java/com/skyflow/config/VaultConfigTests.java (91%) rename {src => common/src}/test/java/com/skyflow/errors/SkyflowExceptionTest.java (91%) rename {src => common/src}/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java (96%) rename {src => common/src}/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java (93%) rename {src => common/src}/test/java/com/skyflow/serviceaccount/util/TokenTests.java (87%) rename {src => common/src}/test/resources/invalidPrivateKeyCredentials.json (100%) rename {src => common/src}/test/resources/invalidTokenURICredentials.json (100%) rename {src => common/src}/test/resources/noClientIDCredentials.json (100%) rename {src => common/src}/test/resources/noKeyIDCredentials.json (100%) rename {src => common/src}/test/resources/noPrivateKeyCredentials.json (100%) rename {src => common/src}/test/resources/noTokenURICredentials.json (100%) rename {src => common/src}/test/resources/notJson.txt (100%) delete mode 100644 src/main/java/com/skyflow/Skyflow.java delete mode 100644 src/main/java/com/skyflow/VaultClient.java delete mode 100644 src/main/java/com/skyflow/config/ConnectionConfig.java delete mode 100644 src/main/java/com/skyflow/config/ManagementConfig.java delete mode 100644 src/main/java/com/skyflow/enums/DeidentifyFileStatus.java delete mode 100644 src/main/java/com/skyflow/enums/DetectEntities.java delete mode 100644 src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java delete mode 100644 src/main/java/com/skyflow/enums/MaskingMethod.java delete mode 100644 src/main/java/com/skyflow/enums/RedactionType.java delete mode 100644 src/main/java/com/skyflow/enums/RequestMethod.java delete mode 100644 src/main/java/com/skyflow/enums/TokenMode.java delete mode 100644 src/main/java/com/skyflow/enums/TokenType.java delete mode 100644 src/main/java/com/skyflow/errors/ErrorMessage.java delete mode 100644 src/main/java/com/skyflow/generated/rest/ApiClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/AsyncApiClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/core/ClientOptions.java delete mode 100644 src/main/java/com/skyflow/generated/rest/core/Environment.java delete mode 100644 src/main/java/com/skyflow/generated/rest/core/QueryStringMapperTest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java delete mode 100644 src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java delete mode 100644 src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java delete mode 100644 src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncDeprecatedClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/AsyncRawDeprecatedClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/DeprecatedClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/RawDeprecatedClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectStatusRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/DetectServiceDetectTextRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/deprecated/requests/V1DetectFileRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java delete mode 100644 src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsColumnMapping.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsEntityColumnMap.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AdvancedOptionsVaultSchema.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AudioConfigTranscriptionType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AuditEventData.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DetectDataAccuracy.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DetectDataEntities.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/EntityLocation.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/EntityType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/ProcessedFileOutputProcessedFileType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/RequestActionType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/TokenType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/Transformations.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AdvancedOptions.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AudioConfig.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AudioOptions.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1Byot.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1Card.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetectFileResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetectTextRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetectTextResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1ImageOptions.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1Locations.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1MemberType.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1PdfConfig.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1PdfOptions.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1ProcessedFileOutput.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1ResponseEntities.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java delete mode 100644 src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java delete mode 100644 src/main/java/com/skyflow/utils/HttpUtility.java delete mode 100644 src/main/java/com/skyflow/utils/Utils.java delete mode 100644 src/main/java/com/skyflow/utils/validations/Validations.java delete mode 100644 src/main/java/com/skyflow/vault/audit/ListEventRequest.java delete mode 100644 src/main/java/com/skyflow/vault/audit/ListEventResponse.java delete mode 100644 src/main/java/com/skyflow/vault/bin/GetBinRequest.java delete mode 100644 src/main/java/com/skyflow/vault/bin/GetBinResponse.java delete mode 100644 src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java delete mode 100644 src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java delete mode 100644 src/main/java/com/skyflow/vault/controller/AuditController.java delete mode 100644 src/main/java/com/skyflow/vault/controller/BinLookupController.java delete mode 100644 src/main/java/com/skyflow/vault/controller/ConnectionController.java delete mode 100644 src/main/java/com/skyflow/vault/controller/DetectController.java delete mode 100644 src/main/java/com/skyflow/vault/controller/VaultController.java delete mode 100644 src/main/java/com/skyflow/vault/data/DeleteRequest.java delete mode 100644 src/main/java/com/skyflow/vault/data/DeleteResponse.java delete mode 100644 src/main/java/com/skyflow/vault/data/GetRequest.java delete mode 100644 src/main/java/com/skyflow/vault/data/GetResponse.java delete mode 100644 src/main/java/com/skyflow/vault/data/InsertRequest.java delete mode 100644 src/main/java/com/skyflow/vault/data/InsertResponse.java delete mode 100644 src/main/java/com/skyflow/vault/data/QueryRequest.java delete mode 100644 src/main/java/com/skyflow/vault/data/QueryResponse.java delete mode 100644 src/main/java/com/skyflow/vault/data/UpdateRequest.java delete mode 100644 src/main/java/com/skyflow/vault/data/UpdateResponse.java delete mode 100644 src/main/java/com/skyflow/vault/detect/AudioBleep.java delete mode 100644 src/main/java/com/skyflow/vault/detect/DateTransformation.java delete mode 100644 src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java delete mode 100644 src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java delete mode 100644 src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java delete mode 100644 src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java delete mode 100644 src/main/java/com/skyflow/vault/detect/EntityInfo.java delete mode 100644 src/main/java/com/skyflow/vault/detect/FileEntityInfo.java delete mode 100644 src/main/java/com/skyflow/vault/detect/FileInfo.java delete mode 100644 src/main/java/com/skyflow/vault/detect/FileInput.java delete mode 100644 src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java delete mode 100644 src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java delete mode 100644 src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java delete mode 100644 src/main/java/com/skyflow/vault/detect/TextIndex.java delete mode 100644 src/main/java/com/skyflow/vault/detect/TokenFormat.java delete mode 100644 src/main/java/com/skyflow/vault/detect/Transformations.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/ColumnValue.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/DetokenizeData.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java delete mode 100644 src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java create mode 100644 v2/src/main/java/com/example/ConcurrentBatchProcessor.java delete mode 100644 v2/src/main/java/com/skyflow/config/Credentials.java delete mode 100644 v2/src/main/java/com/skyflow/config/ManagementConfig.java delete mode 100644 v2/src/main/java/com/skyflow/config/VaultConfig.java delete mode 100644 v2/src/main/java/com/skyflow/enums/Env.java delete mode 100644 v2/src/main/java/com/skyflow/enums/InterfaceName.java delete mode 100644 v2/src/main/java/com/skyflow/enums/LogLevel.java delete mode 100644 v2/src/main/java/com/skyflow/errors/ErrorCode.java delete mode 100644 v2/src/main/java/com/skyflow/errors/SkyflowException.java delete mode 100644 v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java delete mode 100644 v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java delete mode 100644 v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java delete mode 100644 v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java delete mode 100644 v2/src/main/java/com/skyflow/vault/controller/AuditController.java delete mode 100644 v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java rename {src => v2}/test/java/com/skyflow/ConnectionClientTests.java (100%) rename {src => v2}/test/java/com/skyflow/SkyflowTests.java (100%) rename {src => v2}/test/java/com/skyflow/VaultClientTests.java (99%) rename {src => v2}/test/java/com/skyflow/config/ConnectionConfigTests.java (100%) rename {src => v2}/test/java/com/skyflow/utils/HttpUtilityTests.java (100%) rename {src => v2}/test/java/com/skyflow/utils/UtilsTests.java (83%) rename {src => v2}/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/controller/DetectControllerTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/controller/VaultControllerTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/data/DeleteTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/data/GetTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/data/InsertTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/data/QueryTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/data/UpdateTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/detect/DeidentifyFileRequestTest.java (100%) rename {src => v2}/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java (100%) rename {src => v2}/test/java/com/skyflow/vault/detect/DeidentifyTextTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/detect/FileEntityInfoTest.java (100%) rename {src => v2}/test/java/com/skyflow/vault/detect/FileInfoTest.java (100%) rename {src => v2}/test/java/com/skyflow/vault/detect/ReidentifyTextTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/tokens/DetokenizeTests.java (100%) rename {src => v2}/test/java/com/skyflow/vault/tokens/TokenizeTests.java (100%) create mode 100644 v2/v2.iml create mode 100644 v3/src/main/java/com/skyflow/Skyflow.java rename src/main/java/com/skyflow/ConnectionClient.java => v3/src/main/java/com/skyflow/VaultClient.java (66%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/ApiClient.java (75%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/ApiClientBuilder.java (89%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/AsyncApiClient.java (75%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/AsyncApiClientBuilder.java (89%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/ApiClientApiException.java (97%) rename {common/src/main/java/com/skyflow/common => v3/src/main/java/com/skyflow/generated/rest}/core/ApiClientException.java (90%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/ApiClientHttpResponse.java (95%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/ClientOptions.java (99%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/DateTimeDeserializer.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/Environment.java (89%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/FileStream.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/InputStreamRequestBody.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/MediaTypes.java (86%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/Nullable.java (98%) rename {common/src/main/java/com/skyflow/common => v3/src/main/java/com/skyflow/generated/rest}/core/NullableNonemptyFilter.java (91%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/ObjectMappers.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/QueryStringMapper.java (99%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/RequestOptions.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/ResponseBodyInputStream.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/ResponseBodyReader.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/RetryInterceptor.java (98%) rename {common/src/main/java/com/skyflow/common => v3/src/main/java/com/skyflow/generated/rest}/core/Stream.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/core/Suppliers.java (93%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/AsyncRawRecordserviceClient.java (99%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/AsyncRecordserviceClient.java (94%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/RawRecordserviceClient.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/RecordserviceClient.java (93%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/DeleteRequest.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/DeleteTokenRequest.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/DetokenizeRequest.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/ExecuteQueryRequest.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/GetRequest.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/InsertRequest.java (95%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/TokenizeRequest.java (94%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/resources/recordservice/requests/UpdateRequest.java (95%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/ColumnRedactions.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/DeleteResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/DeleteResponseObject.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/DeleteTokenResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/DeleteTokenResponseObject.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/DetokenizeResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/DetokenizeResponseObject.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/EnumDataType.java (91%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/EnumUpdateType.java (90%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/ExecuteQueryRecordResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/ExecuteQueryResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/GetResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/InsertRecordData.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/InsertResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/ProtobufAny.java (95%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/RecordResponseObject.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/RpcStatus.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/TokenGroupRedactions.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/TokenizeRequestObject.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/TokenizeResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/TokenizeResponseObject.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/TokenizeResponseObjectToken.java (98%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/UpdateRecordData.java (97%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/UpdateResponse.java (96%) rename v3/src/main/java/com/skyflow/{vaultLH => generated/rest}/types/Upsert.java (97%) create mode 100644 v3/src/main/java/com/skyflow/utils/Constants.java create mode 100644 v3/src/main/java/com/skyflow/utils/Utils.java create mode 100644 v3/src/main/java/com/skyflow/utils/validations/Validations.java create mode 100644 v3/src/main/java/com/skyflow/vault/controller/VaultController.java delete mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java delete mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java delete mode 100644 v3/src/main/java/com/skyflow/vaultLH/core/Stream.java diff --git a/common/pom.xml b/common/pom.xml index 803af1f6..1695ca87 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -11,7 +11,7 @@ common 1.0.0 - com.skyflow.common + com.skyflow 8 diff --git a/common/src/main/java/com/skyflow/common/ApiClientBuilder.java b/common/src/main/java/com/skyflow/common/ApiClientBuilder.java deleted file mode 100644 index 68277979..00000000 --- a/common/src/main/java/com/skyflow/common/ApiClientBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common; - -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.Environment; -import okhttp3.OkHttpClient; - -public final class ApiClientBuilder { - private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); - - private String token = null; - - private Environment environment = Environment.PRODUCTION; - - /** - * Sets token - */ - public ApiClientBuilder token(String token) { - this.token = token; - return this; - } - - public ApiClientBuilder environment(Environment environment) { - this.environment = environment; - return this; - } - - public ApiClientBuilder url(String url) { - this.environment = Environment.custom(url); - return this; - } - - /** - * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. - */ - public ApiClientBuilder timeout(int timeout) { - this.clientOptionsBuilder.timeout(timeout); - return this; - } - - /** - * Sets the maximum number of retries for the client. Defaults to 2 retries. - */ - public ApiClientBuilder maxRetries(int maxRetries) { - this.clientOptionsBuilder.maxRetries(maxRetries); - return this; - } - - /** - * Sets the underlying OkHttp client - */ - public ApiClientBuilder httpClient(OkHttpClient httpClient) { - this.clientOptionsBuilder.httpClient(httpClient); - return this; - } - - public ApiClient build() { - if (token == null) { - throw new RuntimeException("Please provide token"); - } - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); - clientOptionsBuilder.environment(this.environment); - return new ApiClient(clientOptionsBuilder.build()); - } -} diff --git a/common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java b/common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java deleted file mode 100644 index 90c42570..00000000 --- a/common/src/main/java/com/skyflow/common/AsyncApiClientBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common; - -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.Environment; -import okhttp3.OkHttpClient; - -public final class AsyncApiClientBuilder { - private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); - - private String token = null; - - private Environment environment = Environment.PRODUCTION; - - /** - * Sets token - */ - public AsyncApiClientBuilder token(String token) { - this.token = token; - return this; - } - - public AsyncApiClientBuilder environment(Environment environment) { - this.environment = environment; - return this; - } - - public AsyncApiClientBuilder url(String url) { - this.environment = Environment.custom(url); - return this; - } - - /** - * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. - */ - public AsyncApiClientBuilder timeout(int timeout) { - this.clientOptionsBuilder.timeout(timeout); - return this; - } - - /** - * Sets the maximum number of retries for the client. Defaults to 2 retries. - */ - public AsyncApiClientBuilder maxRetries(int maxRetries) { - this.clientOptionsBuilder.maxRetries(maxRetries); - return this; - } - - /** - * Sets the underlying OkHttp client - */ - public AsyncApiClientBuilder httpClient(OkHttpClient httpClient) { - this.clientOptionsBuilder.httpClient(httpClient); - return this; - } - - public AsyncApiClient build() { - if (token == null) { - throw new RuntimeException("Please provide token"); - } - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); - clientOptionsBuilder.environment(this.environment); - return new AsyncApiClient(clientOptionsBuilder.build()); - } -} diff --git a/common/src/main/java/com/skyflow/common/core/ApiClientApiException.java b/common/src/main/java/com/skyflow/common/core/ApiClientApiException.java deleted file mode 100644 index 98d9f740..00000000 --- a/common/src/main/java/com/skyflow/common/core/ApiClientApiException.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import okhttp3.Response; - -/** - * This exception type will be thrown for any non-2XX API responses. - */ -public class ApiClientApiException extends ApiClientException { - /** - * The error code of the response that triggered the exception. - */ - private final int statusCode; - - /** - * The body of the response that triggered the exception. - */ - private final Object body; - - private final Map> headers; - - public ApiClientApiException(String message, int statusCode, Object body) { - super(message); - this.statusCode = statusCode; - this.body = body; - this.headers = new HashMap<>(); - } - - public ApiClientApiException(String message, int statusCode, Object body, Response rawResponse) { - super(message); - this.statusCode = statusCode; - this.body = body; - this.headers = new HashMap<>(); - rawResponse.headers().forEach(header -> { - String key = header.component1(); - String value = header.component2(); - this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); - }); - } - - /** - * @return the statusCode - */ - public int statusCode() { - return this.statusCode; - } - - /** - * @return the body - */ - public Object body() { - return this.body; - } - - /** - * @return the headers - */ - public Map> headers() { - return this.headers; - } - - @java.lang.Override - public String toString() { - return "ApiClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body - + "}"; - } -} diff --git a/common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java b/common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java deleted file mode 100644 index 7dbcd35f..00000000 --- a/common/src/main/java/com/skyflow/common/core/ApiClientHttpResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import okhttp3.Response; - -public final class ApiClientHttpResponse { - - private final T body; - - private final Map> headers; - - public ApiClientHttpResponse(T body, Response rawResponse) { - this.body = body; - - Map> headers = new HashMap<>(); - rawResponse.headers().forEach(header -> { - String key = header.component1(); - String value = header.component2(); - headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); - }); - this.headers = headers; - } - - public T body() { - return this.body; - } - - public Map> headers() { - return headers; - } -} diff --git a/common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java b/common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java deleted file mode 100644 index e3869be3..00000000 --- a/common/src/main/java/com/skyflow/common/core/DateTimeDeserializer.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.module.SimpleModule; -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQueries; - -/** - * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. - */ -class DateTimeDeserializer extends JsonDeserializer { - private static final SimpleModule MODULE; - - static { - MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); - } - - /** - * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. - * - * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. - */ - public static SimpleModule getModule() { - return MODULE; - } - - @Override - public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { - JsonToken token = parser.currentToken(); - if (token == JsonToken.VALUE_NUMBER_INT) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); - } else { - TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( - parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); - - if (temporal.query(TemporalQueries.offset()) == null) { - return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); - } else { - return OffsetDateTime.from(temporal); - } - } - } -} diff --git a/common/src/main/java/com/skyflow/common/core/FileStream.java b/common/src/main/java/com/skyflow/common/core/FileStream.java deleted file mode 100644 index 6a999376..00000000 --- a/common/src/main/java/com/skyflow/common/core/FileStream.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.io.InputStream; -import java.util.Objects; -import okhttp3.MediaType; -import okhttp3.RequestBody; -import org.jetbrains.annotations.Nullable; - -/** - * Represents a file stream with associated metadata for file uploads. - */ -public class FileStream { - private final InputStream inputStream; - private final String fileName; - private final MediaType contentType; - - /** - * Constructs a FileStream with the given input stream and optional metadata. - * - * @param inputStream The input stream of the file content. Must not be null. - * @param fileName The name of the file, or null if unknown. - * @param contentType The MIME type of the file content, or null if unknown. - * @throws NullPointerException if inputStream is null - */ - public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { - this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); - this.fileName = fileName; - this.contentType = contentType; - } - - public FileStream(InputStream inputStream) { - this(inputStream, null, null); - } - - public InputStream getInputStream() { - return inputStream; - } - - @Nullable - public String getFileName() { - return fileName; - } - - @Nullable - public MediaType getContentType() { - return contentType; - } - - /** - * Creates a RequestBody suitable for use with OkHttp client. - * - * @return A RequestBody instance representing this file stream. - */ - public RequestBody toRequestBody() { - return new InputStreamRequestBody(contentType, inputStream); - } -} diff --git a/common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java b/common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java deleted file mode 100644 index e5bdc8ad..00000000 --- a/common/src/main/java/com/skyflow/common/core/InputStreamRequestBody.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Objects; -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.internal.Util; -import okio.BufferedSink; -import okio.Okio; -import okio.Source; -import org.jetbrains.annotations.Nullable; - -/** - * A custom implementation of OkHttp's RequestBody that wraps an InputStream. - * This class allows streaming of data from an InputStream directly to an HTTP request body, - * which is useful for file uploads or sending large amounts of data without loading it all into memory. - */ -public class InputStreamRequestBody extends RequestBody { - private final InputStream inputStream; - private final MediaType contentType; - - /** - * Constructs an InputStreamRequestBody with the specified content type and input stream. - * - * @param contentType the MediaType of the content, or null if not known - * @param inputStream the InputStream containing the data to be sent - * @throws NullPointerException if inputStream is null - */ - public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { - this.contentType = contentType; - this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); - } - - /** - * Returns the content type of this request body. - * - * @return the MediaType of the content, or null if not specified - */ - @Nullable - @Override - public MediaType contentType() { - return contentType; - } - - /** - * Returns the content length of this request body, if known. - * This method attempts to determine the length using the InputStream's available() method, - * which may not always accurately reflect the total length of the stream. - * - * @return the content length, or -1 if the length is unknown - * @throws IOException if an I/O error occurs - */ - @Override - public long contentLength() throws IOException { - return inputStream.available() == 0 ? -1 : inputStream.available(); - } - - /** - * Writes the content of the InputStream to the given BufferedSink. - * This method is responsible for transferring the data from the InputStream to the network request. - * - * @param sink the BufferedSink to write the content to - * @throws IOException if an I/O error occurs during writing - */ - @Override - public void writeTo(BufferedSink sink) throws IOException { - Source source = null; - try { - source = Okio.source(inputStream); - sink.writeAll(source); - } finally { - Util.closeQuietly(Objects.requireNonNull(source)); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/core/MediaTypes.java b/common/src/main/java/com/skyflow/common/core/MediaTypes.java deleted file mode 100644 index ed48020a..00000000 --- a/common/src/main/java/com/skyflow/common/core/MediaTypes.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import okhttp3.MediaType; - -public final class MediaTypes { - - public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); - - private MediaTypes() {} -} diff --git a/common/src/main/java/com/skyflow/common/core/Nullable.java b/common/src/main/java/com/skyflow/common/core/Nullable.java deleted file mode 100644 index 77d34027..00000000 --- a/common/src/main/java/com/skyflow/common/core/Nullable.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.util.Optional; -import java.util.function.Function; - -public final class Nullable { - - private final Either, Null> value; - - private Nullable() { - this.value = Either.left(Optional.empty()); - } - - private Nullable(T value) { - if (value == null) { - this.value = Either.right(Null.INSTANCE); - } else { - this.value = Either.left(Optional.of(value)); - } - } - - public static Nullable ofNull() { - return new Nullable<>(null); - } - - public static Nullable of(T value) { - return new Nullable<>(value); - } - - public static Nullable empty() { - return new Nullable<>(); - } - - public static Nullable ofOptional(Optional value) { - if (value.isPresent()) { - return of(value.get()); - } else { - return empty(); - } - } - - public boolean isNull() { - return this.value.isRight(); - } - - public boolean isEmpty() { - return this.value.isLeft() && !this.value.getLeft().isPresent(); - } - - public T get() { - if (this.isNull()) { - return null; - } - - return this.value.getLeft().get(); - } - - public Nullable map(Function mapper) { - if (this.isNull()) { - return Nullable.ofNull(); - } - - return Nullable.ofOptional(this.value.getLeft().map(mapper)); - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof Nullable)) { - return false; - } - - if (((Nullable) other).isNull() && this.isNull()) { - return true; - } - - return this.value.getLeft().equals(((Nullable) other).value.getLeft()); - } - - private static final class Either { - private L left = null; - private R right = null; - - private Either(L left, R right) { - if (left != null && right != null) { - throw new IllegalArgumentException("Left and right argument cannot both be non-null."); - } - - if (left == null && right == null) { - throw new IllegalArgumentException("Left and right argument cannot both be null."); - } - - if (left != null) { - this.left = left; - } - - if (right != null) { - this.right = right; - } - } - - public static Either left(L left) { - return new Either<>(left, null); - } - - public static Either right(R right) { - return new Either<>(null, right); - } - - public boolean isLeft() { - return this.left != null; - } - - public boolean isRight() { - return this.right != null; - } - - public L getLeft() { - if (!this.isLeft()) { - throw new IllegalArgumentException("Cannot get left from right Either."); - } - return this.left; - } - - public R getRight() { - if (!this.isRight()) { - throw new IllegalArgumentException("Cannot get right from left Either."); - } - return this.right; - } - } - - private static final class Null { - private static final Null INSTANCE = new Null(); - - private Null() {} - } -} diff --git a/common/src/main/java/com/skyflow/common/core/ObjectMappers.java b/common/src/main/java/com/skyflow/common/core/ObjectMappers.java deleted file mode 100644 index feee4402..00000000 --- a/common/src/main/java/com/skyflow/common/core/ObjectMappers.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.json.JsonMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import java.io.IOException; - -public final class ObjectMappers { - public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() - .addModule(new Jdk8Module()) - .addModule(new JavaTimeModule()) - .addModule(DateTimeDeserializer.getModule()) - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .build(); - - private ObjectMappers() {} - - public static String stringify(Object o) { - try { - return JSON_MAPPER - .setSerializationInclusion(JsonInclude.Include.ALWAYS) - .writerWithDefaultPrettyPrinter() - .writeValueAsString(o); - } catch (IOException e) { - return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/core/QueryStringMapper.java b/common/src/main/java/com/skyflow/common/core/QueryStringMapper.java deleted file mode 100644 index 877b4307..00000000 --- a/common/src/main/java/com/skyflow/common/core/QueryStringMapper.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import okhttp3.HttpUrl; -import okhttp3.MultipartBody; - -public class QueryStringMapper { - - private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; - - public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { - JsonNode valueNode = MAPPER.valueToTree(value); - - List> flat; - if (valueNode.isObject()) { - flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); - } else if (valueNode.isArray()) { - flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); - } else { - if (valueNode.isTextual()) { - httpUrl.addQueryParameter(key, valueNode.textValue()); - } else { - httpUrl.addQueryParameter(key, valueNode.toString()); - } - return; - } - - for (Map.Entry field : flat) { - if (field.getValue().isTextual()) { - httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); - } else { - httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); - } - } - } - - public static void addFormDataPart( - MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { - JsonNode valueNode = MAPPER.valueToTree(value); - - List> flat; - if (valueNode.isObject()) { - flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); - } else if (valueNode.isArray()) { - flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); - } else { - if (valueNode.isTextual()) { - multipartBody.addFormDataPart(key, valueNode.textValue()); - } else { - multipartBody.addFormDataPart(key, valueNode.toString()); - } - return; - } - - for (Map.Entry field : flat) { - if (field.getValue().isTextual()) { - multipartBody.addFormDataPart( - key + field.getKey(), field.getValue().textValue()); - } else { - multipartBody.addFormDataPart( - key + field.getKey(), field.getValue().toString()); - } - } - } - - public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { - List> flat = new ArrayList<>(); - - Iterator> fields = object.fields(); - while (fields.hasNext()) { - Map.Entry field = fields.next(); - - String key = "[" + field.getKey() + "]"; - - if (field.getValue().isObject()) { - List> flatField = - flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); - addAll(flat, flatField, key); - } else if (field.getValue().isArray()) { - List> flatField = - flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); - addAll(flat, flatField, ""); - } else { - flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); - } - } - - return flat; - } - - private static List> flattenArray( - ArrayNode array, String key, boolean arraysAsRepeats) { - List> flat = new ArrayList<>(); - - Iterator elements = array.elements(); - - int index = 0; - while (elements.hasNext()) { - JsonNode element = elements.next(); - - String indexKey = key + "[" + index + "]"; - - if (arraysAsRepeats) { - indexKey = key; - } - - if (element.isObject()) { - List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); - addAll(flat, flatField, indexKey); - } else if (element.isArray()) { - List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); - addAll(flat, flatField, indexKey); - } else { - flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); - } - - index++; - } - - return flat; - } - - private static void addAll( - List> target, List> source, String prefix) { - for (Map.Entry entry : source) { - Map.Entry entryToAdd = - new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); - target.add(entryToAdd); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/core/RequestOptions.java b/common/src/main/java/com/skyflow/common/core/RequestOptions.java deleted file mode 100644 index df0db4f7..00000000 --- a/common/src/main/java/com/skyflow/common/core/RequestOptions.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; - -public final class RequestOptions { - private final String token; - - private final Optional timeout; - - private final TimeUnit timeoutTimeUnit; - - private final Map headers; - - private final Map> headerSuppliers; - - private RequestOptions( - String token, - Optional timeout, - TimeUnit timeoutTimeUnit, - Map headers, - Map> headerSuppliers) { - this.token = token; - this.timeout = timeout; - this.timeoutTimeUnit = timeoutTimeUnit; - this.headers = headers; - this.headerSuppliers = headerSuppliers; - } - - public Optional getTimeout() { - return timeout; - } - - public TimeUnit getTimeoutTimeUnit() { - return timeoutTimeUnit; - } - - public Map getHeaders() { - Map headers = new HashMap<>(); - if (this.token != null) { - headers.put("Authorization", "Bearer " + this.token); - } - headers.putAll(this.headers); - this.headerSuppliers.forEach((key, supplier) -> { - headers.put(key, supplier.get()); - }); - return headers; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private String token = null; - - private Optional timeout = Optional.empty(); - - private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; - - private final Map headers = new HashMap<>(); - - private final Map> headerSuppliers = new HashMap<>(); - - public Builder token(String token) { - this.token = token; - return this; - } - - public Builder timeout(Integer timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { - this.timeout = Optional.of(timeout); - this.timeoutTimeUnit = timeoutTimeUnit; - return this; - } - - public Builder addHeader(String key, String value) { - this.headers.put(key, value); - return this; - } - - public Builder addHeader(String key, Supplier value) { - this.headerSuppliers.put(key, value); - return this; - } - - public RequestOptions build() { - return new RequestOptions(token, timeout, timeoutTimeUnit, headers, headerSuppliers); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java b/common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java deleted file mode 100644 index 2bdd5e5a..00000000 --- a/common/src/main/java/com/skyflow/common/core/ResponseBodyInputStream.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.io.FilterInputStream; -import java.io.IOException; -import okhttp3.Response; - -/** - * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the - * OkHttp Response object is properly closed when the stream is closed. - * - * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. - * It retrieves the InputStream from the Response and overrides the close method to close - * both the InputStream and the Response object, ensuring proper resource management and preventing - * premature closure of the underlying HTTP connection. - */ -public class ResponseBodyInputStream extends FilterInputStream { - private final Response response; - - /** - * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp - * Response object. - * - * @param response the OkHttp Response object from which the InputStream is retrieved - * @throws IOException if an I/O error occurs while retrieving the InputStream - */ - public ResponseBodyInputStream(Response response) throws IOException { - super(response.body().byteStream()); - this.response = response; - } - - /** - * Closes the InputStream and the associated OkHttp Response object. This ensures that the - * underlying HTTP connection is properly closed after the stream is no longer needed. - * - * @throws IOException if an I/O error occurs - */ - @Override - public void close() throws IOException { - super.close(); - response.close(); // Ensure the response is closed when the stream is closed - } -} diff --git a/common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java b/common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java deleted file mode 100644 index 73be351b..00000000 --- a/common/src/main/java/com/skyflow/common/core/ResponseBodyReader.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.io.FilterReader; -import java.io.IOException; -import okhttp3.Response; - -/** - * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the - * OkHttp Response object is properly closed when the reader is closed. - * - * This class extends FilterReader and takes an OkHttp Response object as a parameter. - * It retrieves the Reader from the Response and overrides the close method to close - * both the Reader and the Response object, ensuring proper resource management and preventing - * premature closure of the underlying HTTP connection. - */ -public class ResponseBodyReader extends FilterReader { - private final Response response; - - /** - * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. - * - * @param response the OkHttp Response object from which the Reader is retrieved - * @throws IOException if an I/O error occurs while retrieving the Reader - */ - public ResponseBodyReader(Response response) throws IOException { - super(response.body().charStream()); - this.response = response; - } - - /** - * Closes the Reader and the associated OkHttp Response object. This ensures that the - * underlying HTTP connection is properly closed after the reader is no longer needed. - * - * @throws IOException if an I/O error occurs - */ - @Override - public void close() throws IOException { - super.close(); - response.close(); // Ensure the response is closed when the reader is closed - } -} diff --git a/common/src/main/java/com/skyflow/common/core/RetryInterceptor.java b/common/src/main/java/com/skyflow/common/core/RetryInterceptor.java deleted file mode 100644 index 987548ea..00000000 --- a/common/src/main/java/com/skyflow/common/core/RetryInterceptor.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.io.IOException; -import java.time.Duration; -import java.util.Optional; -import java.util.Random; -import okhttp3.Interceptor; -import okhttp3.Response; - -public class RetryInterceptor implements Interceptor { - - private static final Duration ONE_SECOND = Duration.ofSeconds(1); - private final ExponentialBackoff backoff; - private final Random random = new Random(); - - public RetryInterceptor(int maxRetries) { - this.backoff = new ExponentialBackoff(maxRetries); - } - - @Override - public Response intercept(Chain chain) throws IOException { - Response response = chain.proceed(chain.request()); - - if (shouldRetry(response.code())) { - return retryChain(response, chain); - } - - return response; - } - - private Response retryChain(Response response, Chain chain) throws IOException { - Optional nextBackoff = this.backoff.nextBackoff(); - while (nextBackoff.isPresent()) { - try { - Thread.sleep(nextBackoff.get().toMillis()); - } catch (InterruptedException e) { - throw new IOException("Interrupted while trying request", e); - } - response.close(); - response = chain.proceed(chain.request()); - if (shouldRetry(response.code())) { - nextBackoff = this.backoff.nextBackoff(); - } else { - return response; - } - } - - return response; - } - - private static boolean shouldRetry(int statusCode) { - return statusCode == 408 || statusCode == 429 || statusCode >= 500; - } - - private final class ExponentialBackoff { - - private final int maxNumRetries; - - private int retryNumber = 0; - - ExponentialBackoff(int maxNumRetries) { - this.maxNumRetries = maxNumRetries; - } - - public Optional nextBackoff() { - retryNumber += 1; - if (retryNumber > maxNumRetries) { - return Optional.empty(); - } - - int upperBound = (int) Math.pow(2, retryNumber); - return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/core/Suppliers.java b/common/src/main/java/com/skyflow/common/core/Suppliers.java deleted file mode 100644 index 5992c2d0..00000000 --- a/common/src/main/java/com/skyflow/common/core/Suppliers.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.core; - -import java.util.Objects; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; - -public final class Suppliers { - private Suppliers() {} - - public static Supplier memoize(Supplier delegate) { - AtomicReference value = new AtomicReference<>(); - return () -> { - T val = value.get(); - if (val == null) { - val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); - } - return val; - }; - } -} diff --git a/common/src/main/java/com/skyflow/common/enums/LogLevel.java b/common/src/main/java/com/skyflow/common/enums/LogLevel.java deleted file mode 100644 index ff17c291..00000000 --- a/common/src/main/java/com/skyflow/common/enums/LogLevel.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.skyflow.common.enums; - -public enum LogLevel { - OFF, - ERROR, - WARN, - INFO, - DEBUG -} diff --git a/common/src/main/java/com/skyflow/common/errors/ErrorCode.java b/common/src/main/java/com/skyflow/common/errors/ErrorCode.java deleted file mode 100644 index d99e3ff2..00000000 --- a/common/src/main/java/com/skyflow/common/errors/ErrorCode.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.skyflow.common.errors; - -public enum ErrorCode { - INVALID_INPUT(400), - INVALID_INDEX(404), - SERVER_ERROR(500), - PARTIAL_SUCCESS(500); - - private final int code; - - ErrorCode(int code) { - this.code = code; - } - - public int getCode() { - return code; - } -} diff --git a/common/src/main/java/com/skyflow/common/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/common/errors/ErrorMessage.java deleted file mode 100644 index a9b62243..00000000 --- a/common/src/main/java/com/skyflow/common/errors/ErrorMessage.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.skyflow.common.errors; - -import com.skyflow.common.utils.Constants; - -public enum ErrorMessage { - // Client initialization - VaultIdAlreadyInConfigList("%s0 Validation error. VaultId is present in an existing config. Specify a new vaultId in config."), - VaultIdNotInConfigList("%s0 Validation error. VaultId is missing from the config. Specify the vaultIds from configs."), - ConnectionIdAlreadyInConfigList("%s0 Validation error. ConnectionId is present in an existing config. Specify a connectionId in config."), - ConnectionIdNotInConfigList("%s0 Validation error. ConnectionId is missing from the config. Specify the connectionIds from configs."), - EmptyCredentials("%s0 Validation error. Invalid credentials. Credentials must not be empty."), - - // Vault config - InvalidVaultId("%s0 Initialization failed. Invalid vault ID. Specify a valid vault ID."), - EmptyVaultId("%s0 Initialization failed. Invalid vault ID. Vault ID must not be empty."), - InvalidClusterId("%s0 Initialization failed. Invalid cluster ID. Specify cluster ID."), - EmptyClusterId("%s0 Initialization failed. Invalid cluster ID. Specify a valid cluster ID."), - - // Connection config - InvalidConnectionId("%s0 Initialization failed. Invalid connection ID. Specify a valid connection ID."), - EmptyConnectionId("%s0 Initialization failed. Invalid connection ID. Connection ID must not be empty."), - InvalidConnectionUrl("%s0 Initialization failed. Invalid connection URL. Specify a valid connection URL."), - EmptyConnectionUrl("%s0 Initialization failed. Invalid connection URL. Connection URL must not be empty."), - InvalidConnectionUrlFormat("%s0 Initialization failed. Connection URL is not a valid URL. Specify a valid connection URL."), - - // Credentials - MultipleTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify only one from 'path', 'credentialsString', 'token' or 'apiKey'."), - NoTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify any one from 'path', 'credentialsString', 'token' or 'apiKey'."), - EmptyCredentialFilePath("%s0 Initialization failed. Invalid credentials. Credentials file path must not be empty."), - EmptyCredentialsString("%s0 Initialization failed. Invalid credentials. Credentials string must not be empty."), - EmptyToken("%s0 Initialization failed. Invalid credentials. Token must not be empty."), - EmptyApikey("%s0 Initialization failed. Invalid credentials. Api key must not be empty."), - InvalidApikey("%s0 Initialization failed. Invalid credentials. Specify valid api key."), - EmptyRoles("%s0 Initialization failed. Invalid roles. Specify at least one role."), - EmptyRoleInRoles("%s0 Initialization failed. Invalid role. Specify a valid role."), - EmptyContext("%s0 Initialization failed. Invalid context. Specify a valid context."), - - // Bearer token generation - FileNotFound("%s0 Initialization failed. Credential file not found at %s1. Verify the file path."), - FileInvalidJson("%s0 Initialization failed. File at %s1 is not in valid JSON format. Verify the file contents."), - CredentialsStringInvalidJson("%s0 Initialization failed. Credentials string is not in valid JSON format. Verify the credentials string contents."), - InvalidCredentials("%s0 Initialization failed. Invalid credentials provided. Specify valid credentials."), - MissingPrivateKey("%s0 Initialization failed. Unable to read private key in credentials. Verify your private key."), - MissingClientId("%s0 Initialization failed. Unable to read client ID in credentials. Verify your client ID."), - MissingKeyId("%s0 Initialization failed. Unable to read key ID in credentials. Verify your key ID."), - MissingTokenUri("%s0 Initialization failed. Unable to read token URI in credentials. Verify your token URI."), - InvalidTokenUri("%s0 Initialization failed. Token URI in not a valid URL in credentials. Verify your token URI."), - JwtInvalidFormat("%s0 Initialization failed. Invalid private key format. Verify your credentials."), - InvalidAlgorithm("%s0 Initialization failed. Invalid algorithm to parse private key. Specify valid algorithm."), - InvalidKeySpec("%s0 Initialization failed. Unable to parse RSA private key. Verify your credentials."), - JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."), - MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."), - MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."), - - // Insert - TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."), - EmptyTable("%s0 Validation error. 'table' can't be empty. Specify a table."), - ValuesKeyError("%s0 Validation error. 'values' key is missing from the payload. Specify a 'values' key."), - EmptyValues("%s0 Validation error. 'values' can't be empty. Specify values."), - EmptyKeyInValues("%s0 Validation error. Invalid key in values. Specify a valid key."), - EmptyValueInValues("%s0 Validation error. Invalid value in values. Specify a valid value."), - TokensKeyError("%s0 Validation error. 'tokens' key is missing from the payload. Specify a 'tokens' key."), - EmptyTokens("%s0 Validation error. The 'tokens' field is empty. Specify tokens for one or more fields."), - EmptyKeyInTokens("%s0 Validation error. Invalid key tokens. Specify a valid key."), - EmptyValueInTokens("%s0 Validation error. Invalid value in tokens. Specify a valid value."), - EmptyUpsert("%s0 Validation error. 'upsert' key can't be empty. Specify an upsert column."), - HomogenousNotSupportedWithUpsert("%s0 Validation error. 'homogenous' is not supported with 'upsert'. Specify either 'homogenous' or 'upsert'."), - TokensPassedForTokenModeDisable("%s0 Validation error. 'tokenMode' wasn't specified. Set 'tokenMode' to 'ENABLE' to insert tokens."), - NoTokensWithTokenMode("%s0 Validation error. Tokens weren't specified for records while 'tokenMode' was %s1. Specify tokens."), - MismatchOfFieldsAndTokens("%s0 Validation error. 'fields' and 'tokens' have different columns names. Verify that 'fields' and 'tokens' columns match."), - InsufficientTokensPassedForTokenModeEnableStrict("%s0 Validation error. 'tokenMode' is set to 'ENABLE_STRICT', but some fields are missing tokens. Specify tokens for all fields."), - BatchInsertPartialSuccess("%s0 Insert operation completed with partial success."), - BatchInsertFailure("%s0 Insert operation failed."), - - // Detokenize - InvalidDetokenizeData("%s0 Validation error. Invalid detokenize data. Specify valid detokenize data."), - EmptyDetokenizeData("%s0 Validation error. Invalid data tokens. Specify at least one data token."), - EmptyTokenInDetokenizeData("%s0 Validation error. Invalid data tokens. Specify a valid data token."), - - // Get - IdsKeyError("%s0 Validation error. 'ids' key is missing from the payload. Specify an 'ids' key."), - EmptyIds("%s0 Validation error. 'ids' can't be empty. Specify at least one id."), - EmptyIdInIds("%s0 Validation error. Invalid id in 'ids'. Specify a valid id."), - EmptyFields("%s0 Validation error. Fields are empty in get payload. Specify at least one field."), - EmptyFieldInFields("%s0 Validation error. Invalid field in 'fields'. Specify a valid field."), - RedactionKeyError("%s0 Validation error. 'redaction' key is missing from the payload. Specify a 'redaction' key."), - RedactionWithTokensNotSupported("%s0 Validation error. 'redaction' can't be used when 'returnTokens' is specified. Remove 'redaction' from payload if 'returnTokens' is specified."), - TokensGetColumnNotSupported("%s0 Validation error. Column name and/or column values can't be used when 'returnTokens' is specified. Remove unique column values or 'returnTokens' from the payload."), - EmptyOffset("%s0 Validation error. 'offset' can't be empty. Specify an offset."), - EmptyLimit("%s0 Validation error. 'limit' can't be empty. Specify a limit."), - UniqueColumnOrIdsKeyError("%s0 Validation error. 'ids' or 'columnName' key is missing from the payload. Specify the ids or unique 'columnName' in payload."), - BothIdsAndColumnDetailsSpecified("%s0 Validation error. Both Skyflow IDs and column details can't be specified. Either specify Skyflow IDs or unique column details."), - ColumnNameKeyError("%s0 Validation error. 'columnName' isn't specified whereas 'columnValues' are specified. Either add 'columnName' or remove 'columnValues'."), - EmptyColumnName("%s0 Validation error. 'columnName' can't be empty. Specify a column name."), - ColumnValuesKeyErrorGet("%s0 Validation error. 'columnValues' aren't specified whereas 'columnName' is specified. Either add 'columnValues' or remove 'columnName'."), - EmptyColumnValues("%s0 Validation error. 'columnValues' can't be empty. Specify at least one column value"), - EmptyValueInColumnValues("%s0 Validation error. Invalid value in column values. Specify a valid column value."), - - TokenKeyError("%s0 Validation error. 'token' key is missing from the payload. Specify a 'token' key."), - PartialSuccess("%s0 Validation error. Check 'SkyflowError.data' for details."), - - // Update - DataKeyError("%s0 Validation error. 'data' key is missing from the payload. Specify a 'data' key."), - EmptyData("%s0 Validation error. 'data' can't be empty. Specify data."), - SkyflowIdKeyError("%s0 Validation error. 'skyflow_id' is missing from the data payload. Specify a 'skyflow_id'."), - InvalidSkyflowIdType("%s0 Validation error. Invalid type for 'skyflow_id' in data payload. Specify 'skyflow_id' as a string."), - EmptySkyflowId("%s0 Validation error. 'skyflow_id' can't be empty. Specify a skyflow id."), - - // Query - QueryKeyError("%s0 Validation error. 'query' key is missing from the payload. Specify a 'query' key."), - EmptyQuery("%s0 Validation error. 'query' can't be empty. Specify a query"), - - // Tokenize - ColumnValuesKeyErrorTokenize("%s0 Validation error. 'columnValues' key is missing from the payload. Specify a 'columnValues' key."), - EmptyColumnGroupInColumnValue("%s0 Validation error. Invalid column group in column value. Specify a valid column group."), - - // Connection - InvalidRequestHeaders("%s0 Validation error. Request headers aren't valid. Specify valid request headers."), - EmptyRequestHeaders("%s0 Validation error. Request headers are empty. Specify valid request headers."), - InvalidPathParams("%s0 Validation error. Path parameters aren't valid. Specify valid path parameters."), - EmptyPathParams("%s0 Validation error. Path parameters are empty. Specify valid path parameters."), - InvalidQueryParams("%s0 Validation error. Query parameters aren't valid. Specify valid query parameters."), - EmptyQueryParams("%s0 Validation error. Query parameters are empty. Specify valid query parameters."), - 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."), - - // 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."), - - //Detect Files - InvalidNullFileInDeIdentifyFile("%s0 Validation error. The file field is required and must not be null. Specify a valid file object."), - InvalidFilePath("%s0 Validation error. The file path is invalid. Specify a valid file path."), - BothFileAndFilePathProvided("%s0 Validation error. Both file and filePath are provided. Specify either file object or filePath, not both."), - FileNotFoundToDeidentify("%s0 Validation error. The file to deidentify was not found at the specified path. Verify the file path and try again."), - FileNotReadableToDeidentify("%s0 Validation error. The file to deidentify is not readable. Check the file permissions and try again."), - InvalidPixelDensityToDeidentifyFile("%s0 Validation error. Should be a positive integer. Specify a valid pixel density."), - InvalidMaxResolution("%s0 Validation error. Should be a positive integer. Specify a valid max resolution."), - OutputDirectoryNotFound("%s0 Validation error. The output directory for deidentified files was not found at the specified path. Verify the output directory path and try again."), - InvalidPermission("%s0 Validation error. The output directory for deidentified files is not writable. Check the directory permissions and try again."), - InvalidWaitTime("%s0 Validation error. The wait time for deidentify file operation should be a positive integer. Specify a valid wait time."), - WaitTimeExceedsLimit("%s0 Validation error. The wait time for deidentify file operation exceeds the maximum limit of 64 seconds. Specify a wait time less than or equal to 60 seconds."), - InvalidOrEmptyRunId("%s0 Validation error. The run ID is invalid or empty. Specify a valid run ID."), - 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."), - 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."), - // Generic - ErrorOccurred("%s0 API error. Error occurred.") - ; - private final String message; - - ErrorMessage(String message) { - this.message = message.replace("%s0", Constants.SDK_PREFIX); - } - - public String getMessage() { - return message; - } -} diff --git a/common/src/main/java/com/skyflow/common/errors/HttpStatus.java b/common/src/main/java/com/skyflow/common/errors/HttpStatus.java deleted file mode 100644 index 571a93e5..00000000 --- a/common/src/main/java/com/skyflow/common/errors/HttpStatus.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.skyflow.common.errors; - -public enum HttpStatus { - BAD_REQUEST("Bad Request"); - - private final String httpStatus; - - HttpStatus(String httpStatus) { - this.httpStatus = httpStatus; - } - - public String getHttpStatus() { - return httpStatus; - } -} diff --git a/common/src/main/java/com/skyflow/common/errors/SkyflowException.java b/common/src/main/java/com/skyflow/common/errors/SkyflowException.java deleted file mode 100644 index 8f07689b..00000000 --- a/common/src/main/java/com/skyflow/common/errors/SkyflowException.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.skyflow.common.errors; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.skyflow.common.utils.Constants; - -import java.util.List; -import java.util.Map; - -public class SkyflowException extends Exception { - private String requestId; - private Integer grpcCode; - private Integer httpCode; - private String message; - private String httpStatus; - private JsonArray details; - private JsonObject responseBody; - - public SkyflowException(String message) { - super(message); - this.message = message; - } - - public SkyflowException(Throwable cause) { - super(cause); - this.message = cause.getMessage(); - } - - public SkyflowException(String message, Throwable cause) { - super(message, cause); - this.message = message; - } - - public SkyflowException(int code, String message) { - super(message); - this.httpCode = code; - this.message = message; - this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); - this.details = new JsonArray(); - } - - public SkyflowException(int httpCode, Throwable cause, Map> responseHeaders, String responseBody) { - super(cause); - this.httpCode = httpCode > 0 ? httpCode : 400; - try { - setRequestId(responseHeaders); - setResponseBody(responseBody, responseHeaders); - } catch (Exception e) { - this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); - String fullMessage = responseBody != null ? responseBody : - (cause.getLocalizedMessage() != null ? cause.getMessage() : ErrorMessage.ErrorOccurred.getMessage()); - this.message = fullMessage.split("HTTP response code:")[0].trim(); - } - } - - private void setResponseBody(String responseBody, Map> responseHeaders) { - this.responseBody = JsonParser.parseString(responseBody).getAsJsonObject(); - if (this.responseBody.get("error") != null) { - setGrpcCode(); - setHttpStatus(); - setMessage(); - setDetails(responseHeaders); - } - } - - public String getRequestId() { - return requestId; - } - - private void setRequestId(Map> responseHeaders) { - List ids = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY); - this.requestId = ids == null ? null : ids.get(0); - } - - private void setMessage() { - JsonElement messageElement = ((JsonObject) responseBody.get("error")).get("message"); - this.message = messageElement == null ? null : messageElement.getAsString(); - } - - private void setGrpcCode() { - JsonElement grpcElement = ((JsonObject) responseBody.get("error")).get("grpc_code"); - this.grpcCode = grpcElement == null ? null : grpcElement.getAsInt(); - } - - private void setHttpStatus() { - JsonElement statusElement = ((JsonObject) responseBody.get("error")).get("http_status"); - this.httpStatus = statusElement == null ? null : statusElement.getAsString(); - } - - public int getHttpCode() { - return httpCode; - } - - public JsonArray getDetails() { - return details; - } - - private void setDetails(Map> responseHeaders) { - JsonElement detailsElement = ((JsonObject) responseBody.get("error")).get("details"); - List errorFromClientHeader = responseHeaders.get(Constants.ERROR_FROM_CLIENT_HEADER_KEY); - if (detailsElement != null) { - this.details = detailsElement.getAsJsonArray(); - } - if (errorFromClientHeader != null) { - this.details = this.details == null ? new JsonArray() : this.details; - String errorFromClient = errorFromClientHeader.get(0); - JsonObject detailObject = new JsonObject(); - detailObject.addProperty("errorFromClient", errorFromClient); - this.details.add(detailObject); - } - } - - public Integer getGrpcCode() { - return grpcCode; - } - - public String getHttpStatus() { - return httpStatus; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public String toString() { - return String.format( - "%n requestId: %s%n grpcCode: %s%n httpCode: %s%n httpStatus: %s%n message: %s%n details: %s", - this.requestId, this.grpcCode, this.httpCode, this.httpStatus, this.message, this.details - ); - } -} diff --git a/common/src/main/java/com/skyflow/common/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/common/logs/ErrorLogs.java deleted file mode 100644 index b0ee077e..00000000 --- a/common/src/main/java/com/skyflow/common/logs/ErrorLogs.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.skyflow.common.logs; - -public enum ErrorLogs { - // Client initialization - VAULT_CONFIG_EXISTS("Vault config with vault ID %s1 already exists."), - VAULT_CONFIG_DOES_NOT_EXIST("Vault config with vault ID %s1 doesn't exist."), - VAULT_ID_IS_REQUIRED("Invalid vault config. Vault ID is required."), - EMPTY_VAULT_ID("Invalid vault config. Vault ID can not be empty."), - CLUSTER_ID_IS_REQUIRED("Invalid vault config. Cluster ID is required."), - EMPTY_CLUSTER_ID("Invalid vault config. Cluster ID can not be empty."), - CONNECTION_CONFIG_EXISTS("Connection config with connection ID %s1 already exists."), - CONNECTION_CONFIG_DOES_NOT_EXIST("Connection config with connection ID %s1 doesn't exist."), - CONNECTION_ID_IS_REQUIRED("Invalid connection config. Connection ID is required."), - EMPTY_CONNECTION_ID("Invalid connection config. Connection ID can not be empty."), - CONNECTION_URL_IS_REQUIRED("Invalid connection config. Connection URL is required."), - EMPTY_CONNECTION_URL("Invalid connection config. Connection URL can not be empty."), - INVALID_CONNECTION_URL("Invalid connection config. Connection URL is not a valid URL."), - MULTIPLE_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Only one of 'path', 'credentialsString', 'token' or 'apiKey' is allowed."), - NO_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Any one of 'path', 'credentialsString', 'token' or 'apiKey' is required."), - EMPTY_CREDENTIALS_PATH("Invalid credentials. Credentials path can not be empty."), - EMPTY_CREDENTIALS_STRING("Invalid credentials. Credentials string can not be empty."), - EMPTY_TOKEN_VALUE("Invalid credentials. Token can not be empty."), - EMPTY_API_KEY_VALUE("Invalid credentials. Api key can not be empty."), - INVALID_API_KEY("Invalid credentials. Api key is invalid."), - EMPTY_ROLES("Invalid credentials. Roles can not be empty."), - EMPTY_OR_NULL_ROLE_IN_ROLES("Invalid credentials. Role can not be null or empty in roles at index %s1."), - EMPTY_OR_NULL_CONTEXT("Invalid credentials. Context can not be empty."), - - // Bearer token generation - INVALID_BEARER_TOKEN("Bearer token is invalid or expired."), - INVALID_CREDENTIALS_FILE("Credentials file is either null or an invalid file."), - INVALID_CREDENTIALS_STRING("Credentials string is either null or empty."), - INVALID_CREDENTIALS_FILE_FORMAT("Credentials file is not in a valid JSON format."), - CREDENTIALS_FILE_NOT_FOUND("Credentials file not found at specified path."), - INVALID_CREDENTIALS_STRING_FORMAT("Credentials string is not in a valid JSON string format."), - PRIVATE_KEY_IS_REQUIRED("Private key is required."), - CLIENT_ID_IS_REQUIRED("Client ID is required."), - KEY_ID_IS_REQUIRED("Key ID is required."), - TOKEN_URI_IS_REQUIRED("Token URI is required."), - INVALID_TOKEN_URI("Invalid value for token URI in credentials."), - JWT_INVALID_FORMAT("Private key is not in a valid format."), - INVALID_ALGORITHM("Algorithm for parsing private key is invalid or does not exist."), - INVALID_KEY_SPEC("Unable to parse RSA private key."), - BEARER_TOKEN_REJECTED("Bearer token request resulted in failure."), - SIGNED_DATA_TOKENS_REJECTED("Signed data tokens request resulted in failure."), - - // Vault api interfaces - TABLE_IS_REQUIRED("Invalid %s1 request. Table is required."), - EMPTY_TABLE_NAME("Invalid %s1 request. Table name can not be empty."), - VALUES_IS_REQUIRED("Invalid %s1 request. Values are required."), - EMPTY_VALUES("Invalid %s1 request. Values can not be empty."), - EMPTY_OR_NULL_VALUE_IN_VALUES("Invalid %s1 request. Value can not be null or empty in values for key \"%s2\"."), - EMPTY_OR_NULL_KEY_IN_VALUES("Invalid %s1 request. Key can not be null or empty in values"), - EMPTY_UPSERT("Invalid %s1 request. Upsert can not be empty."), - HOMOGENOUS_NOT_SUPPORTED_WITH_UPSERT("Invalid %s1 request. Homogenous is not supported when upsert is passed."), - TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE("Invalid %s1 request. Tokens are not allowed when tokenMode is DISABLE."), - TOKENS_REQUIRED_WITH_TOKEN_MODE("Invalid %s1 request. Tokens are required when tokenMode is %s2."), - EMPTY_TOKENS("Invalid %s1 request. Tokens can not be empty."), - EMPTY_OR_NULL_VALUE_IN_TOKENS("Invalid %s1 request. Value can not be null or empty in tokens for key \"%s2\"."), - EMPTY_OR_NULL_KEY_IN_TOKENS("Invalid %s1 request. Key can not be null or empty in tokens."), - INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT("Invalid %s1 request. For tokenMode as ENABLE_STRICT, tokens should be passed for all fields."), - MISMATCH_OF_FIELDS_AND_TOKENS("Invalid %s1 request. Keys for values and tokens are not matching."), - INSERT_RECORDS_REJECTED("Insert request resulted in failure."), - DETOKENIZE_DATA_REQUIRED("Invalid %s1 request. Detokenize data is required."), - EMPTY_DETOKENIZE_DATA("Invalid %s1 request. Detokenize data can not be empty."), - EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA("Invalid %s1 request. Token can not be null or empty in detokenize data at index %s2."), - REDACTION_IS_REQUIRED("Invalid %s1 request. Redaction is required."), - DETOKENIZE_REQUEST_REJECTED("Detokenize request resulted in failure."), - IDS_IS_REQUIRED("Invalid %s1 request. Ids are required."), - EMPTY_IDS("Invalid %s1 request. Ids can not be empty."), - EMPTY_OR_NULL_ID_IN_IDS("Invalid %s1 request. Id can not be null or empty in ids at index %s2."), - EMPTY_FIELDS("Invalid %s1 request. Fields can not be empty."), - EMPTY_OR_NULL_FIELD_IN_FIELDS("Invalid %s1 request. Field can not be null or empty in fields at index %s2."), - TOKENIZATION_NOT_SUPPORTED_WITH_REDACTION("Invalid %s1 request. Return tokens is not supported when redaction is applied."), - TOKENIZATION_SUPPORTED_ONLY_WITH_IDS("Invalid %s1 request. Return tokens is not supported when column name and values are passed."), - EMPTY_OFFSET("Invalid %s1 request. Offset can not be empty."), - EMPTY_LIMIT("Invalid %s1 request. Limit can not be empty."), - NEITHER_IDS_NOR_COLUMN_NAME_PASSED("Invalid %s1 request. Neither ids nor column name and values are passed."), - BOTH_IDS_AND_COLUMN_NAME_PASSED("Invalid %s1 request. Both ids and column name and values are passed."), - COLUMN_NAME_IS_REQUIRED("Invalid %s1 request. Column name is required when column values are passed."), - EMPTY_COLUMN_NAME("Invalid %s1 request. Column name can not be empty."), - COLUMN_VALUES_IS_REQUIRED_GET("Invalid %s1 request. Column values are required when column name is passed."), - EMPTY_COLUMN_VALUES("Invalid %s1 request. Column values can not be empty."), - EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES("Invalid %s1 request. Column value can not by null or empty in column values at index %s2."), - GET_REQUEST_REJECTED("Get request resulted in failure."), - DATA_IS_REQUIRED("Invalid %s1 request. Data is required."), - EMPTY_DATA("Invalid %s1 request. Data can not be empty."), - SKYFLOW_ID_IS_REQUIRED("Invalid %s1 request. Skyflow Id is required."), - INVALID_SKYFLOW_ID_TYPE("Invalid %s1 request. Skyflow Id should of type String."), - EMPTY_SKYFLOW_ID("Invalid %s1 request. Skyflow Id can not be empty."), - UPDATE_REQUEST_REJECTED("Update request resulted in failure."), - QUERY_IS_REQUIRED("Invalid %s1 request. Query is required."), - EMPTY_QUERY("Invalid %s1 request. Query can not be empty."), - QUERY_REQUEST_REJECTED("Query request resulted in failure."), - COLUMN_VALUES_IS_REQUIRED_TOKENIZE("Invalid %s1 request. ColumnValues are required."), - EMPTY_OR_NULL_COLUMN_GROUP_IN_COLUMN_VALUES("Invalid %s1 request. Column group can not be null or empty in column values at index %s2."), - TOKENIZE_REQUEST_REJECTED("Tokenize request resulted in failure."), - DELETE_REQUEST_REJECTED("Delete request resulted in failure."), - - // invoke connection interface - INVOKE_CONNECTION_INVALID_CONNECTION_URL("Invalid %s1 request. Connection URL is not a valid URL."), - EMPTY_REQUEST_HEADERS("Invalid %s1 request. Request headers can not be empty."), - INVALID_REQUEST_HEADERS("Invalid %s1 request. Request header can not be null or empty in request headers."), - EMPTY_PATH_PARAMS("Invalid %s1 request. Path params can not be empty."), - INVALID_PATH_PARAM("Invalid %s1 request. Path parameter can not be null or empty in path params."), - EMPTY_QUERY_PARAMS("Invalid %s1 request. Query params can not be empty."), - INVALID_QUERY_PARAM("Invalid %s1 request. Query parameter can not be null or empty in query params."), - EMPTY_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), - INVALID_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), - INVOKE_CONNECTION_REQUEST_REJECTED("Invoke connection 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."), - DEIDENTIFY_TEXT_REQUEST_REJECTED("DeIdentify text request resulted in failure."), - INVALID_TEXT_IN_REIDENTIFY("Invalid %s1 request. The text field is required and must be a non-empty string. Specify a valid text."), - REIDENTIFY_TEXT_REQUEST_REJECTED("ReIdentify text request resulted in failure."), - DEIDENTIFY_FILE_REQUEST_REJECTED("DeIdentify file request resulted in failure."), - GET_DETECT_RUN_REQUEST_REJECTED("Get detect run request resulted in failure."), - INVALID_NULL_FILE_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file field is required and must not be null. Specify a valid file."), - FILE_NOT_FOUND_TO_DEIDENTIFY("Invalid %s1 request. The file field is required and must not be empty. Specify a valid file."), - FILE_NOT_READABLE_TO_DEIDENTIFY("Invalid %s1 request. The file is not readable. Please check the file permissions or path."), - INVALID_PIXEL_DENSITY_TO_DEIDENTIFY_FILE("Invalid %s1 request. Pixel density must be a positive integer greater than 0. Specify a valid pixel density."), - INVALID_MAX_RESOLUTION("Invalid %s1 request. Max resolution must be a positive integer greater than 0. Specify a valid max resolution."), - INVALID_BLEEP_TO_DEIDENTIFY_AUDIO("Invalid %s1 request. Specify a valid bleep as AudioBleep"), - OUTPUT_DIRECTORY_NOT_FOUND("Invalid %s1 request. The output directory does not exist. Please specify a valid output directory."), - INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY("Invalid %s1 request. The output directory is not writable. Please check the permissions or specify a valid output directory."), - EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file and file path fields are both empty. Specify a valid file object or file path."), - ; - - private final String log; - - ErrorLogs(String log) { - this.log = log; - } - - public final String getLog() { - return log; - } -} diff --git a/common/src/main/java/com/skyflow/common/logs/InfoLogs.java b/common/src/main/java/com/skyflow/common/logs/InfoLogs.java deleted file mode 100644 index 337db094..00000000 --- a/common/src/main/java/com/skyflow/common/logs/InfoLogs.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.skyflow.common.logs; - -public enum InfoLogs { - // Client initialization - CLIENT_INITIALIZED("Initialized skyflow client."), - VALIDATING_VAULT_CONFIG("Validating vault config."), - VALIDATING_CONNECTION_CONFIG("Validating connection config."), - UNABLE_TO_GENERATE_SDK_METRIC("Unable to generate %s1 metric."), - VAULT_CONTROLLER_INITIALIZED("Initialized vault controller with vault ID %s1."), - DETECT_CONTROLLER_INITIALIZED("Initialized detect controller with vault ID %s1."), - CONNECTION_CONTROLLER_INITIALIZED("Initialized connection controller with connection ID %s1."), - LOGGER_SETUP_DONE("Set up logger."), - CURRENT_LOG_LEVEL("Current log level is %s1."), - - // Bearer token generation - EMPTY_BEARER_TOKEN("Bearer token is empty."), - BEARER_TOKEN_EXPIRED("Bearer token is expired."), - GET_BEARER_TOKEN_TRIGGERED("getBearerToken method triggered."), - GET_BEARER_TOKEN_SUCCESS("Bearer token generated."), - GET_SIGNED_DATA_TOKENS_TRIGGERED("getSignedDataTokens method triggered."), - GET_SIGNED_DATA_TOKEN_SUCCESS("Signed data tokens generated."), - REUSE_BEARER_TOKEN("Reusing bearer token."), - REUSE_API_KEY("Reusing api key."), - GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED("generateBearerTokenFromCredentials method triggered."), - GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED("generateBearerTokenFromCredentialString method triggered."), - GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED("generateSignedTokensFromCredentialsFile method triggered."), - GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_STRING_TRIGGERED("generateSignedTokensFromCredentialsString method triggered."), - - // Insert interface - INSERT_TRIGGERED("Insert method triggered."), - VALIDATE_INSERT_REQUEST("Validating insert request."), - INSERT_REQUEST_RESOLVED("Insert request resolved."), - INSERT_SUCCESS("Data inserted."), - - // Detokenize interface - DETOKENIZE_TRIGGERED("Detokenize method triggered."), - VALIDATE_DETOKENIZE_REQUEST("Validating detokenize request."), - DETOKENIZE_REQUEST_RESOLVED("Detokenize request resolved."), - DETOKENIZE_PARTIAL_SUCCESS("Data detokenized partially."), - DETOKENIZE_SUCCESS("Data detokenized."), - - // Get interface - GET_TRIGGERED("Get method triggered."), - VALIDATE_GET_REQUEST("Validating get request."), - GET_REQUEST_RESOLVED("Get request resolved."), - GET_SUCCESS("Data revealed."), - - // Update interface - UPDATE_TRIGGERED("Update method triggered."), - VALIDATE_UPDATE_REQUEST("Validating update request."), - UPDATE_REQUEST_RESOLVED("Update request resolved."), - UPDATE_SUCCESS("Data updated."), - - // Delete interface - DELETE_TRIGGERED("Delete method triggered."), - VALIDATING_DELETE_REQUEST("Validating delete request."), - DELETE_REQUEST_RESOLVED("Delete request resolved."), - DELETE_SUCCESS("Data deleted."), - - // Query interface - QUERY_TRIGGERED("Query method triggered."), - VALIDATING_QUERY_REQUEST("Validating query request."), - QUERY_REQUEST_RESOLVED("Query request resolved."), - QUERY_SUCCESS("Query executed."), - - // Tokenize interface - TOKENIZE_TRIGGERED("Tokenize method triggered."), - VALIDATING_TOKENIZE_REQUEST("Validating tokenize request."), - TOKENIZE_REQUEST_RESOLVED("Tokenize request resolved."), - TOKENIZE_SUCCESS("Data tokenized."), - - - // Invoke connection interface - INVOKE_CONNECTION_TRIGGERED("Invoke connection method triggered."), - VALIDATING_INVOKE_CONNECTION_REQUEST("Validating invoke connection request."), - INVOKE_CONNECTION_REQUEST_RESOLVED("Invoke connection request resolved."), - - // detect - VALIDATE_DEIDENTIFY_TEXT_REQUEST("Validating deidentify text request."), - DEIDENTIFY_TEXT_SUCCESS("Text data de-identified."), - DEIDENTIFY_TEXT_TRIGGERED("DeIdentify text method triggered."), - DEIDENTIFY_TEXT_REQUEST_RESOLVED("DeIdentify text request resolved."), - VALIDATE_REIDENTIFY_TEXT_REQUEST("Validating reidentify text request."), - REIDENTIFY_TEXT_TRIGGERED("ReIdentify text method triggered."), - REIDENTIFY_TEXT_REQUEST_RESOLVED("ReIdentify text request resolved."), - DEIDENTIFY_FILE_TRIGGERED("DeIdentify file method triggered."), - VALIDATE_DEIDENTIFY_FILE_REQUEST("Validating deidentify file request."), - DEIDENTIFY_FILE_REQUEST_RESOLVED("DeIdentify file request resolved."), - DEIDENTIFY_FILE_SUCCESS("File deidentified successfully."), - GET_DETECT_RUN_TRIGGERED("Get detect run method triggered."), - VALIDATE_GET_DETECT_RUN_REQUEST("Validating get detect run request."), - REIDENTIFY_TEXT_SUCCESS("Text data re-identified."), - ; - - - private final String log; - - InfoLogs(String log) { - this.log = log; - } - - public final String getLog() { - return log; - } -} diff --git a/common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java deleted file mode 100644 index 250d0659..00000000 --- a/common/src/main/java/com/skyflow/common/resources/authentication/AsyncAuthenticationClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.resources.authentication; - -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.RequestOptions; -import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.common.types.V1GetAuthTokenResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncAuthenticationClient { - protected final ClientOptions clientOptions; - - private final AsyncRawAuthenticationClient rawClient; - - public AsyncAuthenticationClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawAuthenticationClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawAuthenticationClient withRawResponse() { - return this.rawClient; - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public CompletableFuture authenticationServiceGetAuthToken(V1GetAuthTokenRequest request) { - return this.rawClient.authenticationServiceGetAuthToken(request).thenApply(response -> response.body()); - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public CompletableFuture authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request, RequestOptions requestOptions) { - return this.rawClient - .authenticationServiceGetAuthToken(request, requestOptions) - .thenApply(response -> response.body()); - } -} diff --git a/common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java deleted file mode 100644 index ece2bb6a..00000000 --- a/common/src/main/java/com/skyflow/common/resources/authentication/AsyncRawAuthenticationClient.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.resources.authentication; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.skyflow.common.core.ApiClientApiException; -import com.skyflow.common.core.ApiClientException; -import com.skyflow.common.core.ApiClientHttpResponse; -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.MediaTypes; -import com.skyflow.common.core.ObjectMappers; -import com.skyflow.common.core.RequestOptions; -import com.skyflow.common.errors.BadRequestError; -import com.skyflow.common.errors.NotFoundError; -import com.skyflow.common.errors.UnauthorizedError; -import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.common.types.V1GetAuthTokenResponse; -import java.io.IOException; -import java.util.Map; -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 AsyncRawAuthenticationClient { - protected final ClientOptions clientOptions; - - public AsyncRawAuthenticationClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public CompletableFuture> authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request) { - return authenticationServiceGetAuthToken(request, null); - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public CompletableFuture> authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/auth/sa/oauth/token") - .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(), V1GetAuthTokenResponse.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - future.completeExceptionally(new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), - response)); - return; - case 401: - future.completeExceptionally(new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), - response)); - return; - case 404: - future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), - 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/common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java deleted file mode 100644 index b806d785..00000000 --- a/common/src/main/java/com/skyflow/common/resources/authentication/AuthenticationClient.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.resources.authentication; - -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.RequestOptions; -import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.common.types.V1GetAuthTokenResponse; - -public class AuthenticationClient { - protected final ClientOptions clientOptions; - - private final RawAuthenticationClient rawClient; - - public AuthenticationClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawAuthenticationClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawAuthenticationClient withRawResponse() { - return this.rawClient; - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public V1GetAuthTokenResponse authenticationServiceGetAuthToken(V1GetAuthTokenRequest request) { - return this.rawClient.authenticationServiceGetAuthToken(request).body(); - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public V1GetAuthTokenResponse authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request, RequestOptions requestOptions) { - return this.rawClient - .authenticationServiceGetAuthToken(request, requestOptions) - .body(); - } -} diff --git a/common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java b/common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java deleted file mode 100644 index f6b7ab2d..00000000 --- a/common/src/main/java/com/skyflow/common/resources/authentication/RawAuthenticationClient.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.resources.authentication; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.skyflow.common.core.ApiClientApiException; -import com.skyflow.common.core.ApiClientException; -import com.skyflow.common.core.ApiClientHttpResponse; -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.MediaTypes; -import com.skyflow.common.core.ObjectMappers; -import com.skyflow.common.core.RequestOptions; -import com.skyflow.common.errors.BadRequestError; -import com.skyflow.common.errors.NotFoundError; -import com.skyflow.common.errors.UnauthorizedError; -import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.common.types.V1GetAuthTokenResponse; -import java.io.IOException; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawAuthenticationClient { - protected final ClientOptions clientOptions; - - public RawAuthenticationClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public ApiClientHttpResponse authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request) { - return authenticationServiceGetAuthToken(request, null); - } - - /** - *

<p>Generates a Bearer Token to authenticate with Skyflow. This method doesn't require the <code>Authorization</code> header.</p><p><b>Note:</b> For recommended ways to authenticate, see <a href='/api-authentication/'>API authentication</a>.</p>

- */ - public ApiClientHttpResponse authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/auth/sa/oauth/token") - .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(), V1GetAuthTokenResponse.class), - response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), - response); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), - response); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), - 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/common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java b/common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java deleted file mode 100644 index ca0f086f..00000000 --- a/common/src/main/java/com/skyflow/common/resources/authentication/requests/V1GetAuthTokenRequest.java +++ /dev/null @@ -1,335 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.resources.authentication.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.common.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 = V1GetAuthTokenRequest.Builder.class) -public final class V1GetAuthTokenRequest { - private final String grantType; - - private final String assertion; - - private final Optional subjectToken; - - private final Optional subjectTokenType; - - private final Optional requestedTokenUse; - - private final Optional scope; - - private final Map additionalProperties; - - private V1GetAuthTokenRequest( - String grantType, - String assertion, - Optional subjectToken, - Optional subjectTokenType, - Optional requestedTokenUse, - Optional scope, - Map additionalProperties) { - this.grantType = grantType; - this.assertion = assertion; - this.subjectToken = subjectToken; - this.subjectTokenType = subjectTokenType; - this.requestedTokenUse = requestedTokenUse; - this.scope = scope; - this.additionalProperties = additionalProperties; - } - - /** - * @return Grant type of the request. Set this to urn:ietf:params:oauth:grant-type:jwt-bearer. - */ - @JsonProperty("grant_type") - public String getGrantType() { - return grantType; - } - - /** - * @return User-signed JWT token that contains the following fields: <br/> <ul><li><code>iss</code>: Issuer of the JWT.</li><li><code>key</code>: Unique identifier for the key.</li><li><code>aud</code>: Recipient the JWT is intended for.</li><li><code>exp</code>: Time the JWT expires.</li><li><code>sub</code>: Subject of the JWT.</li><li><code>ctx</code>: (Optional) Value for <a href='/context-aware-overview/'>Context-aware authorization</a>.</li></ul> - */ - @JsonProperty("assertion") - public String getAssertion() { - return assertion; - } - - /** - * @return Subject token. - */ - @JsonProperty("subject_token") - public Optional getSubjectToken() { - return subjectToken; - } - - /** - * @return Subject token type. - */ - @JsonProperty("subject_token_type") - public Optional getSubjectTokenType() { - return subjectTokenType; - } - - /** - * @return Token use type. Either delegation or impersonation. - */ - @JsonProperty("requested_token_use") - public Optional getRequestedTokenUse() { - return requestedTokenUse; - } - - /** - * @return Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>". - */ - @JsonProperty("scope") - public Optional getScope() { - return scope; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1GetAuthTokenRequest && equalTo((V1GetAuthTokenRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1GetAuthTokenRequest other) { - return grantType.equals(other.grantType) - && assertion.equals(other.assertion) - && subjectToken.equals(other.subjectToken) - && subjectTokenType.equals(other.subjectTokenType) - && requestedTokenUse.equals(other.requestedTokenUse) - && scope.equals(other.scope); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.grantType, - this.assertion, - this.subjectToken, - this.subjectTokenType, - this.requestedTokenUse, - this.scope); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static GrantTypeStage builder() { - return new Builder(); - } - - public interface GrantTypeStage { - /** - * Grant type of the request. Set this to `urn:ietf:params:oauth:grant-type:jwt-bearer`. - */ - AssertionStage grantType(@NotNull String grantType); - - Builder from(V1GetAuthTokenRequest other); - } - - public interface AssertionStage { - /** - * User-signed JWT token that contains the following fields:
  • iss: Issuer of the JWT.
  • key: Unique identifier for the key.
  • aud: Recipient the JWT is intended for.
  • exp: Time the JWT expires.
  • sub: Subject of the JWT.
  • ctx: (Optional) Value for Context-aware authorization.
- */ - _FinalStage assertion(@NotNull String assertion); - } - - public interface _FinalStage { - V1GetAuthTokenRequest build(); - - /** - *

Subject token.

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

Subject token type.

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

Token use type. Either delegation or impersonation.

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

- */ - _FinalStage scope(Optional scope); - - _FinalStage scope(String scope); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements GrantTypeStage, AssertionStage, _FinalStage { - private String grantType; - - private String assertion; - - private Optional scope = Optional.empty(); - - private Optional requestedTokenUse = Optional.empty(); - - private Optional subjectTokenType = Optional.empty(); - - private Optional subjectToken = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(V1GetAuthTokenRequest other) { - grantType(other.getGrantType()); - assertion(other.getAssertion()); - subjectToken(other.getSubjectToken()); - subjectTokenType(other.getSubjectTokenType()); - requestedTokenUse(other.getRequestedTokenUse()); - scope(other.getScope()); - return this; - } - - /** - * Grant type of the request. Set this to `urn:ietf:params:oauth:grant-type:jwt-bearer`.

Grant type of the request. Set this to urn:ietf:params:oauth:grant-type:jwt-bearer.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("grant_type") - public AssertionStage grantType(@NotNull String grantType) { - this.grantType = Objects.requireNonNull(grantType, "grantType must not be null"); - return this; - } - - /** - * User-signed JWT token that contains the following fields:
  • iss: Issuer of the JWT.
  • key: Unique identifier for the key.
  • aud: Recipient the JWT is intended for.
  • exp: Time the JWT expires.
  • sub: Subject of the JWT.
  • ctx: (Optional) Value for Context-aware authorization.

User-signed JWT token that contains the following fields: <br/> <ul><li><code>iss</code>: Issuer of the JWT.</li><li><code>key</code>: Unique identifier for the key.</li><li><code>aud</code>: Recipient the JWT is intended for.</li><li><code>exp</code>: Time the JWT expires.</li><li><code>sub</code>: Subject of the JWT.</li><li><code>ctx</code>: (Optional) Value for <a href='/context-aware-overview/'>Context-aware authorization</a>.</li></ul>

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Token use type. Either delegation or impersonation.

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

Token use type. Either delegation or impersonation.

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

Subject token type.

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

Subject token type.

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

Subject token.

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

Subject token.

- */ - @java.lang.Override - @JsonSetter(value = "subject_token", nulls = Nulls.SKIP) - public _FinalStage subjectToken(Optional subjectToken) { - this.subjectToken = subjectToken; - return this; - } - - @java.lang.Override - public V1GetAuthTokenRequest build() { - return new V1GetAuthTokenRequest( - grantType, - assertion, - subjectToken, - subjectTokenType, - requestedTokenUse, - scope, - additionalProperties); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java deleted file mode 100644 index b7a00648..00000000 --- a/common/src/main/java/com/skyflow/common/serviceaccount/util/BearerToken.java +++ /dev/null @@ -1,229 +0,0 @@ -package com.skyflow.common.serviceaccount.util; - -import com.google.gson.*; -import com.skyflow.common.ApiClient; -import com.skyflow.common.ApiClientBuilder; -import com.skyflow.common.core.ApiClientApiException; -import com.skyflow.common.resources.authentication.AuthenticationClient; -import com.skyflow.common.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.common.types.V1GetAuthTokenResponse; -import com.skyflow.common.errors.ErrorCode; -import com.skyflow.common.errors.ErrorMessage; -import com.skyflow.common.errors.SkyflowException; -import com.skyflow.common.logs.ErrorLogs; -import com.skyflow.common.logs.InfoLogs; -import com.skyflow.common.utils.Constants; -import com.skyflow.common.utils.Utils; -import com.skyflow.common.utils.logger.LogUtil; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.net.MalformedURLException; -import java.security.PrivateKey; -import java.util.ArrayList; -import java.util.Date; -import java.util.Objects; - -public class BearerToken { - private static final Gson gson = new GsonBuilder().serializeNulls().create(); - private static final ApiClientBuilder apiClientBuilder = new ApiClientBuilder(); - private final File credentialsFile; - private final String credentialsString; - private final String ctx; - private final ArrayList roles; - private final String credentialsType; - - private BearerToken(BearerTokenBuilder builder) { - this.credentialsFile = builder.credentialsFile; - this.credentialsString = builder.credentialsString; - this.ctx = builder.ctx; - this.roles = builder.roles; - this.credentialsType = builder.credentialsType; - } - - public static BearerTokenBuilder builder() { - return new BearerTokenBuilder(); - } - - private static V1GetAuthTokenResponse generateBearerTokenFromCredentials( - File credentialsFile, String context, ArrayList roles - ) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED.getLog()); - try { - if (credentialsFile == null) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); - } - FileReader reader = new FileReader(String.valueOf(credentialsFile)); - JsonObject serviceAccountCredentials = JsonParser.parseReader(reader).getAsJsonObject(); - return getBearerTokenFromCredentials(serviceAccountCredentials, context, roles); - } catch (JsonSyntaxException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( - ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath())); - } catch (FileNotFoundException e) { - LogUtil.printErrorLog(ErrorLogs.CREDENTIALS_FILE_NOT_FOUND.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( - ErrorMessage.FileNotFound.getMessage(), credentialsFile.getPath())); - } - } - - private static V1GetAuthTokenResponse generateBearerTokenFromCredentialString( - String credentials, String context, ArrayList roles - ) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED.getLog()); - try { - if (credentials == null || credentials.isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); - } - JsonObject serviceAccountCredentials = JsonParser.parseString(credentials).getAsJsonObject(); - return getBearerTokenFromCredentials(serviceAccountCredentials, context, roles); - } catch (JsonSyntaxException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.CredentialsStringInvalidJson.getMessage()); - } - } - - private static V1GetAuthTokenResponse getBearerTokenFromCredentials( - JsonObject credentials, String context, ArrayList roles - ) throws SkyflowException { - try { - JsonElement privateKey = credentials.get("privateKey"); - if (privateKey == null) { - LogUtil.printErrorLog(ErrorLogs.PRIVATE_KEY_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingPrivateKey.getMessage()); - } - - JsonElement clientID = credentials.get("clientID"); - if (clientID == null) { - LogUtil.printErrorLog(ErrorLogs.CLIENT_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingClientId.getMessage()); - } - - JsonElement keyID = credentials.get("keyID"); - if (keyID == null) { - LogUtil.printErrorLog(ErrorLogs.KEY_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingKeyId.getMessage()); - } - - JsonElement tokenURI = credentials.get("tokenURI"); - if (tokenURI == null) { - LogUtil.printErrorLog(ErrorLogs.TOKEN_URI_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingTokenUri.getMessage()); - } - - PrivateKey pvtKey = Utils.getPrivateKeyFromPem(privateKey.getAsString()); - String signedUserJWT = getSignedToken( - clientID.getAsString(), keyID.getAsString(), tokenURI.getAsString(), pvtKey, context - ); - - String basePath = Utils.getBaseURL(tokenURI.getAsString()); - apiClientBuilder.url(basePath); - ApiClient apiClient = apiClientBuilder.token("token").build(); - AuthenticationClient authenticationApi = apiClient.authentication(); - - V1GetAuthTokenRequest._FinalStage authTokenBuilder = V1GetAuthTokenRequest.builder().grantType(Constants.GRANT_TYPE).assertion(signedUserJWT); - - if (roles != null) { - String scopedRoles = getScopeUsingRoles(roles); - authTokenBuilder.scope(scopedRoles); - } - return authenticationApi.authenticationServiceGetAuthToken(authTokenBuilder.build()); - } catch (MalformedURLException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_TOKEN_URI.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTokenUri.getMessage()); - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.BEARER_TOKEN_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - } - - private static String getSignedToken( - String clientID, String keyID, String tokenURI, PrivateKey pvtKey, String context - ) { - final Date createdDate = new Date(); - final Date expirationDate = new Date(createdDate.getTime() + (3600 * 1000)); - return Jwts.builder() - .claim("iss", clientID) - .claim("key", keyID) - .claim("aud", tokenURI) - .claim("sub", clientID) - .claim("ctx", context) - .setExpiration(expirationDate) - .signWith(SignatureAlgorithm.RS256, pvtKey) - .compact(); - } - - private static String getScopeUsingRoles(ArrayList roles) { - StringBuilder scope = new StringBuilder(); - if (roles != null) { - for (String role : roles) { - scope.append(" role:").append(role); - } - } - return scope.toString(); - } - - public synchronized String getBearerToken() throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GET_BEARER_TOKEN_TRIGGERED.getLog()); - V1GetAuthTokenResponse response; - String accessToken = null; - if (this.credentialsFile != null && Objects.equals(this.credentialsType, "FILE")) { - response = generateBearerTokenFromCredentials(this.credentialsFile, this.ctx, this.roles); - accessToken = response.getAccessToken().get(); - } else if (this.credentialsString != null && Objects.equals(this.credentialsType, "STRING")) { - response = generateBearerTokenFromCredentialString(this.credentialsString, this.ctx, this.roles); - accessToken = response.getAccessToken().get(); - } - LogUtil.printInfoLog(InfoLogs.GET_BEARER_TOKEN_SUCCESS.getLog()); - return accessToken; - } - - // Builder class - public static class BearerTokenBuilder { - private File credentialsFile; - private String credentialsString; - private String ctx; - private ArrayList roles; - private String credentialsType; - - private BearerTokenBuilder() { - } - - private void setCredentialsType(String credentialsType) { - this.credentialsType = credentialsType; - } - - public BearerTokenBuilder setCredentials(File credentialsFile) { - setCredentialsType("FILE"); - this.credentialsFile = credentialsFile; - return this; - } - - public BearerTokenBuilder setCredentials(String credentialsString) { - setCredentialsType("STRING"); - this.credentialsString = credentialsString; - return this; - } - - public BearerTokenBuilder setCtx(String ctx) { - this.ctx = ctx; - return this; - } - - public BearerTokenBuilder setRoles(ArrayList roles) { - this.roles = roles; - return this; - } - - public BearerToken build() { - return new BearerToken(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java deleted file mode 100644 index dfdd40bd..00000000 --- a/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokenResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.skyflow.common.serviceaccount.util; - -import com.google.gson.Gson; -import com.skyflow.common.utils.Constants; - -public class SignedDataTokenResponse { - private static final String prefix = Constants.SIGNED_DATA_TOKEN_PREFIX; - private final String token; - private final String signedToken; - - public SignedDataTokenResponse(String token, String signedToken) { - this.token = token; - this.signedToken = new StringBuilder(prefix).append(signedToken).toString(); - } - - public String getToken() { - return token; - } - - public String getSignedToken() { - return signedToken; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java deleted file mode 100644 index 5d7f1e18..00000000 --- a/common/src/main/java/com/skyflow/common/serviceaccount/util/SignedDataTokens.java +++ /dev/null @@ -1,213 +0,0 @@ -package com.skyflow.common.serviceaccount.util; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; -import com.skyflow.common.errors.ErrorCode; -import com.skyflow.common.errors.ErrorMessage; -import com.skyflow.common.errors.SkyflowException; -import com.skyflow.common.logs.ErrorLogs; -import com.skyflow.common.logs.InfoLogs; -import com.skyflow.common.utils.Utils; -import com.skyflow.common.utils.logger.LogUtil; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.security.PrivateKey; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; - -public class SignedDataTokens { - private final File credentialsFile; - private final String credentialsString; - private final String credentialsType; - private final String ctx; - private final ArrayList dataTokens; - private final Integer timeToLive; - - private SignedDataTokens(SignedDataTokensBuilder builder) { - this.credentialsFile = builder.credentialsFile; - this.credentialsString = builder.credentialsString; - this.credentialsType = builder.credentialsType; - this.ctx = builder.ctx; - this.dataTokens = builder.dataTokens; - this.timeToLive = builder.timeToLive; - } - - public static SignedDataTokensBuilder builder() { - return new SignedDataTokensBuilder(); - } - - private static List generateSignedTokenFromCredentialsFile( - File credentialsFile, ArrayList dataTokens, Integer timeToLive, String context - ) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED.getLog()); - List responseToken; - try { - if (credentialsFile == null) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); - } - FileReader reader = new FileReader(String.valueOf(credentialsFile)); - JsonObject serviceAccountCredentials = JsonParser.parseReader(reader).getAsJsonObject(); - responseToken = generateSignedTokensFromCredentials(serviceAccountCredentials, dataTokens, timeToLive, context); - } catch (JsonSyntaxException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( - ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath())); - } catch (FileNotFoundException e) { - LogUtil.printErrorLog(ErrorLogs.CREDENTIALS_FILE_NOT_FOUND.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( - ErrorMessage.FileNotFound.getMessage(), credentialsFile.getPath())); - } - return responseToken; - } - - private static List generateSignedTokensFromCredentialsString( - String credentials, ArrayList dataTokens, Integer timeToLive, String context - ) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_STRING_TRIGGERED.getLog()); - List responseToken; - try { - if (credentials == null || credentials.isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage()); - } - JsonObject serviceAccountCredentials = JsonParser.parseString(credentials).getAsJsonObject(); - responseToken = generateSignedTokensFromCredentials(serviceAccountCredentials, dataTokens, timeToLive, context); - } catch (JsonSyntaxException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.CredentialsStringInvalidJson.getMessage()); - } - return responseToken; - } - - private static List generateSignedTokensFromCredentials( - JsonObject credentials, ArrayList dataTokens, Integer timeToLive, String context - ) throws SkyflowException { - List signedDataTokens = null; - try { - JsonElement privateKey = credentials.get("privateKey"); - if (privateKey == null) { - LogUtil.printErrorLog(ErrorLogs.PRIVATE_KEY_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingPrivateKey.getMessage()); - } - - JsonElement clientID = credentials.get("clientID"); - if (clientID == null) { - LogUtil.printErrorLog(ErrorLogs.CLIENT_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingClientId.getMessage()); - } - - JsonElement keyID = credentials.get("keyID"); - if (keyID == null) { - LogUtil.printErrorLog(ErrorLogs.KEY_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingKeyId.getMessage()); - } - PrivateKey pvtKey = Utils.getPrivateKeyFromPem(privateKey.getAsString()); - signedDataTokens = getSignedToken( - clientID.getAsString(), keyID.getAsString(), pvtKey, dataTokens, timeToLive, context); - } catch (RuntimeException e) { - LogUtil.printErrorLog(ErrorLogs.SIGNED_DATA_TOKENS_REJECTED.getLog()); - throw new SkyflowException(e); - } - return signedDataTokens; - } - - private static List getSignedToken( - String clientID, String keyID, PrivateKey pvtKey, - ArrayList dataTokens, Integer timeToLive, String context - ) { - final Date createdDate = new Date(); - final Date expirationDate; - - if (timeToLive != null) { - expirationDate = new Date(createdDate.getTime() + (timeToLive * 1000)); - } else { - expirationDate = new Date(createdDate.getTime() + 60000); // Valid for 60 seconds - } - - List list = new ArrayList<>(); - for (String dataToken : dataTokens) { - String eachSignedDataToken = Jwts.builder() - .claim("iss", "sdk") - .claim("iat", (createdDate.getTime() / 1000)) - .claim("key", keyID) - .claim("sub", clientID) - .claim("ctx", context) - .claim("tok", dataToken) - .setExpiration(expirationDate) - .signWith(SignatureAlgorithm.RS256, pvtKey) - .compact(); - SignedDataTokenResponse responseObject = new SignedDataTokenResponse(dataToken, eachSignedDataToken); - list.add(responseObject); - } - return list; - } - - public synchronized List getSignedDataTokens() throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GET_SIGNED_DATA_TOKENS_TRIGGERED.getLog()); - List signedToken = new ArrayList<>(); - if (this.credentialsFile != null && Objects.equals(this.credentialsType, "FILE")) { - signedToken = generateSignedTokenFromCredentialsFile(this.credentialsFile, this.dataTokens, this.timeToLive, this.ctx); - } else if (this.credentialsString != null && Objects.equals(this.credentialsType, "STRING")) { - signedToken = generateSignedTokensFromCredentialsString(this.credentialsString, this.dataTokens, this.timeToLive, this.ctx); - } - LogUtil.printInfoLog(InfoLogs.GET_SIGNED_DATA_TOKEN_SUCCESS.getLog()); - return signedToken; - } - - public static class SignedDataTokensBuilder { - private ArrayList dataTokens; - private Integer timeToLive; - private File credentialsFile; - private String credentialsString; - private String ctx; - private String credentialsType; - - private SignedDataTokensBuilder() { - } - - private void setCredentialsType(String credentialsType) { - this.credentialsType = credentialsType; - } - - public SignedDataTokensBuilder setCredentials(File credentialsFile) { - setCredentialsType("FILE"); - this.credentialsFile = credentialsFile; - return this; - } - - public SignedDataTokensBuilder setCredentials(String credentialsString) { - setCredentialsType("STRING"); - this.credentialsString = credentialsString; - return this; - } - - public SignedDataTokensBuilder setCtx(String ctx) { - this.ctx = ctx; - return this; - } - - public SignedDataTokensBuilder setDataTokens(ArrayList dataTokens) { - this.dataTokens = dataTokens; - return this; - } - - public SignedDataTokensBuilder setTimeToLive(Integer timeToLive) { - this.timeToLive = timeToLive; - return this; - } - - public SignedDataTokens build() { - return new SignedDataTokens(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java b/common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java deleted file mode 100644 index c72e3809..00000000 --- a/common/src/main/java/com/skyflow/common/serviceaccount/util/Token.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.skyflow.common.serviceaccount.util; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; -import com.skyflow.common.errors.ErrorCode; -import com.skyflow.common.errors.ErrorMessage; -import com.skyflow.common.errors.SkyflowException; -import com.skyflow.common.logs.ErrorLogs; -import com.skyflow.common.logs.InfoLogs; -import com.skyflow.common.utils.logger.LogUtil; -import org.apache.commons.codec.binary.Base64; - -import java.nio.charset.StandardCharsets; -import java.util.Date; - -public class Token { - public static boolean isExpired(String token) { - long expiryTime; - long currentTime; - try { - if (token == null || token.trim().isEmpty()) { - LogUtil.printInfoLog(InfoLogs.EMPTY_BEARER_TOKEN.getLog()); - return true; - } - - currentTime = new Date().getTime() / 1000; - expiryTime = decoded(token).get("exp").getAsLong(); - - } catch (JsonSyntaxException | SkyflowException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); - return true; - } - return currentTime > expiryTime; - } - - static JsonObject decoded(String encodedToken) throws JsonSyntaxException, SkyflowException { - String[] split = encodedToken.split("\\."); - if (split.length < 3) { - LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.JwtDecodeError.getMessage()); - } - byte[] decodedBytes = Base64.decodeBase64(split[1]); - return JsonParser.parseString(new String(decodedBytes, StandardCharsets.UTF_8)).getAsJsonObject(); - } -} diff --git a/common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java b/common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java deleted file mode 100644 index 13687f8a..00000000 --- a/common/src/main/java/com/skyflow/common/types/GooglerpcStatus.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.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.common.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 = GooglerpcStatus.Builder.class) -public final class GooglerpcStatus { - private final Optional code; - - private final Optional message; - - private final Optional> details; - - private final Map additionalProperties; - - private GooglerpcStatus( - Optional code, - Optional message, - Optional> details, - Map additionalProperties) { - this.code = code; - this.message = message; - this.details = details; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("code") - public Optional getCode() { - return code; - } - - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @JsonProperty("details") - public Optional> getDetails() { - return details; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GooglerpcStatus && equalTo((GooglerpcStatus) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GooglerpcStatus other) { - return code.equals(other.code) && message.equals(other.message) && details.equals(other.details); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.code, this.message, this.details); - } - - @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 code = Optional.empty(); - - private Optional message = Optional.empty(); - - private Optional> details = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(GooglerpcStatus other) { - code(other.getCode()); - message(other.getMessage()); - details(other.getDetails()); - return this; - } - - @JsonSetter(value = "code", nulls = Nulls.SKIP) - public Builder code(Optional code) { - this.code = code; - return this; - } - - public Builder code(Integer code) { - this.code = Optional.ofNullable(code); - return this; - } - - @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; - } - - @JsonSetter(value = "details", nulls = Nulls.SKIP) - public Builder details(Optional> details) { - this.details = details; - return this; - } - - public Builder details(List details) { - this.details = Optional.ofNullable(details); - return this; - } - - public GooglerpcStatus build() { - return new GooglerpcStatus(code, message, details, additionalProperties); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/types/ProtobufAny.java b/common/src/main/java/com/skyflow/common/types/ProtobufAny.java deleted file mode 100644 index fec45abf..00000000 --- a/common/src/main/java/com/skyflow/common/types/ProtobufAny.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.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.common.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 = ProtobufAny.Builder.class) -public final class ProtobufAny { - private final Optional type; - - private final Map additionalProperties; - - private ProtobufAny(Optional type, Map additionalProperties) { - this.type = type; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("@type") - public Optional getType() { - return type; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProtobufAny && equalTo((ProtobufAny) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProtobufAny other) { - return type.equals(other.type); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type); - } - - @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 type = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ProtobufAny other) { - type(other.getType()); - return this; - } - - @JsonSetter(value = "@type", nulls = Nulls.SKIP) - public Builder type(Optional type) { - this.type = type; - return this; - } - - public Builder type(String type) { - this.type = Optional.ofNullable(type); - return this; - } - - public ProtobufAny build() { - return new ProtobufAny(type, additionalProperties); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java b/common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java deleted file mode 100644 index 4ee50804..00000000 --- a/common/src/main/java/com/skyflow/common/types/V1GetAuthTokenResponse.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.common.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.common.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 = V1GetAuthTokenResponse.Builder.class) -public final class V1GetAuthTokenResponse { - private final Optional accessToken; - - private final Optional tokenType; - - private final Map additionalProperties; - - private V1GetAuthTokenResponse( - Optional accessToken, Optional tokenType, Map additionalProperties) { - this.accessToken = accessToken; - this.tokenType = tokenType; - this.additionalProperties = additionalProperties; - } - - /** - * @return AccessToken. - */ - @JsonProperty("accessToken") - public Optional getAccessToken() { - return accessToken; - } - - /** - * @return TokenType : Bearer. - */ - @JsonProperty("tokenType") - public Optional getTokenType() { - return tokenType; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1GetAuthTokenResponse && equalTo((V1GetAuthTokenResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1GetAuthTokenResponse other) { - return accessToken.equals(other.accessToken) && tokenType.equals(other.tokenType); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.accessToken, this.tokenType); - } - - @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 accessToken = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1GetAuthTokenResponse other) { - accessToken(other.getAccessToken()); - tokenType(other.getTokenType()); - return this; - } - - /** - *

AccessToken.

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

TokenType : Bearer.

- */ - @JsonSetter(value = "tokenType", nulls = Nulls.SKIP) - public Builder tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - public Builder tokenType(String tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - public V1GetAuthTokenResponse build() { - return new V1GetAuthTokenResponse(accessToken, tokenType, additionalProperties); - } - } -} diff --git a/common/src/main/java/com/skyflow/common/utils/Constants.java b/common/src/main/java/com/skyflow/common/utils/Constants.java deleted file mode 100644 index 0a778dde..00000000 --- a/common/src/main/java/com/skyflow/common/utils/Constants.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.skyflow.common.utils; - -public final class Constants { - public static final String SECURE_PROTOCOL = "https://"; - public static final String DEV_DOMAIN = ".vault.skyflowapis.dev"; - public static final String STAGE_DOMAIN = ".vault.skyflowapis.tech"; - public static final String SANDBOX_DOMAIN = ".vault.skyflowapis-preview.com"; - public static final String PROD_DOMAIN = ".vault.skyflowapis.com"; - public static final String PKCS8_PRIVATE_HEADER = "-----BEGIN PRIVATE KEY-----"; - public static final String PKCS8_PRIVATE_FOOTER = "-----END PRIVATE KEY-----"; - public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; - public static final String SIGNED_DATA_TOKEN_PREFIX = "signed_token_"; - public static final String ORDER_ASCENDING = "ASCENDING"; - public static final String API_KEY_REGEX = "^sky-[a-zA-Z0-9]{5}-[a-fA-F0-9]{32}$"; - public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; - public static final String SDK_NAME = "Skyflow Java SDK "; - public static final String SDK_VERSION = "v2"; - public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; - public static final String SDK_METRIC_NAME_VERSION = "sdk_name_version"; - public static final String SDK_METRIC_NAME_VERSION_PREFIX = "skyflow-java@"; - public static final String SDK_METRIC_CLIENT_DEVICE_MODEL = "sdk_client_device_model"; - public static final String SDK_METRIC_CLIENT_OS_DETAILS = "sdk_client_os_details"; - public static final String SDK_METRIC_RUNTIME_DETAILS = "sdk_runtime_details"; - public static final String SDK_METRIC_RUNTIME_DETAILS_PREFIX = "Java@"; - public static final String SDK_AUTH_HEADER_KEY = "x-skyflow-authorization"; - 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"; -} diff --git a/common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java b/common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java deleted file mode 100644 index 5e2eb136..00000000 --- a/common/src/main/java/com/skyflow/common/utils/logger/LogUtil.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.skyflow.common.utils.logger; - -import com.skyflow.common.logs.InfoLogs; -import com.skyflow.common.utils.Constants; -import com.skyflow.common.enums.LogLevel; - -import java.util.logging.*; - -public final class LogUtil { - private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName()); - private static final String SDK_LOG_PREFIX = "[" + Constants.SDK_PREFIX + "] "; - private static boolean IS_LOGGER_SETUP_DONE = false; - - synchronized public static void setupLogger(LogLevel logLevel) { - IS_LOGGER_SETUP_DONE = true; - LogManager.getLogManager().reset(); - LOGGER.setUseParentHandlers(false); - Formatter formatter = new SimpleFormatter() { - private static final String format = "%s: %s %n"; - - // Override format method - @Override - public synchronized String format(LogRecord logRecord) { - return String.format( - format, - loggerLevelToLogLevelMap(logRecord.getLevel()), - logRecord.getMessage() - ); - } - }; - ConsoleHandler consoleHandler = new ConsoleHandler(); - consoleHandler.setFormatter(formatter); - consoleHandler.setLevel(Level.CONFIG); - - LOGGER.addHandler(consoleHandler); - LOGGER.setLevel(logLevelToLoggerLevelMap(logLevel)); - printInfoLog(InfoLogs.LOGGER_SETUP_DONE.getLog()); - } - - public static void printErrorLog(String message) { - if (IS_LOGGER_SETUP_DONE) - LOGGER.severe(SDK_LOG_PREFIX + message); - else { - setupLogger(LogLevel.ERROR); - LOGGER.severe(SDK_LOG_PREFIX + message); - } - } - - public static void printDebugLog(String message) { - if (IS_LOGGER_SETUP_DONE) - LOGGER.config(SDK_LOG_PREFIX + message); - } - - public static void printWarningLog(String message) { - if (IS_LOGGER_SETUP_DONE) - LOGGER.warning(SDK_LOG_PREFIX + message); - } - - public static void printInfoLog(String message) { - if (IS_LOGGER_SETUP_DONE) - LOGGER.info(SDK_LOG_PREFIX + message); - } - - - private static Level logLevelToLoggerLevelMap(LogLevel logLevel) { - Level loggerLevel; - switch (logLevel) { - case ERROR: - loggerLevel = Level.SEVERE; - break; - case WARN: - loggerLevel = Level.WARNING; - break; - case INFO: - loggerLevel = Level.INFO; - break; - case DEBUG: - loggerLevel = Level.CONFIG; - break; - default: - loggerLevel = Level.OFF; - } - return loggerLevel; - } - - private static LogLevel loggerLevelToLogLevelMap(Level loggerLevel) { - LogLevel logLevel; - if (Level.SEVERE.equals(loggerLevel)) { - logLevel = LogLevel.ERROR; - } else if (Level.WARNING.equals(loggerLevel)) { - logLevel = LogLevel.WARN; - } else if (Level.INFO.equals(loggerLevel)) { - logLevel = LogLevel.INFO; - } else if (Level.CONFIG.equals(loggerLevel)) { - logLevel = LogLevel.DEBUG; - } else - logLevel = LogLevel.OFF; - return logLevel; - } -} diff --git a/src/main/java/com/skyflow/config/Credentials.java b/common/src/main/java/com/skyflow/config/Credentials.java similarity index 100% rename from src/main/java/com/skyflow/config/Credentials.java rename to common/src/main/java/com/skyflow/config/Credentials.java diff --git a/src/main/java/com/skyflow/config/VaultConfig.java b/common/src/main/java/com/skyflow/config/VaultConfig.java similarity index 100% rename from src/main/java/com/skyflow/config/VaultConfig.java rename to common/src/main/java/com/skyflow/config/VaultConfig.java diff --git a/src/main/java/com/skyflow/enums/Env.java b/common/src/main/java/com/skyflow/enums/Env.java similarity index 100% rename from src/main/java/com/skyflow/enums/Env.java rename to common/src/main/java/com/skyflow/enums/Env.java diff --git a/src/main/java/com/skyflow/enums/InterfaceName.java b/common/src/main/java/com/skyflow/enums/InterfaceName.java similarity index 100% rename from src/main/java/com/skyflow/enums/InterfaceName.java rename to common/src/main/java/com/skyflow/enums/InterfaceName.java diff --git a/src/main/java/com/skyflow/enums/LogLevel.java b/common/src/main/java/com/skyflow/enums/LogLevel.java similarity index 100% rename from src/main/java/com/skyflow/enums/LogLevel.java rename to common/src/main/java/com/skyflow/enums/LogLevel.java diff --git a/src/main/java/com/skyflow/errors/ErrorCode.java b/common/src/main/java/com/skyflow/errors/ErrorCode.java similarity index 100% rename from src/main/java/com/skyflow/errors/ErrorCode.java rename to common/src/main/java/com/skyflow/errors/ErrorCode.java diff --git a/v2/src/main/java/com/skyflow/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/errors/ErrorMessage.java similarity index 98% rename from v2/src/main/java/com/skyflow/errors/ErrorMessage.java rename to common/src/main/java/com/skyflow/errors/ErrorMessage.java index df075bca..e3b0bbbe 100644 --- a/v2/src/main/java/com/skyflow/errors/ErrorMessage.java +++ b/common/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -1,6 +1,6 @@ package com.skyflow.errors; -import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; public enum ErrorMessage { // Client initialization @@ -145,7 +145,7 @@ public enum ErrorMessage { 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."), 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."), + 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."), // Generic ErrorOccurred("%s0 API error. Error occurred.") @@ -153,7 +153,7 @@ public enum ErrorMessage { private final String message; ErrorMessage(String message) { - this.message = message.replace("%s0", Constants.SDK_PREFIX); + this.message = message.replace("%s0", SdkVersion.getSdkPrefix()); } public String getMessage() { diff --git a/src/main/java/com/skyflow/errors/HttpStatus.java b/common/src/main/java/com/skyflow/errors/HttpStatus.java similarity index 100% rename from src/main/java/com/skyflow/errors/HttpStatus.java rename to common/src/main/java/com/skyflow/errors/HttpStatus.java diff --git a/src/main/java/com/skyflow/errors/SkyflowException.java b/common/src/main/java/com/skyflow/errors/SkyflowException.java similarity index 96% rename from src/main/java/com/skyflow/errors/SkyflowException.java rename to common/src/main/java/com/skyflow/errors/SkyflowException.java index 32c71f39..138fcc68 100644 --- a/src/main/java/com/skyflow/errors/SkyflowException.java +++ b/common/src/main/java/com/skyflow/errors/SkyflowException.java @@ -4,7 +4,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.skyflow.utils.Constants; +import com.skyflow.utils.BaseConstants; import java.util.List; import java.util.Map; @@ -70,7 +70,7 @@ public String getRequestId() { } private void setRequestId(Map> responseHeaders) { - List ids = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY); + List ids = responseHeaders.get(BaseConstants.REQUEST_ID_HEADER_KEY); this.requestId = ids == null ? null : ids.get(0); } @@ -99,7 +99,7 @@ public JsonArray getDetails() { private void setDetails(Map> responseHeaders) { JsonElement detailsElement = ((JsonObject) responseBody.get("error")).get("details"); - List errorFromClientHeader = responseHeaders.get(Constants.ERROR_FROM_CLIENT_HEADER_KEY); + List errorFromClientHeader = responseHeaders.get(BaseConstants.ERROR_FROM_CLIENT_HEADER_KEY); if (detailsElement != null) { this.details = detailsElement.getAsJsonArray(); } diff --git a/common/src/main/java/com/skyflow/common/ApiClient.java b/common/src/main/java/com/skyflow/generated/rest/ApiClient.java similarity index 75% rename from common/src/main/java/com/skyflow/common/ApiClient.java rename to common/src/main/java/com/skyflow/generated/rest/ApiClient.java index f9aec9de..f49fc4c3 100644 --- a/common/src/main/java/com/skyflow/common/ApiClient.java +++ b/common/src/main/java/com/skyflow/generated/rest/ApiClient.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common; +package com.skyflow.generated.rest; -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.Suppliers; -import com.skyflow.common.resources.authentication.AuthenticationClient; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Suppliers; +import com.skyflow.generated.rest.resources.authentication.AuthenticationClient; import java.util.function.Supplier; public class ApiClient { diff --git a/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java rename to common/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java diff --git a/common/src/main/java/com/skyflow/common/AsyncApiClient.java b/common/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java similarity index 75% rename from common/src/main/java/com/skyflow/common/AsyncApiClient.java rename to common/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java index 310749e3..d9163e14 100644 --- a/common/src/main/java/com/skyflow/common/AsyncApiClient.java +++ b/common/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common; +package com.skyflow.generated.rest; -import com.skyflow.common.core.ClientOptions; -import com.skyflow.common.core.Suppliers; -import com.skyflow.common.resources.authentication.AsyncAuthenticationClient; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Suppliers; +import com.skyflow.generated.rest.resources.authentication.AsyncAuthenticationClient; import java.util.function.Supplier; public class AsyncApiClient { diff --git a/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java rename to common/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java diff --git a/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java b/common/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java rename to common/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java diff --git a/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java b/common/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/ApiClientException.java rename to common/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java diff --git a/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java b/common/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java rename to common/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java diff --git a/common/src/main/java/com/skyflow/common/core/ClientOptions.java b/common/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java similarity index 97% rename from common/src/main/java/com/skyflow/common/core/ClientOptions.java rename to common/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java index f60d6b56..e7388551 100644 --- a/common/src/main/java/com/skyflow/common/core/ClientOptions.java +++ b/common/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.core; +package com.skyflow.generated.rest.core; import java.util.HashMap; import java.util.Map; @@ -33,7 +33,7 @@ private ClientOptions( this.headers.putAll(new HashMap() { { put("X-Fern-Language", "JAVA"); - put("X-Fern-SDK-Name", "com.skyflow.fern:api-sdk"); + put("X-Fern-SDK-Name", "com.skyflow.generated.rest.fern:api-sdk"); put("X-Fern-SDK-Version", "0.0.279"); } }); diff --git a/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java b/common/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java rename to common/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java diff --git a/common/src/main/java/com/skyflow/common/core/Environment.java b/common/src/main/java/com/skyflow/generated/rest/core/Environment.java similarity index 93% rename from common/src/main/java/com/skyflow/common/core/Environment.java rename to common/src/main/java/com/skyflow/generated/rest/core/Environment.java index 75102104..c5a294b7 100644 --- a/common/src/main/java/com/skyflow/common/core/Environment.java +++ b/common/src/main/java/com/skyflow/generated/rest/core/Environment.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.core; +package com.skyflow.generated.rest.core; public final class Environment { public static final Environment PRODUCTION = new Environment("https://manage.skyflowapis.com"); diff --git a/src/main/java/com/skyflow/generated/rest/core/FileStream.java b/common/src/main/java/com/skyflow/generated/rest/core/FileStream.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/FileStream.java rename to common/src/main/java/com/skyflow/generated/rest/core/FileStream.java diff --git a/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java b/common/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java rename to common/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java diff --git a/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java b/common/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/MediaTypes.java rename to common/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java diff --git a/src/main/java/com/skyflow/generated/rest/core/Nullable.java b/common/src/main/java/com/skyflow/generated/rest/core/Nullable.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/Nullable.java rename to common/src/main/java/com/skyflow/generated/rest/core/Nullable.java diff --git a/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java b/common/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java rename to common/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java diff --git a/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java b/common/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java rename to common/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java diff --git a/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java b/common/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java rename to common/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java diff --git a/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java b/common/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/RequestOptions.java rename to common/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java diff --git a/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java b/common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java rename to common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java diff --git a/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java b/common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java rename to common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java diff --git a/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java b/common/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java rename to common/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java diff --git a/src/main/java/com/skyflow/generated/rest/core/Stream.java b/common/src/main/java/com/skyflow/generated/rest/core/Stream.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/Stream.java rename to common/src/main/java/com/skyflow/generated/rest/core/Stream.java diff --git a/src/main/java/com/skyflow/generated/rest/core/Suppliers.java b/common/src/main/java/com/skyflow/generated/rest/core/Suppliers.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/core/Suppliers.java rename to common/src/main/java/com/skyflow/generated/rest/core/Suppliers.java diff --git a/common/src/main/java/com/skyflow/common/errors/BadRequestError.java b/common/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java similarity index 87% rename from common/src/main/java/com/skyflow/common/errors/BadRequestError.java rename to common/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java index 85f14f70..d4b2d99f 100644 --- a/common/src/main/java/com/skyflow/common/errors/BadRequestError.java +++ b/common/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java @@ -1,9 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.errors; +package com.skyflow.generated.rest.errors; -import com.skyflow.common.core.ApiClientApiException; +import com.skyflow.generated.rest.core.ApiClientApiException; import java.util.Map; import okhttp3.Response; diff --git a/v2/src/main/java/com/skyflow/errors/HttpStatus.java b/common/src/main/java/com/skyflow/generated/rest/errors/HttpStatus.java similarity index 85% rename from v2/src/main/java/com/skyflow/errors/HttpStatus.java rename to common/src/main/java/com/skyflow/generated/rest/errors/HttpStatus.java index 2cdadbb0..dc9aecfe 100644 --- a/v2/src/main/java/com/skyflow/errors/HttpStatus.java +++ b/common/src/main/java/com/skyflow/generated/rest/errors/HttpStatus.java @@ -1,4 +1,4 @@ -package com.skyflow.errors; +package com.skyflow.generated.rest.errors; public enum HttpStatus { BAD_REQUEST("Bad Request"); diff --git a/common/src/main/java/com/skyflow/common/errors/NotFoundError.java b/common/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java similarity index 87% rename from common/src/main/java/com/skyflow/common/errors/NotFoundError.java rename to common/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java index abc4523a..46291af6 100644 --- a/common/src/main/java/com/skyflow/common/errors/NotFoundError.java +++ b/common/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java @@ -1,9 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.errors; +package com.skyflow.generated.rest.errors; -import com.skyflow.common.core.ApiClientApiException; +import com.skyflow.generated.rest.core.ApiClientApiException; import java.util.Map; import okhttp3.Response; diff --git a/common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java b/common/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java similarity index 87% rename from common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java rename to common/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java index 9625d45b..1e90cfc2 100644 --- a/common/src/main/java/com/skyflow/common/errors/UnauthorizedError.java +++ b/common/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java @@ -1,9 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.errors; +package com.skyflow.generated.rest.errors; -import com.skyflow.common.core.ApiClientApiException; +import com.skyflow.generated.rest.core.ApiClientApiException; import java.util.Map; import okhttp3.Response; diff --git a/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java diff --git a/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java similarity index 93% rename from src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java index eca4ab90..10ad0c01 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java @@ -4,6 +4,7 @@ package com.skyflow.generated.rest.resources.authentication; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.skyflow.generated.rest.core.ApiClientApiException; import com.skyflow.generated.rest.core.ApiClientException; import com.skyflow.generated.rest.core.ApiClientHttpResponse; @@ -17,6 +18,7 @@ import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; import java.io.IOException; +import java.util.Map; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -88,17 +90,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO switch (response.code()) { case 400: future.completeExceptionally(new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), response)); return; case 401: future.completeExceptionally(new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), response)); return; case 404: future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), response)); return; } diff --git a/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java diff --git a/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java similarity index 90% rename from src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java index 3d242eff..c30cf003 100644 --- a/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java @@ -4,6 +4,7 @@ package com.skyflow.generated.rest.resources.authentication; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.skyflow.generated.rest.core.ApiClientApiException; import com.skyflow.generated.rest.core.ApiClientException; import com.skyflow.generated.rest.core.ApiClientHttpResponse; @@ -17,6 +18,7 @@ import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; import java.io.IOException; +import java.util.Map; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -79,13 +81,19 @@ public ApiClientHttpResponse authenticationServiceGetAut switch (response.code()) { case 400: throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); case 401: throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); case 404: throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error diff --git a/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java b/common/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java rename to common/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java diff --git a/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java b/common/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java rename to common/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java diff --git a/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java b/common/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java rename to common/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java diff --git a/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java b/common/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java similarity index 100% rename from src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java rename to common/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java diff --git a/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java similarity index 100% rename from src/main/java/com/skyflow/logs/ErrorLogs.java rename to common/src/main/java/com/skyflow/logs/ErrorLogs.java diff --git a/src/main/java/com/skyflow/logs/InfoLogs.java b/common/src/main/java/com/skyflow/logs/InfoLogs.java similarity index 100% rename from src/main/java/com/skyflow/logs/InfoLogs.java rename to common/src/main/java/com/skyflow/logs/InfoLogs.java diff --git a/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java b/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java similarity index 94% rename from src/main/java/com/skyflow/serviceaccount/util/BearerToken.java rename to common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java index 23d09ab8..f2c15a6f 100644 --- a/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java +++ b/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java @@ -12,11 +12,10 @@ import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Constants; -import com.skyflow.utils.Utils; +import com.skyflow.utils.BaseConstants; +import com.skyflow.utils.BaseUtils; import com.skyflow.utils.logger.LogUtil; import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; import java.io.File; import java.io.FileNotFoundException; @@ -62,11 +61,11 @@ private static V1GetAuthTokenResponse generateBearerTokenFromCredentials( return getBearerTokenFromCredentials(serviceAccountCredentials, context, roles); } catch (JsonSyntaxException e) { LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseUtils.parameterizedString( ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath())); } catch (FileNotFoundException e) { LogUtil.printErrorLog(ErrorLogs.CREDENTIALS_FILE_NOT_FOUND.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseUtils.parameterizedString( ErrorMessage.FileNotFound.getMessage(), credentialsFile.getPath())); } } @@ -117,17 +116,17 @@ private static V1GetAuthTokenResponse getBearerTokenFromCredentials( throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingTokenUri.getMessage()); } - PrivateKey pvtKey = Utils.getPrivateKeyFromPem(privateKey.getAsString()); + PrivateKey pvtKey = BaseUtils.getPrivateKeyFromPem(privateKey.getAsString()); String signedUserJWT = getSignedToken( clientID.getAsString(), keyID.getAsString(), tokenURI.getAsString(), pvtKey, context ); - String basePath = Utils.getBaseURL(tokenURI.getAsString()); + String basePath = BaseUtils.getBaseURL(tokenURI.getAsString()); apiClientBuilder.url(basePath); ApiClient apiClient = apiClientBuilder.token("token").build(); AuthenticationClient authenticationApi = apiClient.authentication(); - V1GetAuthTokenRequest._FinalStage authTokenBuilder = V1GetAuthTokenRequest.builder().grantType(Constants.GRANT_TYPE).assertion(signedUserJWT); + V1GetAuthTokenRequest._FinalStage authTokenBuilder = V1GetAuthTokenRequest.builder().grantType(BaseConstants.GRANT_TYPE).assertion(signedUserJWT); if (roles != null) { String scopedRoles = getScopeUsingRoles(roles); @@ -155,8 +154,8 @@ private static String getSignedToken( .claim("aud", tokenURI) .claim("sub", clientID) .claim("ctx", context) - .setExpiration(expirationDate) - .signWith(SignatureAlgorithm.RS256, pvtKey) + .expiration(expirationDate) + .signWith(pvtKey, Jwts.SIG.RS256) .compact(); } diff --git a/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java b/common/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java similarity index 83% rename from src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java rename to common/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java index 7c9f4674..874b47c5 100644 --- a/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java +++ b/common/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokenResponse.java @@ -1,10 +1,10 @@ package com.skyflow.serviceaccount.util; import com.google.gson.Gson; -import com.skyflow.utils.Constants; +import com.skyflow.utils.BaseConstants; public class SignedDataTokenResponse { - private static final String prefix = Constants.SIGNED_DATA_TOKEN_PREFIX; + private static final String prefix = BaseConstants.SIGNED_DATA_TOKEN_PREFIX; private final String token; private final String signedToken; diff --git a/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java b/common/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java similarity index 96% rename from src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java rename to common/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java index ecdfa89f..ed0026ef 100644 --- a/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java +++ b/common/src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java @@ -9,10 +9,9 @@ import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Utils; +import com.skyflow.utils.BaseUtils; import com.skyflow.utils.logger.LogUtil; import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; import java.io.File; import java.io.FileNotFoundException; @@ -59,11 +58,11 @@ private static List generateSignedTokenFromCredentialsF responseToken = generateSignedTokensFromCredentials(serviceAccountCredentials, dataTokens, timeToLive, context); } catch (JsonSyntaxException e) { LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseUtils.parameterizedString( ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath())); } catch (FileNotFoundException e) { LogUtil.printErrorLog(ErrorLogs.CREDENTIALS_FILE_NOT_FOUND.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseUtils.parameterizedString( ErrorMessage.FileNotFound.getMessage(), credentialsFile.getPath())); } return responseToken; @@ -111,7 +110,7 @@ private static List generateSignedTokensFromCredentials LogUtil.printErrorLog(ErrorLogs.KEY_ID_IS_REQUIRED.getLog()); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MissingKeyId.getMessage()); } - PrivateKey pvtKey = Utils.getPrivateKeyFromPem(privateKey.getAsString()); + PrivateKey pvtKey = BaseUtils.getPrivateKeyFromPem(privateKey.getAsString()); signedDataTokens = getSignedToken( clientID.getAsString(), keyID.getAsString(), pvtKey, dataTokens, timeToLive, context); } catch (RuntimeException e) { @@ -143,8 +142,8 @@ private static List getSignedToken( .claim("sub", clientID) .claim("ctx", context) .claim("tok", dataToken) - .setExpiration(expirationDate) - .signWith(SignatureAlgorithm.RS256, pvtKey) + .expiration(expirationDate) + .signWith(pvtKey, Jwts.SIG.RS256) .compact(); SignedDataTokenResponse responseObject = new SignedDataTokenResponse(dataToken, eachSignedDataToken); list.add(responseObject); diff --git a/src/main/java/com/skyflow/serviceaccount/util/Token.java b/common/src/main/java/com/skyflow/serviceaccount/util/Token.java similarity index 100% rename from src/main/java/com/skyflow/serviceaccount/util/Token.java rename to common/src/main/java/com/skyflow/serviceaccount/util/Token.java diff --git a/src/main/java/com/skyflow/utils/Constants.java b/common/src/main/java/com/skyflow/utils/BaseConstants.java similarity index 85% rename from src/main/java/com/skyflow/utils/Constants.java rename to common/src/main/java/com/skyflow/utils/BaseConstants.java index b9264a22..cf069e5e 100644 --- a/src/main/java/com/skyflow/utils/Constants.java +++ b/common/src/main/java/com/skyflow/utils/BaseConstants.java @@ -1,6 +1,11 @@ package com.skyflow.utils; -public final class Constants { +public class BaseConstants { + public static final String SDK_NAME= "skyflow java"; + public static final String SDK_VERSION = "2.0.0"; + public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; + public static final String ORDER_ASCENDING = "ASCENDING"; + public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; public static final String SECURE_PROTOCOL = "https://"; public static final String DEV_DOMAIN = ".vault.skyflowapis.dev"; public static final String STAGE_DOMAIN = ".vault.skyflowapis.tech"; @@ -10,12 +15,7 @@ public final class Constants { public static final String PKCS8_PRIVATE_FOOTER = "-----END PRIVATE KEY-----"; public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; public static final String SIGNED_DATA_TOKEN_PREFIX = "signed_token_"; - public static final String ORDER_ASCENDING = "ASCENDING"; public static final String API_KEY_REGEX = "^sky-[a-zA-Z0-9]{5}-[a-fA-F0-9]{32}$"; - public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; - public static final String SDK_NAME = "Skyflow Java SDK "; - public static final String SDK_VERSION = "v2"; - public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; public static final String SDK_METRIC_NAME_VERSION = "sdk_name_version"; public static final String SDK_METRIC_NAME_VERSION_PREFIX = "skyflow-java@"; public static final String SDK_METRIC_CLIENT_DEVICE_MODEL = "sdk_client_device_model"; @@ -25,7 +25,6 @@ public final class Constants { public static final String SDK_AUTH_HEADER_KEY = "x-skyflow-authorization"; 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"; + } diff --git a/common/src/main/java/com/skyflow/common/utils/Utils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java similarity index 55% rename from common/src/main/java/com/skyflow/common/utils/Utils.java rename to common/src/main/java/com/skyflow/utils/BaseUtils.java index d499775b..ba7d7206 100644 --- a/common/src/main/java/com/skyflow/common/utils/Utils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -1,12 +1,16 @@ -package com.skyflow.common.utils; +package com.skyflow.utils; -import com.skyflow.common.errors.ErrorCode; -import com.skyflow.common.errors.ErrorMessage; -import com.skyflow.common.errors.SkyflowException; -import com.skyflow.common.logs.ErrorLogs; -import com.skyflow.common.utils.logger.LogUtil; +import com.skyflow.config.Credentials; +import com.skyflow.enums.Env; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.serviceaccount.util.BearerToken; +import com.skyflow.utils.logger.LogUtil; import org.apache.commons.codec.binary.Base64; +import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.security.KeyFactory; @@ -15,10 +19,51 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; -public final class Utils { +public class BaseUtils { + public static String getVaultURL(String clusterId, Env env) { + StringBuilder sb = new StringBuilder(BaseConstants.SECURE_PROTOCOL); + sb.append(clusterId); + switch (env) { + case DEV: + sb.append(BaseConstants.DEV_DOMAIN); + break; + case STAGE: + sb.append(BaseConstants.STAGE_DOMAIN); + break; + case SANDBOX: + sb.append(BaseConstants.SANDBOX_DOMAIN); + break; + case PROD: + default: + sb.append(BaseConstants.PROD_DOMAIN); + break; + } + return sb.toString(); + } + + public static String generateBearerToken(Credentials credentials) throws SkyflowException { + if (credentials.getPath() != null) { + return BearerToken.builder() + .setCredentials(new File(credentials.getPath())) + .setRoles(credentials.getRoles()) + .setCtx(credentials.getContext()) + .build() + .getBearerToken(); + } else if (credentials.getCredentialsString() != null) { + return BearerToken.builder() + .setCredentials(credentials.getCredentialsString()) + .setRoles(credentials.getRoles()) + .setCtx(credentials.getContext()) + .build() + .getBearerToken(); + } else { + return credentials.getToken(); + } + } + public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException { - String PKCS8PrivateHeader = Constants.PKCS8_PRIVATE_HEADER; - String PKCS8PrivateFooter = Constants.PKCS8_PRIVATE_FOOTER; + String PKCS8PrivateHeader = BaseConstants.PKCS8_PRIVATE_HEADER; + String PKCS8PrivateFooter = BaseConstants.PKCS8_PRIVATE_FOOTER; String privateKeyContent = pemKey; PrivateKey privateKey = null; diff --git a/common/src/main/java/com/skyflow/utils/SdkVersion.java b/common/src/main/java/com/skyflow/utils/SdkVersion.java new file mode 100644 index 00000000..8136d8c9 --- /dev/null +++ b/common/src/main/java/com/skyflow/utils/SdkVersion.java @@ -0,0 +1,13 @@ +package com.skyflow.utils; + +public class SdkVersion { + private static String sdkPrefix = BaseConstants.SDK_PREFIX; + + public static String getSdkPrefix() { + return sdkPrefix; + } + + public static void setSdkPrefix(String sdkPrefix) { + SdkVersion.sdkPrefix = sdkPrefix; + } +} diff --git a/src/main/java/com/skyflow/utils/logger/LogUtil.java b/common/src/main/java/com/skyflow/utils/logger/LogUtil.java similarity index 96% rename from src/main/java/com/skyflow/utils/logger/LogUtil.java rename to common/src/main/java/com/skyflow/utils/logger/LogUtil.java index 78cfa038..8746d930 100644 --- a/src/main/java/com/skyflow/utils/logger/LogUtil.java +++ b/common/src/main/java/com/skyflow/utils/logger/LogUtil.java @@ -1,14 +1,14 @@ package com.skyflow.utils.logger; -import com.skyflow.enums.LogLevel; import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Constants; +import com.skyflow.utils.BaseConstants; +import com.skyflow.enums.LogLevel; import java.util.logging.*; public final class LogUtil { private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName()); - private static final String SDK_LOG_PREFIX = "[" + Constants.SDK_PREFIX + "] "; + private static final String SDK_LOG_PREFIX = "[" + BaseConstants.SDK_PREFIX + "] "; private static boolean IS_LOGGER_SETUP_DONE = false; synchronized public static void setupLogger(LogLevel logLevel) { diff --git a/common/src/main/java/com/skyflow/utils/validations/BaseValidations.java b/common/src/main/java/com/skyflow/utils/validations/BaseValidations.java new file mode 100644 index 00000000..8460ec1d --- /dev/null +++ b/common/src/main/java/com/skyflow/utils/validations/BaseValidations.java @@ -0,0 +1,108 @@ +package com.skyflow.utils.validations; + +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.utils.BaseConstants; +import com.skyflow.utils.BaseUtils; +import com.skyflow.utils.logger.LogUtil; + +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class BaseValidations { + BaseValidations() { + } + + public static void validateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + String vaultId = vaultConfig.getVaultId(); + String clusterId = vaultConfig.getClusterId(); + Credentials credentials = vaultConfig.getCredentials(); + if (vaultId == null) { + LogUtil.printErrorLog(ErrorLogs.VAULT_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidVaultId.getMessage()); + } else if (vaultId.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_VAULT_ID.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyVaultId.getMessage()); + } else if (clusterId == null) { + LogUtil.printErrorLog(ErrorLogs.CLUSTER_ID_IS_REQUIRED.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidClusterId.getMessage()); + } else if (clusterId.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CLUSTER_ID.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyClusterId.getMessage()); + } else if (credentials != null) { + validateCredentials(credentials); + } + } + + public static void validateCredentials(Credentials credentials) throws SkyflowException { + int nonNullMembers = 0; + String path = credentials.getPath(); + String credentialsString = credentials.getCredentialsString(); + String token = credentials.getToken(); + String apiKey = credentials.getApiKey(); + String context = credentials.getContext(); + ArrayList roles = credentials.getRoles(); + + if (path != null) nonNullMembers++; + if (credentialsString != null) nonNullMembers++; + if (token != null) nonNullMembers++; + if (apiKey != null) nonNullMembers++; + + if (nonNullMembers > 1) { + LogUtil.printErrorLog(ErrorLogs.MULTIPLE_TOKEN_GENERATION_MEANS_PASSED.getLog()); + throw new SkyflowException( + ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MultipleTokenGenerationMeansPassed.getMessage() + ); + } else if (nonNullMembers < 1) { + LogUtil.printErrorLog(ErrorLogs.NO_TOKEN_GENERATION_MEANS_PASSED.getLog()); + throw new SkyflowException( + ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NoTokenGenerationMeansPassed.getMessage() + ); + } else if (path != null && path.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_PATH.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialFilePath.getMessage()); + } else if (credentialsString != null && credentialsString.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_STRING.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialsString.getMessage()); + } else if (token != null && token.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_TOKEN_VALUE.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyToken.getMessage()); + } else if (apiKey != null) { + if (apiKey.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_API_KEY_VALUE.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyApikey.getMessage()); + } else { + Pattern pattern = Pattern.compile(BaseConstants.API_KEY_REGEX); + Matcher matcher = pattern.matcher(apiKey); + if (!matcher.matches()) { + LogUtil.printErrorLog(ErrorLogs.INVALID_API_KEY.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidApikey.getMessage()); + } + } + } else if (roles != null) { + if (roles.isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_ROLES.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoles.getMessage()); + } else { + for (int index = 0; index < roles.size(); index++) { + String role = roles.get(index); + if (role == null || role.trim().isEmpty()) { + LogUtil.printErrorLog(BaseUtils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_ROLE_IN_ROLES.getLog(), Integer.toString(index) + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoleInRoles.getMessage()); + } + } + } + } + if (context != null && context.trim().isEmpty()) { + LogUtil.printErrorLog(ErrorLogs.EMPTY_OR_NULL_CONTEXT.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyContext.getMessage()); + } + } +} diff --git a/common/src/test/java/com/skyflow/api/TestClient.java b/common/src/test/java/com/skyflow/api/TestClient.java deleted file mode 100644 index 3f2810e1..00000000 --- a/common/src/test/java/com/skyflow/api/TestClient.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.api; - -public final class TestClient { - public void test() { - // Add tests here and mark this file in .fernignore - assert true; - } -} diff --git a/common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java b/common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java deleted file mode 100644 index e661b48a..00000000 --- a/common/src/test/java/com/skyflow/api/core/QueryStringMapperTest.java +++ /dev/null @@ -1,341 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.api.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 com.skyflow.common.core.QueryStringMapper; -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/test/java/com/skyflow/config/CredentialsTests.java b/common/src/test/java/com/skyflow/config/CredentialsTests.java similarity index 89% rename from src/test/java/com/skyflow/config/CredentialsTests.java rename to common/src/test/java/com/skyflow/config/CredentialsTests.java index ff9fcfda..13cd0644 100644 --- a/src/test/java/com/skyflow/config/CredentialsTests.java +++ b/common/src/test/java/com/skyflow/config/CredentialsTests.java @@ -3,7 +3,7 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.utils.validations.Validations; +import com.skyflow.utils.validations.BaseValidations; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -45,7 +45,7 @@ public void testValidCredentialsWithPath() { try { Credentials credentials = new Credentials(); credentials.setPath(path); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.assertNull(credentials.getCredentialsString()); Assert.assertNull(credentials.getToken()); Assert.assertNull(credentials.getApiKey()); @@ -59,7 +59,7 @@ public void testValidCredentialsWithCredentialsString() { try { Credentials credentials = new Credentials(); credentials.setCredentialsString(credentialsString); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.assertNull(credentials.getPath()); Assert.assertNull(credentials.getToken()); Assert.assertNull(credentials.getApiKey()); @@ -73,7 +73,7 @@ public void testValidCredentialsWithToken() { try { Credentials credentials = new Credentials(); credentials.setToken(token); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.assertNull(credentials.getPath()); Assert.assertNull(credentials.getCredentialsString()); Assert.assertNull(credentials.getApiKey()); @@ -87,7 +87,7 @@ public void testValidCredentialsWithApikey() { try { Credentials credentials = new Credentials(); credentials.setApiKey(validApiKey); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.assertNull(credentials.getPath()); Assert.assertNull(credentials.getCredentialsString()); Assert.assertNull(credentials.getToken()); @@ -104,7 +104,7 @@ public void testValidCredentialsWithRolesAndContext() { credentials.setApiKey(validApiKey); credentials.setRoles(roles); credentials.setContext(context); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.assertNull(credentials.getPath()); Assert.assertNull(credentials.getCredentialsString()); Assert.assertNull(credentials.getToken()); @@ -120,7 +120,7 @@ public void testEmptyPathInCredentials() { try { Credentials credentials = new Credentials(); credentials.setPath(""); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -133,7 +133,7 @@ public void testEmptyCredentialsStringInCredentials() { try { Credentials credentials = new Credentials(); credentials.setCredentialsString(""); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -146,7 +146,7 @@ public void testEmptyTokenInCredentials() { try { Credentials credentials = new Credentials(); credentials.setToken(""); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -159,7 +159,7 @@ public void testEmptyApikeyInCredentials() { try { Credentials credentials = new Credentials(); credentials.setApiKey(""); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -172,7 +172,7 @@ public void testInvalidApikeyInCredentials() { try { Credentials credentials = new Credentials(); credentials.setApiKey(invalidApiKey); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -186,7 +186,7 @@ public void testBothTokenAndPathInCredentials() { Credentials credentials = new Credentials(); credentials.setPath(path); credentials.setToken(token); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -198,7 +198,7 @@ public void testBothTokenAndPathInCredentials() { public void testNothingPassedInCredentials() { try { Credentials credentials = new Credentials(); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -212,7 +212,7 @@ public void testEmptyRolesInCredentials() { Credentials credentials = new Credentials(); credentials.setPath(path); credentials.setRoles(roles); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -228,7 +228,7 @@ public void testNullRoleInRolesInCredentials() { roles.add(role); roles.add(null); credentials.setRoles(roles); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -244,7 +244,7 @@ public void testEmptyRoleInRolesInCredentials() { roles.add(role); roles.add(""); credentials.setRoles(roles); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -258,7 +258,7 @@ public void testEmptyContextInCredentials() { Credentials credentials = new Credentials(); credentials.setPath(path); credentials.setContext(""); - Validations.validateCredentials(credentials); + BaseValidations.validateCredentials(credentials); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); diff --git a/src/test/java/com/skyflow/config/VaultConfigTests.java b/common/src/test/java/com/skyflow/config/VaultConfigTests.java similarity index 91% rename from src/test/java/com/skyflow/config/VaultConfigTests.java rename to common/src/test/java/com/skyflow/config/VaultConfigTests.java index b99f6c9b..2c3cb77d 100644 --- a/src/test/java/com/skyflow/config/VaultConfigTests.java +++ b/common/src/test/java/com/skyflow/config/VaultConfigTests.java @@ -4,7 +4,7 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.utils.validations.Validations; +import com.skyflow.utils.validations.BaseValidations; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -35,7 +35,7 @@ public void testValidVaultConfigWithCredentialsInValidations() { vaultConfig.setClusterId(clusterID); vaultConfig.setEnv(Env.SANDBOX); vaultConfig.setCredentials(credentials); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.assertEquals(vaultID, vaultConfig.getVaultId()); Assert.assertEquals(clusterID, vaultConfig.getClusterId()); @@ -53,7 +53,7 @@ public void testValidVaultConfigWithoutCredentialsInValidations() { vaultConfig.setVaultId(vaultID); vaultConfig.setClusterId(clusterID); vaultConfig.setEnv(Env.SANDBOX); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.assertEquals(vaultID, vaultConfig.getVaultId()); Assert.assertEquals(clusterID, vaultConfig.getClusterId()); @@ -71,7 +71,7 @@ public void testDefaultEnvInVaultConfigWithCredentialsInValidations() { vaultConfig.setVaultId(vaultID); vaultConfig.setClusterId(clusterID); vaultConfig.setCredentials(credentials); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.assertEquals(vaultID, vaultConfig.getVaultId()); Assert.assertEquals(clusterID, vaultConfig.getClusterId()); @@ -89,7 +89,7 @@ public void testDefaultEnvInVaultConfigWithoutCredentialsInValidations() { vaultConfig.setVaultId(vaultID); vaultConfig.setClusterId(clusterID); vaultConfig.setEnv(null); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.assertEquals(vaultID, vaultConfig.getVaultId()); Assert.assertEquals(clusterID, vaultConfig.getClusterId()); @@ -106,7 +106,7 @@ public void testNoVaultIdInVaultConfigInValidations() { try { vaultConfig.setClusterId(clusterID); vaultConfig.setEnv(Env.SANDBOX); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -121,7 +121,7 @@ public void testEmptyVaultIdInVaultConfigInValidations() { vaultConfig.setVaultId(""); vaultConfig.setClusterId(clusterID); vaultConfig.setEnv(Env.SANDBOX); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -135,7 +135,7 @@ public void testNoClusterIdInVaultConfigInValidations() { VaultConfig vaultConfig = new VaultConfig(); vaultConfig.setVaultId(vaultID); vaultConfig.setEnv(Env.SANDBOX); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); @@ -150,7 +150,7 @@ public void testEmptyClusterIdInVaultConfigInValidations() { vaultConfig.setVaultId(vaultID); vaultConfig.setClusterId(""); vaultConfig.setEnv(Env.SANDBOX); - Validations.validateVaultConfig(vaultConfig); + BaseValidations.validateVaultConfig(vaultConfig); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); diff --git a/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java b/common/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java similarity index 91% rename from src/test/java/com/skyflow/errors/SkyflowExceptionTest.java rename to common/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java index 89e0643b..cf35f548 100644 --- a/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java +++ b/common/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java @@ -59,7 +59,7 @@ public void testConstructorWithJsonErrorBody() { Assert.assertEquals("NOT_FOUND", ex.getHttpStatus()); Assert.assertEquals("req-123", ex.getRequestId()); Assert.assertNotNull(ex.getDetails()); - Assert.assertTrue(ex.getDetails().size() > 0); + Assert.assertFalse(ex.getDetails().isEmpty()); } @@ -67,9 +67,9 @@ public void testConstructorWithJsonErrorBody() { public void testConstructorWithNullErrorBody() { Map> headers = new HashMap<>(); SkyflowException ex = new SkyflowException(500, new RuntimeException("fail"), headers, null); - Assert.assertNull(ex.getMessage()); + Assert.assertEquals(ex.getMessage(), "fail"); + Assert.assertEquals(ex.getHttpStatus(), HttpStatus.BAD_REQUEST.getHttpStatus()); Assert.assertNull(ex.getGrpcCode()); - Assert.assertNull(ex.getHttpStatus()); } @Test @@ -85,11 +85,11 @@ public void testGettersAndSetters() { @Test public void testSetDetailsWithErrorFromClientHeader() { - String json = "{\"error\":{\"message\":\"test error\",\"grpc_code\":13,\"details\":[]}}"; + String jsonString = "{\"error\":{\"message\":\"test error\",\"grpc_code\":13,\"details\":[]}}"; Map> headers = new HashMap<>(); headers.put("error-from-client", Collections.singletonList("client error")); - SkyflowException ex = new SkyflowException(500, new RuntimeException("fail"), headers, json); + SkyflowException ex = new SkyflowException(500, new RuntimeException("fail"), headers, jsonString); Assert.assertNotNull(ex.getDetails()); Assert.assertEquals(1, ex.getDetails().size()); diff --git a/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java b/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java similarity index 96% rename from src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java rename to common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java index 4bfb697c..3e8a7696 100644 --- a/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java +++ b/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java @@ -3,7 +3,7 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.utils.Utils; +import com.skyflow.utils.BaseUtils; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -64,7 +64,7 @@ public void testEmptyCredentialsFilePath() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), ""), e.getMessage() + BaseUtils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), ""), e.getMessage() ); } } @@ -79,7 +79,7 @@ public void testInvalidFilePath() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), invalidFilePath), + BaseUtils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), invalidFilePath), e.getMessage() ); } @@ -95,7 +95,7 @@ public void testInvalidCredentialsFile() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.FileInvalidJson.getMessage(), invalidJsonFilePath), + BaseUtils.parameterizedString(ErrorMessage.FileInvalidJson.getMessage(), invalidJsonFilePath), e.getMessage() ); } diff --git a/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java b/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java similarity index 93% rename from src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java rename to common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java index 42ad9bc7..56b1403f 100644 --- a/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java +++ b/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java @@ -3,7 +3,7 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.utils.Utils; +import com.skyflow.utils.BaseUtils; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -69,7 +69,7 @@ public void testEmptyCredentialsFilePath() { Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); - Assert.assertEquals(Utils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), ""), e.getMessage()); + Assert.assertEquals(BaseUtils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), ""), e.getMessage()); } } @@ -83,7 +83,7 @@ public void testInvalidFilePath() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), invalidFilePath), + BaseUtils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), invalidFilePath), e.getMessage()); } } @@ -98,7 +98,7 @@ public void testInvalidCredentialsFile() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.FileInvalidJson.getMessage(), invalidJsonFilePath), + BaseUtils.parameterizedString(ErrorMessage.FileInvalidJson.getMessage(), invalidJsonFilePath), e.getMessage() ); } @@ -116,7 +116,7 @@ public void testEmptyCredentialsString() { System.out.println(e); Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.InvalidCredentials.getMessage(), invalidJsonFilePath), + BaseUtils.parameterizedString(ErrorMessage.InvalidCredentials.getMessage(), invalidJsonFilePath), e.getMessage() ); } catch (Exception e) { @@ -134,7 +134,7 @@ public void testInvalidCredentialsString() { } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( - Utils.parameterizedString(ErrorMessage.CredentialsStringInvalidJson.getMessage(), invalidJsonFilePath), + BaseUtils.parameterizedString(ErrorMessage.CredentialsStringInvalidJson.getMessage(), invalidJsonFilePath), e.getMessage() ); } diff --git a/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java b/common/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java similarity index 87% rename from src/test/java/com/skyflow/serviceaccount/util/TokenTests.java rename to common/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java index ed5c72b2..587527cf 100644 --- a/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java +++ b/common/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java @@ -1,6 +1,6 @@ package com.skyflow.serviceaccount.util; -import com.skyflow.Skyflow; +// import com.skyflow.Skyflow; import com.skyflow.enums.LogLevel; import io.github.cdimascio.dotenv.Dotenv; import org.junit.Assert; @@ -10,10 +10,10 @@ public class TokenTests { private static final String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception"; - @BeforeClass - public static void setup() { - Skyflow skyflowClient = Skyflow.builder().setLogLevel(LogLevel.DEBUG).build(); - } + // @BeforeClass + // public static void setup() { + // Skyflow skyflowClient = Skyflow.builder().setLogLevel(LogLevel.DEBUG).build(); + // } @Test public void testNoTokenForIsExpiredToken() { diff --git a/src/test/resources/invalidPrivateKeyCredentials.json b/common/src/test/resources/invalidPrivateKeyCredentials.json similarity index 100% rename from src/test/resources/invalidPrivateKeyCredentials.json rename to common/src/test/resources/invalidPrivateKeyCredentials.json diff --git a/src/test/resources/invalidTokenURICredentials.json b/common/src/test/resources/invalidTokenURICredentials.json similarity index 100% rename from src/test/resources/invalidTokenURICredentials.json rename to common/src/test/resources/invalidTokenURICredentials.json diff --git a/src/test/resources/noClientIDCredentials.json b/common/src/test/resources/noClientIDCredentials.json similarity index 100% rename from src/test/resources/noClientIDCredentials.json rename to common/src/test/resources/noClientIDCredentials.json diff --git a/src/test/resources/noKeyIDCredentials.json b/common/src/test/resources/noKeyIDCredentials.json similarity index 100% rename from src/test/resources/noKeyIDCredentials.json rename to common/src/test/resources/noKeyIDCredentials.json diff --git a/src/test/resources/noPrivateKeyCredentials.json b/common/src/test/resources/noPrivateKeyCredentials.json similarity index 100% rename from src/test/resources/noPrivateKeyCredentials.json rename to common/src/test/resources/noPrivateKeyCredentials.json diff --git a/src/test/resources/noTokenURICredentials.json b/common/src/test/resources/noTokenURICredentials.json similarity index 100% rename from src/test/resources/noTokenURICredentials.json rename to common/src/test/resources/noTokenURICredentials.json diff --git a/src/test/resources/notJson.txt b/common/src/test/resources/notJson.txt similarity index 100% rename from src/test/resources/notJson.txt rename to common/src/test/resources/notJson.txt diff --git a/pom.xml b/pom.xml index 835ffe20..40d47190 100644 --- a/pom.xml +++ b/pom.xml @@ -50,12 +50,6 @@
- - com.squareup.okhttp3 - okhttp - 4.12.0 - compile - com.fasterxml.jackson.core jackson-databind diff --git a/src/main/java/com/skyflow/Skyflow.java b/src/main/java/com/skyflow/Skyflow.java deleted file mode 100644 index 8e51da57..00000000 --- a/src/main/java/com/skyflow/Skyflow.java +++ /dev/null @@ -1,307 +0,0 @@ -package com.skyflow; - -import com.skyflow.config.ConnectionConfig; -import com.skyflow.config.Credentials; -import com.skyflow.config.VaultConfig; -import com.skyflow.enums.Env; -import com.skyflow.enums.LogLevel; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.logs.ErrorLogs; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Utils; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.utils.validations.Validations; -import com.skyflow.vault.controller.ConnectionController; -import com.skyflow.vault.controller.DetectController; -import com.skyflow.vault.controller.VaultController; - -import java.util.LinkedHashMap; - -public final class Skyflow { - private final SkyflowClientBuilder builder; - - private Skyflow(SkyflowClientBuilder builder) { - this.builder = builder; - LogUtil.printInfoLog(InfoLogs.CLIENT_INITIALIZED.getLog()); - } - - public static SkyflowClientBuilder builder() { - return new SkyflowClientBuilder(); - } - - public Skyflow addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - this.builder.addVaultConfig(vaultConfig); - return this; - } - - public VaultConfig getVaultConfig(String vaultId) { - return this.builder.vaultConfigMap.get(vaultId); - } - - public Skyflow updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - this.builder.updateVaultConfig(vaultConfig); - return this; - } - - public Skyflow removeVaultConfig(String vaultId) throws SkyflowException { - this.builder.removeVaultConfig(vaultId); - return this; - } - - public Skyflow addConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { - this.builder.addConnectionConfig(connectionConfig); - return this; - } - - public ConnectionConfig getConnectionConfig(String connectionId) { - return this.builder.connectionConfigMap.get(connectionId); - } - - public Skyflow updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { - this.builder.updateConnectionConfig(connectionConfig); - return this; - } - - public Skyflow removeConnectionConfig(String connectionId) throws SkyflowException { - this.builder.removeConnectionConfig(connectionId); - return this; - } - - public Skyflow updateSkyflowCredentials(Credentials credentials) throws SkyflowException { - this.builder.addSkyflowCredentials(credentials); - return this; - } - - public Skyflow updateLogLevel(LogLevel logLevel) { - this.builder.setLogLevel(logLevel); - return this; - } - - public LogLevel getLogLevel() { - return this.builder.logLevel; - } - - public VaultController vault() throws SkyflowException { - Object[] array = this.builder.vaultClientsMap.keySet().toArray(); - if (array.length < 1) { - LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - String vaultId = (String) array[0]; - return this.vault(vaultId); - } - - public VaultController vault(String vaultId) throws SkyflowException { - VaultController controller = this.builder.vaultClientsMap.get(vaultId); - if (controller == null) { - LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - return controller; - } - - - public ConnectionController connection() throws SkyflowException { - Object[] array = this.builder.connectionsMap.keySet().toArray(); - if (array.length < 1) { - LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage()); - } - String connectionId = (String) array[0]; - return this.connection(connectionId); - } - - public ConnectionController connection(String connectionId) throws SkyflowException { - ConnectionController controller = this.builder.connectionsMap.get(connectionId); - if (controller == null) { - LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage()); - } - return controller; - } - - public DetectController detect() throws SkyflowException { - Object[] array = this.builder.detectClientsMap.keySet().toArray(); - if (array.length < 1) { - LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - String detectId = (String) array[0]; - return this.detect(detectId); - } - - public DetectController detect(String vaultId) throws SkyflowException { - DetectController controller = this.builder.detectClientsMap.get(vaultId); - if (controller == null) { - LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - return controller; - } - - public static final class SkyflowClientBuilder { - private final LinkedHashMap connectionsMap; - private final LinkedHashMap vaultClientsMap; - private final LinkedHashMap detectClientsMap; - private final LinkedHashMap vaultConfigMap; - private final LinkedHashMap connectionConfigMap; - private Credentials skyflowCredentials; - private LogLevel logLevel; - - public SkyflowClientBuilder() { - this.vaultClientsMap = new LinkedHashMap<>(); - this.detectClientsMap = new LinkedHashMap<>(); - this.vaultConfigMap = new LinkedHashMap<>(); - this.connectionsMap = new LinkedHashMap<>(); - this.connectionConfigMap = new LinkedHashMap<>(); - this.skyflowCredentials = null; - this.logLevel = LogLevel.ERROR; - } - - public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); - Validations.validateVaultConfig(vaultConfig); - if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.VAULT_CONFIG_EXISTS.getLog(), vaultConfig.getVaultId() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); - } else { - this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); - this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); - this.detectClientsMap.put(vaultConfig.getVaultId(), new DetectController(vaultConfig, this.skyflowCredentials)); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); - } - return this; - } - - public SkyflowClientBuilder updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); - Validations.validateVaultConfig(vaultConfig); - if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { - VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfig); - this.vaultClientsMap.get(updatedConfig.getVaultId()).updateVaultConfig(); - } else { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultConfig.getVaultId() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - return this; - } - - public SkyflowClientBuilder removeVaultConfig(String vaultId) throws SkyflowException { - if (this.vaultClientsMap.containsKey(vaultId)) { - this.vaultClientsMap.remove(vaultId); - this.vaultConfigMap.remove(vaultId); - } else { - LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultId)); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - return this; - } - - public SkyflowClientBuilder addConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.VALIDATING_CONNECTION_CONFIG.getLog()); - Validations.validateConnectionConfig(connectionConfig); - if (this.connectionsMap.containsKey(connectionConfig.getConnectionId())) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.CONNECTION_CONFIG_EXISTS.getLog(), connectionConfig.getConnectionId() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.ConnectionIdAlreadyInConfigList.getMessage()); - } else { - this.connectionConfigMap.put(connectionConfig.getConnectionId(), connectionConfig); - ConnectionController controller = new ConnectionController(connectionConfig, this.skyflowCredentials); - this.connectionsMap.put(connectionConfig.getConnectionId(), controller); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.CONNECTION_CONTROLLER_INITIALIZED.getLog(), connectionConfig.getConnectionId())); - } - return this; - } - - public SkyflowClientBuilder updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.VALIDATING_CONNECTION_CONFIG.getLog()); - Validations.validateConnectionConfig(connectionConfig); - if (this.connectionsMap.containsKey(connectionConfig.getConnectionId())) { - ConnectionConfig updatedConfig = findAndUpdateConnectionConfig(connectionConfig); - this.connectionsMap.get(updatedConfig.getConnectionId()).updateConnectionConfig(connectionConfig); - } else { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog(), connectionConfig.getConnectionId() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.ConnectionIdNotInConfigList.getMessage()); - } - return this; - } - - public SkyflowClientBuilder removeConnectionConfig(String connectionId) throws SkyflowException { - if (this.connectionsMap.containsKey(connectionId)) { - this.connectionsMap.remove(connectionId); - this.connectionConfigMap.remove(connectionId); - } else { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog(), connectionId - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.ConnectionIdNotInConfigList.getMessage()); - } - return this; - } - - public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throws SkyflowException { - Validations.validateCredentials(credentials); - this.skyflowCredentials = credentials; - for (VaultController vault : this.vaultClientsMap.values()) { - vault.setCommonCredentials(this.skyflowCredentials); - } - for (DetectController detect : this.detectClientsMap.values()) { - detect.setCommonCredentials(this.skyflowCredentials); - } - for (ConnectionController connection : this.connectionsMap.values()) { - connection.setCommonCredentials(this.skyflowCredentials); - } - return this; - } - - public SkyflowClientBuilder setLogLevel(LogLevel logLevel) { - this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; - LogUtil.setupLogger(this.logLevel); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.CURRENT_LOG_LEVEL.getLog(), String.valueOf(logLevel) - )); - return this; - } - - public Skyflow build() { - return new Skyflow(this); - } - - private VaultConfig findAndUpdateVaultConfig(VaultConfig vaultConfig) { - VaultConfig previousConfig = this.vaultConfigMap.get(vaultConfig.getVaultId()); - Env env = vaultConfig.getEnv() != null ? vaultConfig.getEnv() : previousConfig.getEnv(); - String clusterId = vaultConfig.getClusterId() != null ? vaultConfig.getClusterId() : previousConfig.getClusterId(); - Credentials credentials = vaultConfig.getCredentials() != null ? vaultConfig.getCredentials() : previousConfig.getCredentials(); - previousConfig.setEnv(env); - previousConfig.setClusterId(clusterId); - previousConfig.setCredentials(credentials); - return previousConfig; - } - - private ConnectionConfig findAndUpdateConnectionConfig(ConnectionConfig connectionConfig) { - ConnectionConfig previousConfig = this.connectionConfigMap.get(connectionConfig.getConnectionId()); - String connectionURL = connectionConfig.getConnectionUrl() != null ? connectionConfig.getConnectionUrl() : previousConfig.getConnectionUrl(); - Credentials credentials = connectionConfig.getCredentials() != null ? connectionConfig.getCredentials() : previousConfig.getCredentials(); - previousConfig.setConnectionUrl(connectionURL); - previousConfig.setCredentials(credentials); - return previousConfig; - } - } -} diff --git a/src/main/java/com/skyflow/VaultClient.java b/src/main/java/com/skyflow/VaultClient.java deleted file mode 100644 index 7536a2c1..00000000 --- a/src/main/java/com/skyflow/VaultClient.java +++ /dev/null @@ -1,819 +0,0 @@ -package com.skyflow; - -import com.skyflow.config.Credentials; -import com.skyflow.config.VaultConfig; -import com.skyflow.enums.DetectEntities; -import com.skyflow.enums.DetectOutputTranscriptions; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.rest.ApiClient; -import com.skyflow.generated.rest.ApiClientBuilder; -import com.skyflow.generated.rest.resources.files.FilesClient; -import com.skyflow.generated.rest.resources.files.requests.*; -import com.skyflow.generated.rest.resources.files.types.*; -import com.skyflow.generated.rest.resources.query.QueryClient; -import com.skyflow.generated.rest.resources.records.RecordsClient; -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.strings.StringsClient; -import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; -import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; -import com.skyflow.generated.rest.resources.strings.types.ReidentifyStringRequestFormat; -import com.skyflow.generated.rest.resources.tokens.TokensClient; -import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; -import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.*; -import com.skyflow.generated.rest.types.Transformations; -import com.skyflow.logs.InfoLogs; -import com.skyflow.serviceaccount.util.Token; -import com.skyflow.utils.Constants; -import com.skyflow.utils.Utils; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.utils.validations.Validations; -import com.skyflow.vault.data.InsertRequest; -import com.skyflow.vault.data.UpdateRequest; -import com.skyflow.vault.detect.*; -import com.skyflow.vault.detect.DeidentifyFileRequest; -import com.skyflow.vault.detect.DeidentifyTextRequest; -import com.skyflow.vault.tokens.ColumnValue; -import com.skyflow.vault.tokens.DetokenizeData; -import com.skyflow.vault.tokens.DetokenizeRequest; -import com.skyflow.vault.tokens.TokenizeRequest; -import io.github.cdimascio.dotenv.Dotenv; -import io.github.cdimascio.dotenv.DotenvException; - -import java.util.*; -import java.util.stream.Collectors; - - -public class VaultClient { - private final VaultConfig vaultConfig; - private final ApiClientBuilder apiClientBuilder; - private ApiClient apiClient; - private Credentials commonCredentials; - private Credentials finalCredentials; - private String token; - private String apiKey; - - protected VaultClient(VaultConfig vaultConfig, Credentials credentials) { - super(); - this.vaultConfig = vaultConfig; - this.commonCredentials = credentials; - this.apiClientBuilder = new ApiClientBuilder(); - this.apiClient = null; - updateVaultURL(); - } - - protected RecordsClient getRecordsApi() { - return this.apiClient.records(); - } - - protected TokensClient getTokensApi() { - return this.apiClient.tokens(); - } - - protected StringsClient getDetectTextApi() { - return this.apiClient.strings(); - } - - protected FilesClient getDetectFileAPi(){ - return this.apiClient.files(); - } - - protected QueryClient getQueryApi() { - return this.apiClient.query(); - } - - protected VaultConfig getVaultConfig() { - return vaultConfig; - } - - protected void setCommonCredentials(Credentials commonCredentials) throws SkyflowException { - this.commonCredentials = commonCredentials; - prioritiseCredentials(); - } - - protected void updateVaultConfig() throws SkyflowException { - updateVaultURL(); - prioritiseCredentials(); - } - - protected V1DetokenizePayload getDetokenizePayload(DetokenizeRequest request) { - List recordRequests = new ArrayList<>(); - - for (DetokenizeData detokenizeDataRecord : request.getDetokenizeData()) { - V1DetokenizeRecordRequest recordRequest = V1DetokenizeRecordRequest.builder() - .token(detokenizeDataRecord.getToken()) - .redaction(detokenizeDataRecord.getRedactionType().getRedaction()) - .build(); - recordRequests.add(recordRequest); - } - - return V1DetokenizePayload.builder() - .continueOnError(request.getContinueOnError()) - .downloadUrl(request.getDownloadURL()) - .detokenizationParameters(recordRequests) - .build(); - } - - protected RecordServiceInsertRecordBody getBulkInsertRequestBody(InsertRequest request) { - List> values = request.getValues(); - List> tokens = request.getTokens(); - List records = new ArrayList<>(); - - for (int index = 0; index < values.size(); index++) { - V1FieldRecords.Builder recordBuilder = V1FieldRecords.builder().fields(values.get(index)); - if (tokens != null && index < tokens.size()) { - recordBuilder.tokens(tokens.get(index)); - } - records.add(recordBuilder.build()); - } - - return RecordServiceInsertRecordBody.builder() - .tokenization(request.getReturnTokens()) - .homogeneous(request.getHomogeneous()) - .upsert(request.getUpsert()) - .byot(request.getTokenMode().getBYOT()) - .records(records) - .build(); - } - - protected RecordServiceBatchOperationBody getBatchInsertRequestBody(InsertRequest request) { - ArrayList> values = request.getValues(); - ArrayList> tokens = request.getTokens(); - List records = new ArrayList<>(); - - for (int index = 0; index < values.size(); index++) { - V1BatchRecord.Builder recordBuilder = V1BatchRecord.builder() - .method(BatchRecordMethod.POST) - .tableName(request.getTable()) - .upsert(request.getUpsert()) - .tokenization(request.getReturnTokens()) - .fields(values.get(index)); - - if (tokens != null && index < tokens.size()) { - recordBuilder.tokens(tokens.get(index)); - } - - records.add(recordBuilder.build()); - } - - return RecordServiceBatchOperationBody.builder() - .continueOnError(true) - .byot(request.getTokenMode().getBYOT()) - .records(records) - .build(); - } - - protected RecordServiceUpdateRecordBody getUpdateRequestBody(UpdateRequest request) { - RecordServiceUpdateRecordBody.Builder updateRequestBodyBuilder = RecordServiceUpdateRecordBody.builder(); - updateRequestBodyBuilder.byot(request.getTokenMode().getBYOT()); - updateRequestBodyBuilder.tokenization(request.getReturnTokens()); - V1FieldRecords.Builder recordBuilder = V1FieldRecords.builder(); - HashMap values = request.getData(); - - if (values != null) { - recordBuilder.fields(values); - } - - HashMap tokens = request.getTokens(); - if (tokens != null) { - recordBuilder.tokens(tokens); - } - - updateRequestBodyBuilder.record(recordBuilder.build()); - - return updateRequestBodyBuilder.build(); - } - - protected V1TokenizePayload getTokenizePayload(TokenizeRequest request) { - List tokenizationParameters = new ArrayList<>(); - - for (ColumnValue columnValue : request.getColumnValues()) { - V1TokenizeRecordRequest.Builder recordBuilder = V1TokenizeRecordRequest.builder(); - String value = columnValue.getValue(); - recordBuilder.value(value); - String columnGroup = columnValue.getColumnGroup(); - recordBuilder.columnGroup(columnGroup); - tokenizationParameters.add(recordBuilder.build()); - } - - V1TokenizePayload.Builder payloadBuilder = V1TokenizePayload.builder(); - - if (!tokenizationParameters.isEmpty()) { - payloadBuilder.tokenizationParameters(tokenizationParameters); - } - - return payloadBuilder.build(); - } - - protected void setBearerToken() throws SkyflowException { - prioritiseCredentials(); - Validations.validateCredentials(this.finalCredentials); - if (this.finalCredentials.getApiKey() != null) { - LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); - token=this.finalCredentials.getApiKey(); - } else if (Token.isExpired(token)) { - LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); - token = Utils.generateBearerToken(this.finalCredentials); - } else { - LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); - } - this.apiClientBuilder.token(token); - this.apiClient = this.apiClientBuilder.build(); - } - - protected DeidentifyTextResponse getDeIdentifyTextResponse(DeidentifyStringResponse deidentifyStringResponse) { - List entities = deidentifyStringResponse.getEntities() != null - ? deidentifyStringResponse.getEntities().stream() - .map(this::convertDetectedEntityToEntityInfo) - .collect(Collectors.toList()) - : null; - - return new DeidentifyTextResponse( - deidentifyStringResponse.getProcessedText(), - entities, - deidentifyStringResponse.getWordCount(), - deidentifyStringResponse.getCharacterCount() - ); - } - - protected DeidentifyStringRequest getDeidentifyStringRequest(DeidentifyTextRequest deIdentifyTextRequest, String vaultId) throws SkyflowException { - List entities = deIdentifyTextRequest.getEntities(); - - List mappedEntityTypes = null; - if (entities != null) { - mappedEntityTypes = deIdentifyTextRequest.getEntities().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList()); - } - - TokenFormat tokenFormat = deIdentifyTextRequest.getTokenFormat(); - - Optional> vaultToken = Optional.empty(); - Optional> entityTypes = Optional.empty(); - Optional> entityUniqueCounter = Optional.empty(); - Optional> allowRegex = Optional.ofNullable(deIdentifyTextRequest.getAllowRegexList()); - Optional> restrictRegex = Optional.ofNullable(deIdentifyTextRequest.getRestrictRegexList()); - Optional transformations = Optional.ofNullable(getTransformations(deIdentifyTextRequest.getTransformations())); - - if (tokenFormat != null) { - if (tokenFormat.getVaultToken() != null && !tokenFormat.getVaultToken().isEmpty()) { - vaultToken = Optional.of(tokenFormat.getVaultToken().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) { - entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { - entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - } - - TokenType tokenType = TokenType.builder() - .vaultToken(vaultToken) - .entityOnly(entityTypes) - .entityUnqCounter(entityUniqueCounter) - .build(); - - - return DeidentifyStringRequest.builder() - .vaultId(vaultId) - .text(deIdentifyTextRequest.getText()) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - protected ReidentifyStringRequest getReidentifyStringRequest(ReidentifyTextRequest reidentifyTextRequest, String vaultId) throws SkyflowException { - List maskEntities = null; - List redactedEntities = null; - List plaintextEntities = null; - - if (reidentifyTextRequest.getMaskedEntities() != null) { - maskEntities = reidentifyTextRequest.getMaskedEntities().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList()); - } - - if (reidentifyTextRequest.getPlainTextEntities() != null) { - plaintextEntities = reidentifyTextRequest.getPlainTextEntities().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList()); - } - - if (reidentifyTextRequest.getRedactedEntities() != null) { - redactedEntities = reidentifyTextRequest.getRedactedEntities().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList()); - } - - ReidentifyStringRequestFormat reidentifyStringRequestFormat = ReidentifyStringRequestFormat.builder() - .masked(maskEntities) - .plaintext(plaintextEntities) - .redacted(redactedEntities) - .build(); - - - return ReidentifyStringRequest.builder() - .text(reidentifyTextRequest.getText()) - .vaultId(vaultId) - .format(reidentifyStringRequestFormat) - .build(); - } - - - private EntityInfo convertDetectedEntityToEntityInfo(DetectedEntity detectedEntity) { - TextIndex textIndex = new TextIndex( - detectedEntity.getLocation().get().getStartIndex().orElse(0), - detectedEntity.getLocation().get().getEndIndex().orElse(0) - ); - TextIndex processedIndex = new TextIndex( - detectedEntity.getLocation().get().getStartIndexProcessed().orElse(0), - detectedEntity.getLocation().get().getEndIndexProcessed().orElse(0) - ); - - Map entityScores = detectedEntity.getEntityScores() - .map(doubleMap -> doubleMap.entrySet().stream() - .collect(Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue - ))) - .orElse(Collections.emptyMap()); - - - return new EntityInfo( - detectedEntity.getToken().orElse(""), - detectedEntity.getValue().orElse(""), - textIndex, - processedIndex, - detectedEntity.getEntityType().orElse(""), - entityScores); - } - - - private Transformations getTransformations(com.skyflow.vault.detect.Transformations transformations) { - if (transformations == null || transformations.getShiftDates() == null) { - return null; - } - - List entityTypes = null; - if (!transformations.getShiftDates().getEntities().isEmpty()) { - entityTypes = transformations.getShiftDates().getEntities().stream() - .map(entity -> TransformationsShiftDatesEntityTypesItem.valueOf(entity.name())) - .collect(Collectors.toList()); - } else { - entityTypes = Collections.emptyList(); - } - - return Transformations.builder() - .shiftDates(TransformationsShiftDates.builder() - .maxDays(transformations.getShiftDates().getMax()) - .minDays(transformations.getShiftDates().getMin()) - .entityTypes(entityTypes) - .build()) - .build(); - } - - private List getEntityTypes(List entities){ - List mappedEntityTypes = null; - if (entities != null) { - mappedEntityTypes = entities.stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList()); - } - - return mappedEntityTypes; - } - - protected com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest getDeidentifyTextFileRequest(DeidentifyFileRequest request, String vaultId, String base64Content){ - List mappedEntityTypes = getEntityTypes(request.getEntities()); - - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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()) { - entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { - entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - } - - TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() - .entityOnly(entityTypes) - .entityUnqCounter(entityUniqueCounter) - .build(); - - DeidentifyTextRequestFile file = DeidentifyTextRequestFile.builder() - .base64(base64Content) - .build(); - - // Build the final request - com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest req = - com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - - return req; - } - - - protected DeidentifyAudioRequest getDeidentifyAudioRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String dataFormat) throws SkyflowException { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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()) { - entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { - entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - } - - TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() - .entityOnly(entityTypes) - .entityUnqCounter(entityUniqueCounter) - .build(); - - DeidentifyAudioRequestFile deidentifyAudioRequestFile = DeidentifyAudioRequestFile.builder().base64(base64Content).dataFormat(mapAudioDataFormat(dataFormat)).build(); - DetectOutputTranscriptions transcription = request.getOutputTranscription(); - DeidentifyAudioRequestOutputTranscription outputTranscriptionType = null; - if (transcription != null) { - outputTranscriptionType = DeidentifyAudioRequestOutputTranscription.valueOf(transcription.name()); - } - - return DeidentifyAudioRequest.builder() - .vaultId(vaultId) - .file(deidentifyAudioRequestFile) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .entityTypes(mappedEntityTypes) - .bleepFrequency(request.getBleep() != null ? request.getBleep().getFrequency() : null) - .bleepGain(request.getBleep() != null ? request.getBleep().getGain() : null) - .bleepStartPadding(request.getBleep() != null ? request.getBleep().getStartPadding() : null) - .bleepStopPadding(request.getBleep() != null ? request.getBleep().getStopPadding() : null) - .outputProcessedAudio(request.getOutputProcessedAudio()) - .outputTranscription(outputTranscriptionType) - .tokenType(tokenType) - .transformations(transformations) - .build(); - } - - protected DeidentifyPdfRequest getDeidentifyPdfRequest(DeidentifyFileRequest request, String vaultId, String base64Content) { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - - TokenFormat tokenFormat = request.getTokenFormat(); - Optional> entityTypes = Optional.empty(); - 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()) { - entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { - entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - } - - TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() - .entityOnly(entityTypes) - .entityUnqCounter(entityUniqueCounter) - .build(); - - DeidentifyPdfRequestFile file = DeidentifyPdfRequestFile.builder() - .base64(base64Content) - .build(); - - return DeidentifyPdfRequest.builder() - .vaultId(vaultId) - .file(file) - .density(request.getPixelDensity() != null ? request.getPixelDensity().intValue() : null) - .maxResolution(request.getMaxResolution() != null ? request.getMaxResolution().intValue() : null) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - protected DeidentifyImageRequest getDeidentifyImageRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - - TokenFormat tokenFormat = request.getTokenFormat(); - Optional> entityTypes = Optional.empty(); - 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); - - DeidentifyImageRequestFile file = DeidentifyImageRequestFile.builder() - .base64(base64Content) - .dataFormat(DeidentifyImageRequestFileDataFormat.valueOf(format.toUpperCase())) - .build(); - - Optional maskingMethod = Optional.empty(); - if (request.getMaskingMethod() != null) { - maskingMethod = Optional.of(DeidentifyImageRequestMaskingMethod.valueOf(request.getMaskingMethod().name())); - } - - return DeidentifyImageRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .maskingMethod(maskingMethod) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .outputProcessedImage(request.getOutputProcessedImage()) - .outputOcrText(request.getOutputOcrText()) - .build(); - } - - protected DeidentifyPresentationRequest getDeidentifyPresentationRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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); - - DeidentifyPresentationRequestFile file = DeidentifyPresentationRequestFile.builder() - .base64(base64Content) - .dataFormat(DeidentifyPresentationRequestFileDataFormat.valueOf(format.toUpperCase())) - .build(); - - return DeidentifyPresentationRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - protected DeidentifySpreadsheetRequest getDeidentifySpreadsheetRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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); - - DeidentifySpreadsheetRequestFile file = DeidentifySpreadsheetRequestFile.builder() - .base64(base64Content) - .dataFormat(DeidentifySpreadsheetRequestFileDataFormat.valueOf(format.toUpperCase())) - .build(); - - return DeidentifySpreadsheetRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - protected DeidentifyStructuredTextRequest getDeidentifyStructuredTextRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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); - - DeidentifyStructuredTextRequestFile file = DeidentifyStructuredTextRequestFile.builder() - .base64(base64Content) - .dataFormat(DeidentifyStructuredTextRequestFileDataFormat.valueOf(format.toUpperCase())) - .build(); - - return DeidentifyStructuredTextRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - protected DeidentifyDocumentRequest getDeidentifyDocumentRequest(DeidentifyFileRequest request, String vaultId, String base64Content, String format) { - List mappedEntityTypes = getEntityTypes(request.getEntities()); - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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); - - DeidentifyDocumentRequestFile file = DeidentifyDocumentRequestFile.builder() - .base64(base64Content) - .dataFormat(DeidentifyDocumentRequestFileDataFormat.valueOf(format.toUpperCase())) - .build(); - - return DeidentifyDocumentRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - protected com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest getDeidentifyGenericFileRequest( - DeidentifyFileRequest request, String vaultId, String base64Content, String fileExtension) { - - List mappedEntityTypes = getEntityTypes(request.getEntities()); - - TokenFormat tokenFormat = request.getTokenFormat(); - - Optional> entityTypes = Optional.empty(); - 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()) { - entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { - entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - } - - TokenTypeWithoutVault tokenType = TokenTypeWithoutVault.builder() - .entityOnly(entityTypes) - .entityUnqCounter(entityUniqueCounter) - .build(); - - DeidentifyFileRequestFile file = - DeidentifyFileRequestFile.builder() - .base64(base64Content) - .dataFormat(fileExtension != null ? DeidentifyFileRequestFileDataFormat.valueOf(fileExtension.toUpperCase()) : null) - .build(); - - return com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest.builder() - .vaultId(vaultId) - .file(file) - .entityTypes(mappedEntityTypes) - .tokenType(tokenType) - .allowRegex(allowRegex) - .restrictRegex(restrictRegex) - .transformations(transformations) - .build(); - } - - private TokenTypeWithoutVault buildTokenType(TokenFormat tokenFormat, - Optional> entityTypes, - Optional> entityUniqueCounter) { - - if (tokenFormat != null) { - if (tokenFormat.getEntityOnly() != null && !tokenFormat.getEntityOnly().isEmpty()) { - entityTypes = Optional.of(tokenFormat.getEntityOnly().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - - if (tokenFormat.getEntityUniqueCounter() != null && !tokenFormat.getEntityUniqueCounter().isEmpty()) { - entityUniqueCounter = Optional.of(tokenFormat.getEntityUniqueCounter().stream() - .map(detectEntity -> EntityType.valueOf(detectEntity.name())) - .collect(Collectors.toList())); - } - } - - return TokenTypeWithoutVault.builder() - .entityOnly(entityTypes) - .entityUnqCounter(entityUniqueCounter) - .build(); - } - - private DeidentifyAudioRequestFileDataFormat mapAudioDataFormat(String dataFormat) throws SkyflowException { - switch (dataFormat) { - case "mp3": - return DeidentifyAudioRequestFileDataFormat.MP_3; - case "wav": - return DeidentifyAudioRequestFileDataFormat.WAV; - default: - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidAudioFileType.getMessage()); - } - } - - private void updateVaultURL() { - String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); - this.apiClientBuilder.url(vaultURL); - } - - private void prioritiseCredentials() throws SkyflowException { - try { - Credentials original = this.finalCredentials; - if (this.vaultConfig.getCredentials() != null) { - this.finalCredentials = this.vaultConfig.getCredentials(); - } else if (this.commonCredentials != null) { - this.finalCredentials = this.commonCredentials; - } else { - Dotenv dotenv = Dotenv.load(); - String sysCredentials = dotenv.get(Constants.ENV_CREDENTIALS_KEY_NAME); - if (sysCredentials == null) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.EmptyCredentials.getMessage()); - } else { - this.finalCredentials = new Credentials(); - this.finalCredentials.setCredentialsString(sysCredentials); - } - } - if (original != null && !original.equals(this.finalCredentials)) { - token = null; - apiKey = null; - } - } catch (DotenvException e) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.EmptyCredentials.getMessage()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/com/skyflow/config/ConnectionConfig.java b/src/main/java/com/skyflow/config/ConnectionConfig.java deleted file mode 100644 index c017b181..00000000 --- a/src/main/java/com/skyflow/config/ConnectionConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.skyflow.config; - -public class ConnectionConfig { - private String connectionId; - private String connectionUrl; - private Credentials credentials; - - public ConnectionConfig() { - this.connectionId = null; - this.connectionUrl = null; - this.credentials = null; - } - - public String getConnectionId() { - return connectionId; - } - - public void setConnectionId(String connectionId) { - this.connectionId = connectionId; - } - - public String getConnectionUrl() { - return connectionUrl; - } - - public void setConnectionUrl(String connectionUrl) { - this.connectionUrl = connectionUrl; - } - - public Credentials getCredentials() { - return credentials; - } - - public void setCredentials(Credentials credentials) { - this.credentials = credentials; - } - -} diff --git a/src/main/java/com/skyflow/config/ManagementConfig.java b/src/main/java/com/skyflow/config/ManagementConfig.java deleted file mode 100644 index a054c8ea..00000000 --- a/src/main/java/com/skyflow/config/ManagementConfig.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.skyflow.config; - -public class ManagementConfig { - // members - - // constructor - ManagementConfig() { - } - - // getters and setters -} diff --git a/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java b/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java deleted file mode 100644 index e17c6d0c..00000000 --- a/src/main/java/com/skyflow/enums/DeidentifyFileStatus.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.skyflow.enums; - -public enum DeidentifyFileStatus { - IN_PROGRESS("IN_PROGRESS"), - SUCCESS("SUCCESS"); - - private final String value; - - DeidentifyFileStatus(String value) { - this.value = value; - } - - public String value() { - return value; - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/enums/DetectEntities.java b/src/main/java/com/skyflow/enums/DetectEntities.java deleted file mode 100644 index f2c21eff..00000000 --- a/src/main/java/com/skyflow/enums/DetectEntities.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.skyflow.enums; - - -public enum DetectEntities { - ACCOUNT_NUMBER("account_number"), - AGE("age"), - ALL("all"), - BANK_ACCOUNT("bank_account"), - BLOOD_TYPE("blood_type"), - CONDITION("condition"), - CORPORATE_ACTION("corporate_action"), - CREDIT_CARD("credit_card"), - CREDIT_CARD_EXPIRATION("credit_card_expiration"), - CVV("cvv"), - DATE("date"), - DATE_INTERVAL("date_interval"), - DOB("dob"), - DOSE("dose"), - DRIVER_LICENSE("driver_license"), - DRUG("drug"), - DURATION("duration"), - EMAIL_ADDRESS("email_address"), - EVENT("event"), - FILENAME("filename"), - FINANCIAL_METRIC("financial_metric"), - GENDER_SEXUALITY("gender_sexuality"), - HEALTHCARE_NUMBER("healthcare_number"), - INJURY("injury"), - IP_ADDRESS("ip_address"), - LANGUAGE("language"), - LOCATION("location"), - LOCATION_ADDRESS("location_address"), - LOCATION_ADDRESS_STREET("location_address_street"), - LOCATION_CITY("location_city"), - LOCATION_COORDINATE("location_coordinate"), - LOCATION_COUNTRY("location_country"), - LOCATION_STATE("location_state"), - LOCATION_ZIP("location_zip"), - MARITAL_STATUS("marital_status"), - MEDICAL_CODE("medical_code"), - MEDICAL_PROCESS("medical_process"), - MONEY("money"), - NAME("name"), - NAME_FAMILY("name_family"), - NAME_GIVEN("name_given"), - NAME_MEDICAL_PROFESSIONAL("name_medical_professional"), - NUMERICAL_PII("numerical_pii"), - OCCUPATION("occupation"), - ORGANIZATION("organization"), - ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), - ORIGIN("origin"), - PASSPORT_NUMBER("passport_number"), - PASSWORD("password"), - PHONE_NUMBER("phone_number"), - PHYSICAL_ATTRIBUTE("physical_attribute"), - POLITICAL_AFFILIATION("political_affiliation"), - PRODUCT("product"), - RELIGION("religion"), - ROUTING_NUMBER("routing_number"), - SSN("ssn"), - STATISTICS("statistics"), - TIME("time"), - TREND("trend"), - URL("url"), - USERNAME("username"), - VEHICLE_ID("vehicle_id"), - ZODIAC_SIGN("zodiac_sign"); - - private final String detectEntities; - - DetectEntities(String detectEntities) { - this.detectEntities = detectEntities; - } - - public String getDetectEntities() { - return detectEntities; - } - - @Override - public String toString() { - return detectEntities; - } -} diff --git a/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java b/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java deleted file mode 100644 index 43251c61..00000000 --- a/src/main/java/com/skyflow/enums/DetectOutputTranscriptions.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.skyflow.enums; - -public enum DetectOutputTranscriptions { - DIARIZED_TRANSCRIPTION("diarized_transcription"), - MEDICAL_DIARIZED_TRANSCRIPTION("medical_diarized_transcription"), - MEDICAL_TRANSCRIPTION("medical_transcription"), - PLAINTEXT_TRANSCRIPTION("plaintext_transcription"), - TRANSCRIPTION("transcription"); - - private final String detectOutputTranscriptions; - - DetectOutputTranscriptions(String detectOutputTranscriptions) { - this.detectOutputTranscriptions = detectOutputTranscriptions; - } - - public String getDetectOutputTranscriptions() { - return detectOutputTranscriptions; - } - - @Override - public String toString() { - return detectOutputTranscriptions; - } -} diff --git a/src/main/java/com/skyflow/enums/MaskingMethod.java b/src/main/java/com/skyflow/enums/MaskingMethod.java deleted file mode 100644 index e3ff252c..00000000 --- a/src/main/java/com/skyflow/enums/MaskingMethod.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.skyflow.enums; - -public enum MaskingMethod { - BLACKBOX("blackbox"), - BLUR("blur"); - - private final String maskingMethod; - - MaskingMethod(String maskingMethod) { - this.maskingMethod = maskingMethod; - } - - public String getMaskingMethod() { - return maskingMethod; - } - - @Override - public String toString() { - return maskingMethod; - } -} diff --git a/src/main/java/com/skyflow/enums/RedactionType.java b/src/main/java/com/skyflow/enums/RedactionType.java deleted file mode 100644 index 9c76cc7d..00000000 --- a/src/main/java/com/skyflow/enums/RedactionType.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.skyflow.enums; - - -import com.skyflow.generated.rest.types.RedactionEnumRedaction; - -public enum RedactionType { - PLAIN_TEXT(RedactionEnumRedaction.PLAIN_TEXT), - MASKED(RedactionEnumRedaction.MASKED), - DEFAULT(RedactionEnumRedaction.DEFAULT), - REDACTED(RedactionEnumRedaction.REDACTED); - - private final RedactionEnumRedaction redaction; - - RedactionType(RedactionEnumRedaction redaction) { - this.redaction = redaction; - } - - public RedactionEnumRedaction getRedaction() { - return redaction; - } - - @Override - public String toString() { - return String.valueOf(redaction); - } -} diff --git a/src/main/java/com/skyflow/enums/RequestMethod.java b/src/main/java/com/skyflow/enums/RequestMethod.java deleted file mode 100644 index ffa3d949..00000000 --- a/src/main/java/com/skyflow/enums/RequestMethod.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.skyflow.enums; - -public enum RequestMethod { - GET("GET"), - POST("POST"), - PUT("PUT"), - PATCH("PATCH"), - DELETE("DELETE"), - ; - - private final String requestMethod; - - - RequestMethod(String requestMethod) { - this.requestMethod = requestMethod; - } - - @Override - public String toString() { - return requestMethod; - } -} diff --git a/src/main/java/com/skyflow/enums/TokenMode.java b/src/main/java/com/skyflow/enums/TokenMode.java deleted file mode 100644 index 63e9b8a9..00000000 --- a/src/main/java/com/skyflow/enums/TokenMode.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.skyflow.enums; - -import com.skyflow.generated.rest.types.V1Byot; - -public enum TokenMode { - DISABLE(V1Byot.DISABLE), - ENABLE(V1Byot.ENABLE), - ENABLE_STRICT(V1Byot.ENABLE_STRICT); - - private final V1Byot byot; - - TokenMode(V1Byot byot) { - this.byot = byot; - } - - public V1Byot getBYOT() { - return byot; - } - - @Override - public String toString() { - return byot.toString(); - } -} diff --git a/src/main/java/com/skyflow/enums/TokenType.java b/src/main/java/com/skyflow/enums/TokenType.java deleted file mode 100644 index 4a619e9c..00000000 --- a/src/main/java/com/skyflow/enums/TokenType.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.skyflow.enums; - -public enum TokenType { - VAULT_TOKEN("vault_token"), - ENTITY_UNIQUE_COUNTER("entity_unq_counter"), - ENTITY_ONLY("entity_only"); - - private final String tokenType; - - TokenType(String tokenType) { - this.tokenType = tokenType; - } - - public String getTokenType() { - return tokenType; - } - - public String getDefault() { - return ENTITY_UNIQUE_COUNTER.getTokenType(); - } - - @Override - public String toString() { - return tokenType; - } -} - diff --git a/src/main/java/com/skyflow/errors/ErrorMessage.java b/src/main/java/com/skyflow/errors/ErrorMessage.java deleted file mode 100644 index df075bca..00000000 --- a/src/main/java/com/skyflow/errors/ErrorMessage.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.skyflow.errors; - -import com.skyflow.utils.Constants; - -public enum ErrorMessage { - // Client initialization - VaultIdAlreadyInConfigList("%s0 Validation error. VaultId is present in an existing config. Specify a new vaultId in config."), - VaultIdNotInConfigList("%s0 Validation error. VaultId is missing from the config. Specify the vaultIds from configs."), - ConnectionIdAlreadyInConfigList("%s0 Validation error. ConnectionId is present in an existing config. Specify a connectionId in config."), - ConnectionIdNotInConfigList("%s0 Validation error. ConnectionId is missing from the config. Specify the connectionIds from configs."), - EmptyCredentials("%s0 Validation error. Invalid credentials. Credentials must not be empty."), - - // Vault config - InvalidVaultId("%s0 Initialization failed. Invalid vault ID. Specify a valid vault ID."), - EmptyVaultId("%s0 Initialization failed. Invalid vault ID. Vault ID must not be empty."), - InvalidClusterId("%s0 Initialization failed. Invalid cluster ID. Specify cluster ID."), - EmptyClusterId("%s0 Initialization failed. Invalid cluster ID. Specify a valid cluster ID."), - - // Connection config - InvalidConnectionId("%s0 Initialization failed. Invalid connection ID. Specify a valid connection ID."), - EmptyConnectionId("%s0 Initialization failed. Invalid connection ID. Connection ID must not be empty."), - InvalidConnectionUrl("%s0 Initialization failed. Invalid connection URL. Specify a valid connection URL."), - EmptyConnectionUrl("%s0 Initialization failed. Invalid connection URL. Connection URL must not be empty."), - InvalidConnectionUrlFormat("%s0 Initialization failed. Connection URL is not a valid URL. Specify a valid connection URL."), - - // Credentials - MultipleTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify only one from 'path', 'credentialsString', 'token' or 'apiKey'."), - NoTokenGenerationMeansPassed("%s0 Initialization failed. Invalid credentials. Specify any one from 'path', 'credentialsString', 'token' or 'apiKey'."), - EmptyCredentialFilePath("%s0 Initialization failed. Invalid credentials. Credentials file path must not be empty."), - EmptyCredentialsString("%s0 Initialization failed. Invalid credentials. Credentials string must not be empty."), - EmptyToken("%s0 Initialization failed. Invalid credentials. Token must not be empty."), - EmptyApikey("%s0 Initialization failed. Invalid credentials. Api key must not be empty."), - InvalidApikey("%s0 Initialization failed. Invalid credentials. Specify valid api key."), - EmptyRoles("%s0 Initialization failed. Invalid roles. Specify at least one role."), - EmptyRoleInRoles("%s0 Initialization failed. Invalid role. Specify a valid role."), - EmptyContext("%s0 Initialization failed. Invalid context. Specify a valid context."), - - // Bearer token generation - FileNotFound("%s0 Initialization failed. Credential file not found at %s1. Verify the file path."), - FileInvalidJson("%s0 Initialization failed. File at %s1 is not in valid JSON format. Verify the file contents."), - CredentialsStringInvalidJson("%s0 Initialization failed. Credentials string is not in valid JSON format. Verify the credentials string contents."), - InvalidCredentials("%s0 Initialization failed. Invalid credentials provided. Specify valid credentials."), - MissingPrivateKey("%s0 Initialization failed. Unable to read private key in credentials. Verify your private key."), - MissingClientId("%s0 Initialization failed. Unable to read client ID in credentials. Verify your client ID."), - MissingKeyId("%s0 Initialization failed. Unable to read key ID in credentials. Verify your key ID."), - MissingTokenUri("%s0 Initialization failed. Unable to read token URI in credentials. Verify your token URI."), - InvalidTokenUri("%s0 Initialization failed. Token URI in not a valid URL in credentials. Verify your token URI."), - JwtInvalidFormat("%s0 Initialization failed. Invalid private key format. Verify your credentials."), - InvalidAlgorithm("%s0 Initialization failed. Invalid algorithm to parse private key. Specify valid algorithm."), - InvalidKeySpec("%s0 Initialization failed. Unable to parse RSA private key. Verify your credentials."), - JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."), - MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."), - MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."), - - // Insert - TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."), - EmptyTable("%s0 Validation error. 'table' can't be empty. Specify a table."), - ValuesKeyError("%s0 Validation error. 'values' key is missing from the payload. Specify a 'values' key."), - EmptyValues("%s0 Validation error. 'values' can't be empty. Specify values."), - EmptyKeyInValues("%s0 Validation error. Invalid key in values. Specify a valid key."), - EmptyValueInValues("%s0 Validation error. Invalid value in values. Specify a valid value."), - TokensKeyError("%s0 Validation error. 'tokens' key is missing from the payload. Specify a 'tokens' key."), - EmptyTokens("%s0 Validation error. The 'tokens' field is empty. Specify tokens for one or more fields."), - EmptyKeyInTokens("%s0 Validation error. Invalid key tokens. Specify a valid key."), - EmptyValueInTokens("%s0 Validation error. Invalid value in tokens. Specify a valid value."), - EmptyUpsert("%s0 Validation error. 'upsert' key can't be empty. Specify an upsert column."), - HomogenousNotSupportedWithUpsert("%s0 Validation error. 'homogenous' is not supported with 'upsert'. Specify either 'homogenous' or 'upsert'."), - TokensPassedForTokenModeDisable("%s0 Validation error. 'tokenMode' wasn't specified. Set 'tokenMode' to 'ENABLE' to insert tokens."), - NoTokensWithTokenMode("%s0 Validation error. Tokens weren't specified for records while 'tokenMode' was %s1. Specify tokens."), - MismatchOfFieldsAndTokens("%s0 Validation error. 'fields' and 'tokens' have different columns names. Verify that 'fields' and 'tokens' columns match."), - InsufficientTokensPassedForTokenModeEnableStrict("%s0 Validation error. 'tokenMode' is set to 'ENABLE_STRICT', but some fields are missing tokens. Specify tokens for all fields."), - BatchInsertPartialSuccess("%s0 Insert operation completed with partial success."), - BatchInsertFailure("%s0 Insert operation failed."), - - // Detokenize - InvalidDetokenizeData("%s0 Validation error. Invalid detokenize data. Specify valid detokenize data."), - EmptyDetokenizeData("%s0 Validation error. Invalid data tokens. Specify at least one data token."), - EmptyTokenInDetokenizeData("%s0 Validation error. Invalid data tokens. Specify a valid data token."), - - // Get - IdsKeyError("%s0 Validation error. 'ids' key is missing from the payload. Specify an 'ids' key."), - EmptyIds("%s0 Validation error. 'ids' can't be empty. Specify at least one id."), - EmptyIdInIds("%s0 Validation error. Invalid id in 'ids'. Specify a valid id."), - EmptyFields("%s0 Validation error. Fields are empty in get payload. Specify at least one field."), - EmptyFieldInFields("%s0 Validation error. Invalid field in 'fields'. Specify a valid field."), - RedactionKeyError("%s0 Validation error. 'redaction' key is missing from the payload. Specify a 'redaction' key."), - RedactionWithTokensNotSupported("%s0 Validation error. 'redaction' can't be used when 'returnTokens' is specified. Remove 'redaction' from payload if 'returnTokens' is specified."), - TokensGetColumnNotSupported("%s0 Validation error. Column name and/or column values can't be used when 'returnTokens' is specified. Remove unique column values or 'returnTokens' from the payload."), - EmptyOffset("%s0 Validation error. 'offset' can't be empty. Specify an offset."), - EmptyLimit("%s0 Validation error. 'limit' can't be empty. Specify a limit."), - UniqueColumnOrIdsKeyError("%s0 Validation error. 'ids' or 'columnName' key is missing from the payload. Specify the ids or unique 'columnName' in payload."), - BothIdsAndColumnDetailsSpecified("%s0 Validation error. Both Skyflow IDs and column details can't be specified. Either specify Skyflow IDs or unique column details."), - ColumnNameKeyError("%s0 Validation error. 'columnName' isn't specified whereas 'columnValues' are specified. Either add 'columnName' or remove 'columnValues'."), - EmptyColumnName("%s0 Validation error. 'columnName' can't be empty. Specify a column name."), - ColumnValuesKeyErrorGet("%s0 Validation error. 'columnValues' aren't specified whereas 'columnName' is specified. Either add 'columnValues' or remove 'columnName'."), - EmptyColumnValues("%s0 Validation error. 'columnValues' can't be empty. Specify at least one column value"), - EmptyValueInColumnValues("%s0 Validation error. Invalid value in column values. Specify a valid column value."), - - TokenKeyError("%s0 Validation error. 'token' key is missing from the payload. Specify a 'token' key."), - PartialSuccess("%s0 Validation error. Check 'SkyflowError.data' for details."), - - // Update - DataKeyError("%s0 Validation error. 'data' key is missing from the payload. Specify a 'data' key."), - EmptyData("%s0 Validation error. 'data' can't be empty. Specify data."), - SkyflowIdKeyError("%s0 Validation error. 'skyflow_id' is missing from the data payload. Specify a 'skyflow_id'."), - InvalidSkyflowIdType("%s0 Validation error. Invalid type for 'skyflow_id' in data payload. Specify 'skyflow_id' as a string."), - EmptySkyflowId("%s0 Validation error. 'skyflow_id' can't be empty. Specify a skyflow id."), - - // Query - QueryKeyError("%s0 Validation error. 'query' key is missing from the payload. Specify a 'query' key."), - EmptyQuery("%s0 Validation error. 'query' can't be empty. Specify a query"), - - // Tokenize - ColumnValuesKeyErrorTokenize("%s0 Validation error. 'columnValues' key is missing from the payload. Specify a 'columnValues' key."), - EmptyColumnGroupInColumnValue("%s0 Validation error. Invalid column group in column value. Specify a valid column group."), - - // Connection - InvalidRequestHeaders("%s0 Validation error. Request headers aren't valid. Specify valid request headers."), - EmptyRequestHeaders("%s0 Validation error. Request headers are empty. Specify valid request headers."), - InvalidPathParams("%s0 Validation error. Path parameters aren't valid. Specify valid path parameters."), - EmptyPathParams("%s0 Validation error. Path parameters are empty. Specify valid path parameters."), - InvalidQueryParams("%s0 Validation error. Query parameters aren't valid. Specify valid query parameters."), - EmptyQueryParams("%s0 Validation error. Query parameters are empty. Specify valid query parameters."), - 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."), - - // 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."), - - //Detect Files - InvalidNullFileInDeIdentifyFile("%s0 Validation error. The file field is required and must not be null. Specify a valid file object."), - InvalidFilePath("%s0 Validation error. The file path is invalid. Specify a valid file path."), - BothFileAndFilePathProvided("%s0 Validation error. Both file and filePath are provided. Specify either file object or filePath, not both."), - FileNotFoundToDeidentify("%s0 Validation error. The file to deidentify was not found at the specified path. Verify the file path and try again."), - FileNotReadableToDeidentify("%s0 Validation error. The file to deidentify is not readable. Check the file permissions and try again."), - InvalidPixelDensityToDeidentifyFile("%s0 Validation error. Should be a positive integer. Specify a valid pixel density."), - InvalidMaxResolution("%s0 Validation error. Should be a positive integer. Specify a valid max resolution."), - OutputDirectoryNotFound("%s0 Validation error. The output directory for deidentified files was not found at the specified path. Verify the output directory path and try again."), - InvalidPermission("%s0 Validation error. The output directory for deidentified files is not writable. Check the directory permissions and try again."), - InvalidWaitTime("%s0 Validation error. The wait time for deidentify file operation should be a positive integer. Specify a valid wait time."), - WaitTimeExceedsLimit("%s0 Validation error. The wait time for deidentify file operation exceeds the maximum limit of 64 seconds. Specify a wait time less than or equal to 60 seconds."), - InvalidOrEmptyRunId("%s0 Validation error. The run ID is invalid or empty. Specify a valid run ID."), - 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."), - 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."), - // Generic - ErrorOccurred("%s0 API error. Error occurred.") - ; - private final String message; - - ErrorMessage(String message) { - this.message = message.replace("%s0", Constants.SDK_PREFIX); - } - - public String getMessage() { - return message; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/ApiClient.java b/src/main/java/com/skyflow/generated/rest/ApiClient.java deleted file mode 100644 index 296a553f..00000000 --- a/src/main/java/com/skyflow/generated/rest/ApiClient.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.Suppliers; -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.query.QueryClient; -import com.skyflow.generated.rest.resources.records.RecordsClient; -import com.skyflow.generated.rest.resources.strings.StringsClient; -import com.skyflow.generated.rest.resources.tokens.TokensClient; -import java.util.function.Supplier; - -public class ApiClient { - protected final ClientOptions clientOptions; - - protected final Supplier auditClient; - - protected final Supplier binLookupClient; - - protected final Supplier recordsClient; - - protected final Supplier tokensClient; - - protected final Supplier queryClient; - - protected final Supplier authenticationClient; - - protected final Supplier deprecatedClient; - - protected final Supplier stringsClient; - - protected final Supplier filesClient; - - public ApiClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.auditClient = Suppliers.memoize(() -> new AuditClient(clientOptions)); - this.binLookupClient = Suppliers.memoize(() -> new BinLookupClient(clientOptions)); - this.recordsClient = Suppliers.memoize(() -> new RecordsClient(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.stringsClient = Suppliers.memoize(() -> new StringsClient(clientOptions)); - this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions)); - } - - public AuditClient audit() { - return this.auditClient.get(); - } - - public BinLookupClient binLookup() { - return this.binLookupClient.get(); - } - - public RecordsClient records() { - return this.recordsClient.get(); - } - - public TokensClient tokens() { - return this.tokensClient.get(); - } - - public QueryClient query() { - return this.queryClient.get(); - } - - public AuthenticationClient authentication() { - return this.authenticationClient.get(); - } - - public DeprecatedClient deprecated() { - return this.deprecatedClient.get(); - } - - public StringsClient strings() { - return this.stringsClient.get(); - } - - public FilesClient files() { - return this.filesClient.get(); - } - - public static ApiClientBuilder builder() { - return new ApiClientBuilder(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java b/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java deleted file mode 100644 index d36c8141..00000000 --- a/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.Suppliers; -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.query.AsyncQueryClient; -import com.skyflow.generated.rest.resources.records.AsyncRecordsClient; -import com.skyflow.generated.rest.resources.strings.AsyncStringsClient; -import com.skyflow.generated.rest.resources.tokens.AsyncTokensClient; -import java.util.function.Supplier; - -public class AsyncApiClient { - protected final ClientOptions clientOptions; - - protected final Supplier auditClient; - - protected final Supplier binLookupClient; - - protected final Supplier recordsClient; - - protected final Supplier tokensClient; - - protected final Supplier queryClient; - - protected final Supplier authenticationClient; - - protected final Supplier deprecatedClient; - - protected final Supplier stringsClient; - - protected final Supplier filesClient; - - public AsyncApiClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.auditClient = Suppliers.memoize(() -> new AsyncAuditClient(clientOptions)); - this.binLookupClient = Suppliers.memoize(() -> new AsyncBinLookupClient(clientOptions)); - this.recordsClient = Suppliers.memoize(() -> new AsyncRecordsClient(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.stringsClient = Suppliers.memoize(() -> new AsyncStringsClient(clientOptions)); - this.filesClient = Suppliers.memoize(() -> new AsyncFilesClient(clientOptions)); - } - - public AsyncAuditClient audit() { - return this.auditClient.get(); - } - - public AsyncBinLookupClient binLookup() { - return this.binLookupClient.get(); - } - - public AsyncRecordsClient records() { - return this.recordsClient.get(); - } - - public AsyncTokensClient tokens() { - return this.tokensClient.get(); - } - - public AsyncQueryClient query() { - return this.queryClient.get(); - } - - public AsyncAuthenticationClient authentication() { - return this.authenticationClient.get(); - } - - public AsyncDeprecatedClient deprecated() { - return this.deprecatedClient.get(); - } - - public AsyncStringsClient strings() { - return this.stringsClient.get(); - } - - public AsyncFilesClient files() { - return this.filesClient.get(); - } - - public static AsyncApiClientBuilder builder() { - return new AsyncApiClientBuilder(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java b/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java deleted file mode 100644 index badaddd3..00000000 --- a/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; -import okhttp3.OkHttpClient; - -public final class ClientOptions { - private final Environment environment; - - private final Map headers; - - private final Map> headerSuppliers; - - private final OkHttpClient httpClient; - - private final int timeout; - - private ClientOptions( - Environment environment, - Map headers, - Map> headerSuppliers, - OkHttpClient httpClient, - int timeout) { - this.environment = environment; - this.headers = new HashMap<>(); - this.headers.putAll(headers); - this.headers.putAll(new HashMap() { - { - put("X-Fern-Language", "JAVA"); - put("X-Fern-SDK-Name", "com.skyflow.fern:api-sdk"); - put("X-Fern-SDK-Version", "0.0.219"); - } - }); - this.headerSuppliers = headerSuppliers; - this.httpClient = httpClient; - this.timeout = timeout; - } - - public Environment environment() { - return this.environment; - } - - public Map headers(RequestOptions requestOptions) { - Map values = new HashMap<>(this.headers); - headerSuppliers.forEach((key, supplier) -> { - values.put(key, supplier.get()); - }); - if (requestOptions != null) { - values.putAll(requestOptions.getHeaders()); - } - return values; - } - - public int timeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.timeout; - } - return requestOptions.getTimeout().orElse(this.timeout); - } - - public OkHttpClient httpClient() { - return this.httpClient; - } - - public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.httpClient; - } - return this.httpClient - .newBuilder() - .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .build(); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private Environment environment; - - private final Map headers = new HashMap<>(); - - private final Map> headerSuppliers = new HashMap<>(); - - private int maxRetries = 2; - - private Optional timeout = Optional.empty(); - - private OkHttpClient httpClient = null; - - public Builder environment(Environment environment) { - this.environment = environment; - return this; - } - - public Builder addHeader(String key, String value) { - this.headers.put(key, value); - return this; - } - - public Builder addHeader(String key, Supplier value) { - this.headerSuppliers.put(key, value); - return this; - } - - /** - * Override the timeout in seconds. Defaults to 60 seconds. - */ - public Builder timeout(int timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - /** - * Override the timeout in seconds. Defaults to 60 seconds. - */ - public Builder timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - /** - * Override the maximum number of retries. Defaults to 2 retries. - */ - public Builder maxRetries(int maxRetries) { - this.maxRetries = maxRetries; - return this; - } - - public Builder httpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - public ClientOptions build() { - OkHttpClient.Builder httpClientBuilder = - this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); - - if (this.httpClient != null) { - timeout.ifPresent(timeout -> httpClientBuilder - .callTimeout(timeout, TimeUnit.SECONDS) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS)); - } else { - httpClientBuilder - .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .addInterceptor(new RetryInterceptor(this.maxRetries)); - } - - this.httpClient = httpClientBuilder.build(); - this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); - - return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/core/Environment.java b/src/main/java/com/skyflow/generated/rest/core/Environment.java deleted file mode 100644 index c0adb233..00000000 --- a/src/main/java/com/skyflow/generated/rest/core/Environment.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.core; - -public final class Environment { - public static final Environment PRODUCTION = new Environment("https://identifier.vault.skyflowapis.com"); - - public static final Environment SANDBOX = new Environment("https://identifier.vault.skyflowapis-preview.com"); - - private final String url; - - private Environment(String url) { - this.url = url; - } - - public String getUrl() { - return this.url; - } - - public static Environment custom(String url) { - return new Environment(url); - } -} 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/errors/BadRequestError.java b/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java deleted file mode 100644 index c8d4bb99..00000000 --- a/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.errors; - -import com.skyflow.generated.rest.core.ApiClientApiException; -import okhttp3.Response; - -public final class BadRequestError extends ApiClientApiException { - /** - * The body of the response that triggered the exception. - */ - private final Object body; - - public BadRequestError(Object body) { - super("BadRequestError", 400, body); - this.body = body; - } - - public BadRequestError(Object body, Response rawResponse) { - super("BadRequestError", 400, body, rawResponse); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public Object body() { - return this.body; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java b/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java deleted file mode 100644 index d29f2b82..00000000 --- a/src/main/java/com/skyflow/generated/rest/errors/InternalServerError.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.errors; - -import com.skyflow.generated.rest.core.ApiClientApiException; -import com.skyflow.generated.rest.types.ErrorResponse; -import okhttp3.Response; - -public final class InternalServerError extends ApiClientApiException { - /** - * The body of the response that triggered the exception. - */ - private final ErrorResponse body; - - public InternalServerError(ErrorResponse body) { - super("InternalServerError", 500, body); - this.body = body; - } - - public InternalServerError(ErrorResponse body, Response rawResponse) { - super("InternalServerError", 500, body, rawResponse); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public ErrorResponse body() { - return this.body; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java b/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java deleted file mode 100644 index efa94aad..00000000 --- a/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.errors; - -import com.skyflow.generated.rest.core.ApiClientApiException; -import okhttp3.Response; - -public final class NotFoundError extends ApiClientApiException { - /** - * The body of the response that triggered the exception. - */ - private final Object body; - - public NotFoundError(Object body) { - super("NotFoundError", 404, body); - this.body = body; - } - - public NotFoundError(Object body, Response rawResponse) { - super("NotFoundError", 404, body, rawResponse); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public Object body() { - return this.body; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java b/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java deleted file mode 100644 index 3b6d6ae1..00000000 --- a/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.errors; - -import com.skyflow.generated.rest.core.ApiClientApiException; -import okhttp3.Response; - -public final class UnauthorizedError extends ApiClientApiException { - /** - * The body of the response that triggered the exception. - */ - private final Object body; - - public UnauthorizedError(Object body) { - super("UnauthorizedError", 401, body); - this.body = body; - } - - public UnauthorizedError(Object body, Response rawResponse) { - super("UnauthorizedError", 401, body, rawResponse); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public Object body() { - return this.body; - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java b/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java deleted file mode 100644 index 0064558d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncAuditClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.audit.requests.AuditServiceListAuditEventsRequest; -import com.skyflow.generated.rest.types.V1AuditResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncAuditClient { - protected final ClientOptions clientOptions; - - private final AsyncRawAuditClient rawClient; - - public AsyncAuditClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawAuditClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawAuditClient withRawResponse() { - return this.rawClient; - } - - /** - * Lists audit events that match query parameters. - */ - public CompletableFuture auditServiceListAuditEvents(AuditServiceListAuditEventsRequest request) { - return this.rawClient.auditServiceListAuditEvents(request).thenApply(response -> response.body()); - } - - /** - * Lists audit events that match query parameters. - */ - public CompletableFuture auditServiceListAuditEvents( - AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { - return this.rawClient - .auditServiceListAuditEvents(request, requestOptions) - .thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java b/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java deleted file mode 100644 index 875ca259..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/AsyncRawAuditClient.java +++ /dev/null @@ -1,296 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit; - -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.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.audit.requests.AuditServiceListAuditEventsRequest; -import com.skyflow.generated.rest.types.V1AuditResponse; -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.Response; -import okhttp3.ResponseBody; -import org.jetbrains.annotations.NotNull; - -public class AsyncRawAuditClient { - protected final ClientOptions clientOptions; - - public AsyncRawAuditClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Lists audit events that match query parameters. - */ - public CompletableFuture> auditServiceListAuditEvents( - AuditServiceListAuditEventsRequest request) { - return auditServiceListAuditEvents(request, null); - } - - /** - * Lists audit events that match query parameters. - */ - public CompletableFuture> auditServiceListAuditEvents( - AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/audit/events"); - if (request.getFilterOpsContextChangeId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.changeID", - request.getFilterOpsContextChangeId().get(), - false); - } - if (request.getFilterOpsContextRequestId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.requestID", - request.getFilterOpsContextRequestId().get(), - false); - } - if (request.getFilterOpsContextTraceId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.traceID", - request.getFilterOpsContextTraceId().get(), - false); - } - if (request.getFilterOpsContextSessionId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.sessionID", - request.getFilterOpsContextSessionId().get(), - false); - } - if (request.getFilterOpsContextActor().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.actor", - request.getFilterOpsContextActor().get(), - false); - } - if (request.getFilterOpsContextActorType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.actorType", - request.getFilterOpsContextActorType().get(), - false); - } - if (request.getFilterOpsContextAccessType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.accessType", - request.getFilterOpsContextAccessType().get(), - false); - } - if (request.getFilterOpsContextIpAddress().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.ipAddress", - request.getFilterOpsContextIpAddress().get(), - false); - } - if (request.getFilterOpsContextOrigin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.origin", - request.getFilterOpsContextOrigin().get(), - false); - } - if (request.getFilterOpsContextAuthMode().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.authMode", - request.getFilterOpsContextAuthMode().get(), - false); - } - if (request.getFilterOpsContextJwtId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.jwtID", - request.getFilterOpsContextJwtId().get(), - false); - } - if (request.getFilterOpsContextBearerTokenContextId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.bearerTokenContextID", - request.getFilterOpsContextBearerTokenContextId().get(), - false); - } - if (request.getFilterOpsParentAccountId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.parentAccountID", - request.getFilterOpsParentAccountId().get(), - false); - } - QueryStringMapper.addQueryParameter(httpUrl, "filterOps.accountID", request.getFilterOpsAccountId(), false); - if (request.getFilterOpsWorkspaceId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.workspaceID", - request.getFilterOpsWorkspaceId().get(), - false); - } - if (request.getFilterOpsVaultId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.vaultID", request.getFilterOpsVaultId().get(), false); - } - if (request.getFilterOpsResourceIDs().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.resourceIDs", - request.getFilterOpsResourceIDs().get(), - false); - } - if (request.getFilterOpsActionType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.actionType", - request.getFilterOpsActionType().get(), - false); - } - if (request.getFilterOpsResourceType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.resourceType", - request.getFilterOpsResourceType().get(), - false); - } - if (request.getFilterOpsTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.tags", request.getFilterOpsTags().get(), false); - } - if (request.getFilterOpsResponseCode().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.responseCode", - request.getFilterOpsResponseCode().get(), - false); - } - if (request.getFilterOpsStartTime().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.startTime", - request.getFilterOpsStartTime().get(), - false); - } - if (request.getFilterOpsEndTime().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.endTime", request.getFilterOpsEndTime().get(), false); - } - if (request.getFilterOpsApiName().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.apiName", request.getFilterOpsApiName().get(), false); - } - if (request.getFilterOpsResponseMessage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.responseMessage", - request.getFilterOpsResponseMessage().get(), - false); - } - if (request.getFilterOpsHttpMethod().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.httpMethod", - request.getFilterOpsHttpMethod().get(), - false); - } - if (request.getFilterOpsHttpUri().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.httpURI", request.getFilterOpsHttpUri().get(), false); - } - if (request.getSortOpsSortBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sortOps.sortBy", request.getSortOpsSortBy().get(), false); - } - if (request.getSortOpsOrderBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sortOps.orderBy", request.getSortOpsOrderBy().get(), false); - } - if (request.getAfterOpsTimestamp().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "afterOps.timestamp", - request.getAfterOpsTimestamp().get(), - false); - } - if (request.getAfterOpsChangeId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "afterOps.changeID", request.getAfterOpsChangeId().get(), false); - } - if (request.getLimit().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "limit", request.getLimit().get(), false); - } - if (request.getOffset().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "offset", request.getOffset().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(), V1AuditResponse.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/audit/AuditClient.java b/src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java deleted file mode 100644 index bac81431..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/AuditClient.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.audit.requests.AuditServiceListAuditEventsRequest; -import com.skyflow.generated.rest.types.V1AuditResponse; - -public class AuditClient { - protected final ClientOptions clientOptions; - - private final RawAuditClient rawClient; - - public AuditClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawAuditClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawAuditClient withRawResponse() { - return this.rawClient; - } - - /** - * Lists audit events that match query parameters. - */ - public V1AuditResponse auditServiceListAuditEvents(AuditServiceListAuditEventsRequest request) { - return this.rawClient.auditServiceListAuditEvents(request).body(); - } - - /** - * Lists audit events that match query parameters. - */ - public V1AuditResponse auditServiceListAuditEvents( - AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { - return this.rawClient - .auditServiceListAuditEvents(request, requestOptions) - .body(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java b/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java deleted file mode 100644 index bfec3bf2..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/RawAuditClient.java +++ /dev/null @@ -1,277 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit; - -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.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.audit.requests.AuditServiceListAuditEventsRequest; -import com.skyflow.generated.rest.types.V1AuditResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawAuditClient { - protected final ClientOptions clientOptions; - - public RawAuditClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Lists audit events that match query parameters. - */ - public ApiClientHttpResponse auditServiceListAuditEvents( - AuditServiceListAuditEventsRequest request) { - return auditServiceListAuditEvents(request, null); - } - - /** - * Lists audit events that match query parameters. - */ - public ApiClientHttpResponse auditServiceListAuditEvents( - AuditServiceListAuditEventsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/audit/events"); - if (request.getFilterOpsContextChangeId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.changeID", - request.getFilterOpsContextChangeId().get(), - false); - } - if (request.getFilterOpsContextRequestId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.requestID", - request.getFilterOpsContextRequestId().get(), - false); - } - if (request.getFilterOpsContextTraceId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.traceID", - request.getFilterOpsContextTraceId().get(), - false); - } - if (request.getFilterOpsContextSessionId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.sessionID", - request.getFilterOpsContextSessionId().get(), - false); - } - if (request.getFilterOpsContextActor().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.actor", - request.getFilterOpsContextActor().get(), - false); - } - if (request.getFilterOpsContextActorType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.actorType", - request.getFilterOpsContextActorType().get(), - false); - } - if (request.getFilterOpsContextAccessType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.accessType", - request.getFilterOpsContextAccessType().get(), - false); - } - if (request.getFilterOpsContextIpAddress().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.ipAddress", - request.getFilterOpsContextIpAddress().get(), - false); - } - if (request.getFilterOpsContextOrigin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.origin", - request.getFilterOpsContextOrigin().get(), - false); - } - if (request.getFilterOpsContextAuthMode().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.authMode", - request.getFilterOpsContextAuthMode().get(), - false); - } - if (request.getFilterOpsContextJwtId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.jwtID", - request.getFilterOpsContextJwtId().get(), - false); - } - if (request.getFilterOpsContextBearerTokenContextId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.context.bearerTokenContextID", - request.getFilterOpsContextBearerTokenContextId().get(), - false); - } - if (request.getFilterOpsParentAccountId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.parentAccountID", - request.getFilterOpsParentAccountId().get(), - false); - } - QueryStringMapper.addQueryParameter(httpUrl, "filterOps.accountID", request.getFilterOpsAccountId(), false); - if (request.getFilterOpsWorkspaceId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.workspaceID", - request.getFilterOpsWorkspaceId().get(), - false); - } - if (request.getFilterOpsVaultId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.vaultID", request.getFilterOpsVaultId().get(), false); - } - if (request.getFilterOpsResourceIDs().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.resourceIDs", - request.getFilterOpsResourceIDs().get(), - false); - } - if (request.getFilterOpsActionType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.actionType", - request.getFilterOpsActionType().get(), - false); - } - if (request.getFilterOpsResourceType().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.resourceType", - request.getFilterOpsResourceType().get(), - false); - } - if (request.getFilterOpsTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.tags", request.getFilterOpsTags().get(), false); - } - if (request.getFilterOpsResponseCode().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.responseCode", - request.getFilterOpsResponseCode().get(), - false); - } - if (request.getFilterOpsStartTime().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.startTime", - request.getFilterOpsStartTime().get(), - false); - } - if (request.getFilterOpsEndTime().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.endTime", request.getFilterOpsEndTime().get(), false); - } - if (request.getFilterOpsApiName().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.apiName", request.getFilterOpsApiName().get(), false); - } - if (request.getFilterOpsResponseMessage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.responseMessage", - request.getFilterOpsResponseMessage().get(), - false); - } - if (request.getFilterOpsHttpMethod().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "filterOps.httpMethod", - request.getFilterOpsHttpMethod().get(), - false); - } - if (request.getFilterOpsHttpUri().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "filterOps.httpURI", request.getFilterOpsHttpUri().get(), false); - } - if (request.getSortOpsSortBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sortOps.sortBy", request.getSortOpsSortBy().get(), false); - } - if (request.getSortOpsOrderBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sortOps.orderBy", request.getSortOpsOrderBy().get(), false); - } - if (request.getAfterOpsTimestamp().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "afterOps.timestamp", - request.getAfterOpsTimestamp().get(), - false); - } - if (request.getAfterOpsChangeId().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "afterOps.changeID", request.getAfterOpsChangeId().get(), false); - } - if (request.getLimit().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "limit", request.getLimit().get(), false); - } - if (request.getOffset().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "offset", request.getOffset().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(), V1AuditResponse.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/audit/requests/AuditServiceListAuditEventsRequest.java b/src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java deleted file mode 100644 index 3da04589..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/requests/AuditServiceListAuditEventsRequest.java +++ /dev/null @@ -1,1589 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.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.audit.types.AuditServiceListAuditEventsRequestFilterOpsActionType; -import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsContextAccessType; -import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsContextActorType; -import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsContextAuthMode; -import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestFilterOpsResourceType; -import com.skyflow.generated.rest.resources.audit.types.AuditServiceListAuditEventsRequestSortOpsOrderBy; -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 = AuditServiceListAuditEventsRequest.Builder.class) -public final class AuditServiceListAuditEventsRequest { - private final Optional filterOpsContextChangeId; - - private final Optional filterOpsContextRequestId; - - private final Optional filterOpsContextTraceId; - - private final Optional filterOpsContextSessionId; - - private final Optional filterOpsContextActor; - - private final Optional filterOpsContextActorType; - - private final Optional filterOpsContextAccessType; - - private final Optional filterOpsContextIpAddress; - - private final Optional filterOpsContextOrigin; - - private final Optional filterOpsContextAuthMode; - - private final Optional filterOpsContextJwtId; - - private final Optional filterOpsContextBearerTokenContextId; - - private final Optional filterOpsParentAccountId; - - private final String filterOpsAccountId; - - private final Optional filterOpsWorkspaceId; - - private final Optional filterOpsVaultId; - - private final Optional filterOpsResourceIDs; - - private final Optional filterOpsActionType; - - private final Optional filterOpsResourceType; - - private final Optional filterOpsTags; - - private final Optional filterOpsResponseCode; - - private final Optional filterOpsStartTime; - - private final Optional filterOpsEndTime; - - private final Optional filterOpsApiName; - - private final Optional filterOpsResponseMessage; - - private final Optional filterOpsHttpMethod; - - private final Optional filterOpsHttpUri; - - private final Optional sortOpsSortBy; - - private final Optional sortOpsOrderBy; - - private final Optional afterOpsTimestamp; - - private final Optional afterOpsChangeId; - - private final Optional limit; - - private final Optional offset; - - private final Map additionalProperties; - - private AuditServiceListAuditEventsRequest( - Optional filterOpsContextChangeId, - Optional filterOpsContextRequestId, - Optional filterOpsContextTraceId, - Optional filterOpsContextSessionId, - Optional filterOpsContextActor, - Optional filterOpsContextActorType, - Optional filterOpsContextAccessType, - Optional filterOpsContextIpAddress, - Optional filterOpsContextOrigin, - Optional filterOpsContextAuthMode, - Optional filterOpsContextJwtId, - Optional filterOpsContextBearerTokenContextId, - Optional filterOpsParentAccountId, - String filterOpsAccountId, - Optional filterOpsWorkspaceId, - Optional filterOpsVaultId, - Optional filterOpsResourceIDs, - Optional filterOpsActionType, - Optional filterOpsResourceType, - Optional filterOpsTags, - Optional filterOpsResponseCode, - Optional filterOpsStartTime, - Optional filterOpsEndTime, - Optional filterOpsApiName, - Optional filterOpsResponseMessage, - Optional filterOpsHttpMethod, - Optional filterOpsHttpUri, - Optional sortOpsSortBy, - Optional sortOpsOrderBy, - Optional afterOpsTimestamp, - Optional afterOpsChangeId, - Optional limit, - Optional offset, - Map additionalProperties) { - this.filterOpsContextChangeId = filterOpsContextChangeId; - this.filterOpsContextRequestId = filterOpsContextRequestId; - this.filterOpsContextTraceId = filterOpsContextTraceId; - this.filterOpsContextSessionId = filterOpsContextSessionId; - this.filterOpsContextActor = filterOpsContextActor; - this.filterOpsContextActorType = filterOpsContextActorType; - this.filterOpsContextAccessType = filterOpsContextAccessType; - this.filterOpsContextIpAddress = filterOpsContextIpAddress; - this.filterOpsContextOrigin = filterOpsContextOrigin; - this.filterOpsContextAuthMode = filterOpsContextAuthMode; - this.filterOpsContextJwtId = filterOpsContextJwtId; - this.filterOpsContextBearerTokenContextId = filterOpsContextBearerTokenContextId; - this.filterOpsParentAccountId = filterOpsParentAccountId; - this.filterOpsAccountId = filterOpsAccountId; - this.filterOpsWorkspaceId = filterOpsWorkspaceId; - this.filterOpsVaultId = filterOpsVaultId; - this.filterOpsResourceIDs = filterOpsResourceIDs; - this.filterOpsActionType = filterOpsActionType; - this.filterOpsResourceType = filterOpsResourceType; - this.filterOpsTags = filterOpsTags; - this.filterOpsResponseCode = filterOpsResponseCode; - this.filterOpsStartTime = filterOpsStartTime; - this.filterOpsEndTime = filterOpsEndTime; - this.filterOpsApiName = filterOpsApiName; - this.filterOpsResponseMessage = filterOpsResponseMessage; - this.filterOpsHttpMethod = filterOpsHttpMethod; - this.filterOpsHttpUri = filterOpsHttpUri; - this.sortOpsSortBy = sortOpsSortBy; - this.sortOpsOrderBy = sortOpsOrderBy; - this.afterOpsTimestamp = afterOpsTimestamp; - this.afterOpsChangeId = afterOpsChangeId; - this.limit = limit; - this.offset = offset; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID for the audit event. - */ - @JsonProperty("filterOps.context.changeID") - public Optional getFilterOpsContextChangeId() { - return filterOpsContextChangeId; - } - - /** - * @return ID for the request that caused the event. - */ - @JsonProperty("filterOps.context.requestID") - public Optional getFilterOpsContextRequestId() { - return filterOpsContextRequestId; - } - - /** - * @return ID for the request set by the service that received the request. - */ - @JsonProperty("filterOps.context.traceID") - public Optional getFilterOpsContextTraceId() { - return filterOpsContextTraceId; - } - - /** - * @return ID for the session in which the request was sent. - */ - @JsonProperty("filterOps.context.sessionID") - public Optional getFilterOpsContextSessionId() { - return filterOpsContextSessionId; - } - - /** - * @return Member who sent the request. Depending on actorType, this may be a user ID or a service account ID. - */ - @JsonProperty("filterOps.context.actor") - public Optional getFilterOpsContextActor() { - return filterOpsContextActor; - } - - /** - * @return Type of member who sent the request. - */ - @JsonProperty("filterOps.context.actorType") - public Optional getFilterOpsContextActorType() { - return filterOpsContextActorType; - } - - /** - * @return Type of access for the request. - */ - @JsonProperty("filterOps.context.accessType") - public Optional getFilterOpsContextAccessType() { - return filterOpsContextAccessType; - } - - /** - * @return IP Address of the client that made the request. - */ - @JsonProperty("filterOps.context.ipAddress") - public Optional getFilterOpsContextIpAddress() { - return filterOpsContextIpAddress; - } - - /** - * @return HTTP Origin request header (including scheme, hostname, and port) of the request. - */ - @JsonProperty("filterOps.context.origin") - public Optional getFilterOpsContextOrigin() { - return filterOpsContextOrigin; - } - - /** - * @return Authentication mode the actor used. - */ - @JsonProperty("filterOps.context.authMode") - public Optional getFilterOpsContextAuthMode() { - return filterOpsContextAuthMode; - } - - /** - * @return ID of the JWT token. - */ - @JsonProperty("filterOps.context.jwtID") - public Optional getFilterOpsContextJwtId() { - return filterOpsContextJwtId; - } - - /** - * @return Embedded User Context. - */ - @JsonProperty("filterOps.context.bearerTokenContextID") - public Optional getFilterOpsContextBearerTokenContextId() { - return filterOpsContextBearerTokenContextId; - } - - /** - * @return Resources with the specified parent account ID. - */ - @JsonProperty("filterOps.parentAccountID") - public Optional getFilterOpsParentAccountId() { - return filterOpsParentAccountId; - } - - /** - * @return Resources with the specified account ID. - */ - @JsonProperty("filterOps.accountID") - public String getFilterOpsAccountId() { - return filterOpsAccountId; - } - - /** - * @return Resources with the specified workspace ID. - */ - @JsonProperty("filterOps.workspaceID") - public Optional getFilterOpsWorkspaceId() { - return filterOpsWorkspaceId; - } - - /** - * @return Resources with the specified vault ID. - */ - @JsonProperty("filterOps.vaultID") - public Optional getFilterOpsVaultId() { - return filterOpsVaultId; - } - - /** - * @return Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890". - */ - @JsonProperty("filterOps.resourceIDs") - public Optional getFilterOpsResourceIDs() { - return filterOpsResourceIDs; - } - - /** - * @return Events with the specified action type. - */ - @JsonProperty("filterOps.actionType") - public Optional getFilterOpsActionType() { - return filterOpsActionType; - } - - /** - * @return Resources with the specified type. - */ - @JsonProperty("filterOps.resourceType") - public Optional getFilterOpsResourceType() { - return filterOpsResourceType; - } - - /** - * @return Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get". - */ - @JsonProperty("filterOps.tags") - public Optional getFilterOpsTags() { - return filterOpsTags; - } - - /** - * @return HTTP response code of the request. - */ - @JsonProperty("filterOps.responseCode") - public Optional getFilterOpsResponseCode() { - return filterOpsResponseCode; - } - - /** - * @return Start timestamp for the query, in SQL format. - */ - @JsonProperty("filterOps.startTime") - public Optional getFilterOpsStartTime() { - return filterOpsStartTime; - } - - /** - * @return End timestamp for the query, in SQL format. - */ - @JsonProperty("filterOps.endTime") - public Optional getFilterOpsEndTime() { - return filterOpsEndTime; - } - - /** - * @return Name of the API called in the request. - */ - @JsonProperty("filterOps.apiName") - public Optional getFilterOpsApiName() { - return filterOpsApiName; - } - - /** - * @return Response message of the request. - */ - @JsonProperty("filterOps.responseMessage") - public Optional getFilterOpsResponseMessage() { - return filterOpsResponseMessage; - } - - /** - * @return HTTP method of the request. - */ - @JsonProperty("filterOps.httpMethod") - public Optional getFilterOpsHttpMethod() { - return filterOpsHttpMethod; - } - - /** - * @return HTTP URI of the request. - */ - @JsonProperty("filterOps.httpURI") - public Optional getFilterOpsHttpUri() { - return filterOpsHttpUri; - } - - /** - * @return Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase"). - */ - @JsonProperty("sortOps.sortBy") - public Optional getSortOpsSortBy() { - return sortOpsSortBy; - } - - /** - * @return Ascending or descending ordering of results. - */ - @JsonProperty("sortOps.orderBy") - public Optional getSortOpsOrderBy() { - return sortOpsOrderBy; - } - - /** - * @return Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. - */ - @JsonProperty("afterOps.timestamp") - public Optional getAfterOpsTimestamp() { - return afterOpsTimestamp; - } - - /** - * @return Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. - */ - @JsonProperty("afterOps.changeID") - public Optional getAfterOpsChangeId() { - return afterOpsChangeId; - } - - /** - * @return Number of results to return. - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return Record position at which to start returning results. - */ - @JsonProperty("offset") - public Optional getOffset() { - return offset; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditServiceListAuditEventsRequest - && equalTo((AuditServiceListAuditEventsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AuditServiceListAuditEventsRequest other) { - return filterOpsContextChangeId.equals(other.filterOpsContextChangeId) - && filterOpsContextRequestId.equals(other.filterOpsContextRequestId) - && filterOpsContextTraceId.equals(other.filterOpsContextTraceId) - && filterOpsContextSessionId.equals(other.filterOpsContextSessionId) - && filterOpsContextActor.equals(other.filterOpsContextActor) - && filterOpsContextActorType.equals(other.filterOpsContextActorType) - && filterOpsContextAccessType.equals(other.filterOpsContextAccessType) - && filterOpsContextIpAddress.equals(other.filterOpsContextIpAddress) - && filterOpsContextOrigin.equals(other.filterOpsContextOrigin) - && filterOpsContextAuthMode.equals(other.filterOpsContextAuthMode) - && filterOpsContextJwtId.equals(other.filterOpsContextJwtId) - && filterOpsContextBearerTokenContextId.equals(other.filterOpsContextBearerTokenContextId) - && filterOpsParentAccountId.equals(other.filterOpsParentAccountId) - && filterOpsAccountId.equals(other.filterOpsAccountId) - && filterOpsWorkspaceId.equals(other.filterOpsWorkspaceId) - && filterOpsVaultId.equals(other.filterOpsVaultId) - && filterOpsResourceIDs.equals(other.filterOpsResourceIDs) - && filterOpsActionType.equals(other.filterOpsActionType) - && filterOpsResourceType.equals(other.filterOpsResourceType) - && filterOpsTags.equals(other.filterOpsTags) - && filterOpsResponseCode.equals(other.filterOpsResponseCode) - && filterOpsStartTime.equals(other.filterOpsStartTime) - && filterOpsEndTime.equals(other.filterOpsEndTime) - && filterOpsApiName.equals(other.filterOpsApiName) - && filterOpsResponseMessage.equals(other.filterOpsResponseMessage) - && filterOpsHttpMethod.equals(other.filterOpsHttpMethod) - && filterOpsHttpUri.equals(other.filterOpsHttpUri) - && sortOpsSortBy.equals(other.sortOpsSortBy) - && sortOpsOrderBy.equals(other.sortOpsOrderBy) - && afterOpsTimestamp.equals(other.afterOpsTimestamp) - && afterOpsChangeId.equals(other.afterOpsChangeId) - && limit.equals(other.limit) - && offset.equals(other.offset); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.filterOpsContextChangeId, - this.filterOpsContextRequestId, - this.filterOpsContextTraceId, - this.filterOpsContextSessionId, - this.filterOpsContextActor, - this.filterOpsContextActorType, - this.filterOpsContextAccessType, - this.filterOpsContextIpAddress, - this.filterOpsContextOrigin, - this.filterOpsContextAuthMode, - this.filterOpsContextJwtId, - this.filterOpsContextBearerTokenContextId, - this.filterOpsParentAccountId, - this.filterOpsAccountId, - this.filterOpsWorkspaceId, - this.filterOpsVaultId, - this.filterOpsResourceIDs, - this.filterOpsActionType, - this.filterOpsResourceType, - this.filterOpsTags, - this.filterOpsResponseCode, - this.filterOpsStartTime, - this.filterOpsEndTime, - this.filterOpsApiName, - this.filterOpsResponseMessage, - this.filterOpsHttpMethod, - this.filterOpsHttpUri, - this.sortOpsSortBy, - this.sortOpsOrderBy, - this.afterOpsTimestamp, - this.afterOpsChangeId, - this.limit, - this.offset); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static FilterOpsAccountIdStage builder() { - return new Builder(); - } - - public interface FilterOpsAccountIdStage { - /** - * Resources with the specified account ID. - */ - _FinalStage filterOpsAccountId(@NotNull String filterOpsAccountId); - - Builder from(AuditServiceListAuditEventsRequest other); - } - - public interface _FinalStage { - AuditServiceListAuditEventsRequest build(); - - /** - *

ID for the audit event.

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

ID for the request that caused the event.

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

ID for the request set by the service that received the request.

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

ID for the session in which the request was sent.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

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

Type of member who sent the request.

- */ - _FinalStage filterOpsContextActorType( - Optional filterOpsContextActorType); - - _FinalStage filterOpsContextActorType( - AuditServiceListAuditEventsRequestFilterOpsContextActorType filterOpsContextActorType); - - /** - *

Type of access for the request.

- */ - _FinalStage filterOpsContextAccessType( - Optional filterOpsContextAccessType); - - _FinalStage filterOpsContextAccessType( - AuditServiceListAuditEventsRequestFilterOpsContextAccessType filterOpsContextAccessType); - - /** - *

IP Address of the client that made the request.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

Authentication mode the actor used.

- */ - _FinalStage filterOpsContextAuthMode( - Optional filterOpsContextAuthMode); - - _FinalStage filterOpsContextAuthMode( - AuditServiceListAuditEventsRequestFilterOpsContextAuthMode filterOpsContextAuthMode); - - /** - *

ID of the JWT token.

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

Embedded User Context.

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

Resources with the specified parent account ID.

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

Resources with the specified workspace ID.

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

Resources with the specified vault ID.

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

Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890".

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

Events with the specified action type.

- */ - _FinalStage filterOpsActionType( - Optional filterOpsActionType); - - _FinalStage filterOpsActionType(AuditServiceListAuditEventsRequestFilterOpsActionType filterOpsActionType); - - /** - *

Resources with the specified type.

- */ - _FinalStage filterOpsResourceType( - Optional filterOpsResourceType); - - _FinalStage filterOpsResourceType( - AuditServiceListAuditEventsRequestFilterOpsResourceType filterOpsResourceType); - - /** - *

Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get".

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

HTTP response code of the request.

- */ - _FinalStage filterOpsResponseCode(Optional filterOpsResponseCode); - - _FinalStage filterOpsResponseCode(Integer filterOpsResponseCode); - - /** - *

Start timestamp for the query, in SQL format.

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

End timestamp for the query, in SQL format.

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

Name of the API called in the request.

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

Response message of the request.

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

HTTP method of the request.

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

HTTP URI of the request.

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

Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase").

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

Ascending or descending ordering of results.

- */ - _FinalStage sortOpsOrderBy(Optional sortOpsOrderBy); - - _FinalStage sortOpsOrderBy(AuditServiceListAuditEventsRequestSortOpsOrderBy sortOpsOrderBy); - - /** - *

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Number of results to return.

- */ - _FinalStage limit(Optional limit); - - _FinalStage limit(Long limit); - - /** - *

Record position at which to start returning results.

- */ - _FinalStage offset(Optional offset); - - _FinalStage offset(Long offset); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements FilterOpsAccountIdStage, _FinalStage { - private String filterOpsAccountId; - - private Optional offset = Optional.empty(); - - private Optional limit = Optional.empty(); - - private Optional afterOpsChangeId = Optional.empty(); - - private Optional afterOpsTimestamp = Optional.empty(); - - private Optional sortOpsOrderBy = Optional.empty(); - - private Optional sortOpsSortBy = Optional.empty(); - - private Optional filterOpsHttpUri = Optional.empty(); - - private Optional filterOpsHttpMethod = Optional.empty(); - - private Optional filterOpsResponseMessage = Optional.empty(); - - private Optional filterOpsApiName = Optional.empty(); - - private Optional filterOpsEndTime = Optional.empty(); - - private Optional filterOpsStartTime = Optional.empty(); - - private Optional filterOpsResponseCode = Optional.empty(); - - private Optional filterOpsTags = Optional.empty(); - - private Optional filterOpsResourceType = - Optional.empty(); - - private Optional filterOpsActionType = Optional.empty(); - - private Optional filterOpsResourceIDs = Optional.empty(); - - private Optional filterOpsVaultId = Optional.empty(); - - private Optional filterOpsWorkspaceId = Optional.empty(); - - private Optional filterOpsParentAccountId = Optional.empty(); - - private Optional filterOpsContextBearerTokenContextId = Optional.empty(); - - private Optional filterOpsContextJwtId = Optional.empty(); - - private Optional filterOpsContextAuthMode = - Optional.empty(); - - private Optional filterOpsContextOrigin = Optional.empty(); - - private Optional filterOpsContextIpAddress = Optional.empty(); - - private Optional filterOpsContextAccessType = - Optional.empty(); - - private Optional filterOpsContextActorType = - Optional.empty(); - - private Optional filterOpsContextActor = Optional.empty(); - - private Optional filterOpsContextSessionId = Optional.empty(); - - private Optional filterOpsContextTraceId = Optional.empty(); - - private Optional filterOpsContextRequestId = Optional.empty(); - - private Optional filterOpsContextChangeId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AuditServiceListAuditEventsRequest other) { - filterOpsContextChangeId(other.getFilterOpsContextChangeId()); - filterOpsContextRequestId(other.getFilterOpsContextRequestId()); - filterOpsContextTraceId(other.getFilterOpsContextTraceId()); - filterOpsContextSessionId(other.getFilterOpsContextSessionId()); - filterOpsContextActor(other.getFilterOpsContextActor()); - filterOpsContextActorType(other.getFilterOpsContextActorType()); - filterOpsContextAccessType(other.getFilterOpsContextAccessType()); - filterOpsContextIpAddress(other.getFilterOpsContextIpAddress()); - filterOpsContextOrigin(other.getFilterOpsContextOrigin()); - filterOpsContextAuthMode(other.getFilterOpsContextAuthMode()); - filterOpsContextJwtId(other.getFilterOpsContextJwtId()); - filterOpsContextBearerTokenContextId(other.getFilterOpsContextBearerTokenContextId()); - filterOpsParentAccountId(other.getFilterOpsParentAccountId()); - filterOpsAccountId(other.getFilterOpsAccountId()); - filterOpsWorkspaceId(other.getFilterOpsWorkspaceId()); - filterOpsVaultId(other.getFilterOpsVaultId()); - filterOpsResourceIDs(other.getFilterOpsResourceIDs()); - filterOpsActionType(other.getFilterOpsActionType()); - filterOpsResourceType(other.getFilterOpsResourceType()); - filterOpsTags(other.getFilterOpsTags()); - filterOpsResponseCode(other.getFilterOpsResponseCode()); - filterOpsStartTime(other.getFilterOpsStartTime()); - filterOpsEndTime(other.getFilterOpsEndTime()); - filterOpsApiName(other.getFilterOpsApiName()); - filterOpsResponseMessage(other.getFilterOpsResponseMessage()); - filterOpsHttpMethod(other.getFilterOpsHttpMethod()); - filterOpsHttpUri(other.getFilterOpsHttpUri()); - sortOpsSortBy(other.getSortOpsSortBy()); - sortOpsOrderBy(other.getSortOpsOrderBy()); - afterOpsTimestamp(other.getAfterOpsTimestamp()); - afterOpsChangeId(other.getAfterOpsChangeId()); - limit(other.getLimit()); - offset(other.getOffset()); - return this; - } - - /** - * Resources with the specified account ID.

Resources with the specified account ID.

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

Record position at which to start returning results.

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

Record position at which to start returning results.

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

Number of results to return.

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

Number of results to return.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Ascending or descending ordering of results.

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

Ascending or descending ordering of results.

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

Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase").

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

Fully-qualified field by which to sort results. Field names should be in camel case (for example, "capitalization.camelCase").

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

HTTP URI of the request.

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

HTTP URI of the request.

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

HTTP method of the request.

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

HTTP method of the request.

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

Response message of the request.

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

Response message of the request.

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

Name of the API called in the request.

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

Name of the API called in the request.

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

End timestamp for the query, in SQL format.

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

End timestamp for the query, in SQL format.

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

Start timestamp for the query, in SQL format.

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

Start timestamp for the query, in SQL format.

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

HTTP response code of the request.

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

HTTP response code of the request.

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

Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get".

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

Events with associated tags. If an event matches at least one tag, the event is returned. Comma-separated list. For example, "login, get".

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

Resources with the specified type.

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

Resources with the specified type.

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

Events with the specified action type.

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

Events with the specified action type.

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

Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890".

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

Resources with a specified ID. If a resource matches at least one ID, the associated event is returned. Format is a comma-separated list of "<resourceType>/<resourceID>". For example, "VAULT/12345, USER/67890".

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

Resources with the specified vault ID.

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

Resources with the specified vault ID.

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

Resources with the specified workspace ID.

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

Resources with the specified workspace ID.

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

Resources with the specified parent account ID.

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

Resources with the specified parent account ID.

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

Embedded User Context.

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

Embedded User Context.

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

ID of the JWT token.

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

ID of the JWT token.

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

Authentication mode the actor used.

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

Authentication mode the actor used.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

IP Address of the client that made the request.

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

IP Address of the client that made the request.

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

Type of access for the request.

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

Type of access for the request.

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

Type of member who sent the request.

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

Type of member who sent the request.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

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

ID for the session in which the request was sent.

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

ID for the session in which the request was sent.

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

ID for the request set by the service that received the request.

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

ID for the request set by the service that received the request.

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

ID for the request that caused the event.

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

ID for the request that caused the event.

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

ID for the audit event.

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

ID for the audit event.

- */ - @java.lang.Override - @JsonSetter(value = "filterOps.context.changeID", nulls = Nulls.SKIP) - public _FinalStage filterOpsContextChangeId(Optional filterOpsContextChangeId) { - this.filterOpsContextChangeId = filterOpsContextChangeId; - return this; - } - - @java.lang.Override - public AuditServiceListAuditEventsRequest build() { - return new AuditServiceListAuditEventsRequest( - filterOpsContextChangeId, - filterOpsContextRequestId, - filterOpsContextTraceId, - filterOpsContextSessionId, - filterOpsContextActor, - filterOpsContextActorType, - filterOpsContextAccessType, - filterOpsContextIpAddress, - filterOpsContextOrigin, - filterOpsContextAuthMode, - filterOpsContextJwtId, - filterOpsContextBearerTokenContextId, - filterOpsParentAccountId, - filterOpsAccountId, - filterOpsWorkspaceId, - filterOpsVaultId, - filterOpsResourceIDs, - filterOpsActionType, - filterOpsResourceType, - filterOpsTags, - filterOpsResponseCode, - filterOpsStartTime, - filterOpsEndTime, - filterOpsApiName, - filterOpsResponseMessage, - filterOpsHttpMethod, - filterOpsHttpUri, - sortOpsSortBy, - sortOpsOrderBy, - afterOpsTimestamp, - afterOpsChangeId, - limit, - offset, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java b/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java deleted file mode 100644 index a9fb6d44..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsActionType.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuditServiceListAuditEventsRequestFilterOpsActionType { - NONE("NONE"), - - ASSIGN("ASSIGN"), - - CREATE("CREATE"), - - DELETE("DELETE"), - - EXECUTE("EXECUTE"), - - LIST("LIST"), - - READ("READ"), - - UNASSIGN("UNASSIGN"), - - UPDATE("UPDATE"), - - VALIDATE("VALIDATE"), - - LOGIN("LOGIN"), - - ROTATE("ROTATE"), - - SCHEDULEROTATION("SCHEDULEROTATION"), - - SCHEDULEROTATIONALERT("SCHEDULEROTATIONALERT"), - - IMPORT("IMPORT"), - - GETIMPORTPARAMETERS("GETIMPORTPARAMETERS"), - - PING("PING"), - - GETCLOUDPROVIDER("GETCLOUDPROVIDER"); - - private final String value; - - AuditServiceListAuditEventsRequestFilterOpsActionType(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/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java b/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java deleted file mode 100644 index 0b082305..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAccessType.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuditServiceListAuditEventsRequestFilterOpsContextAccessType { - ACCESS_NONE("ACCESS_NONE"), - - API("API"), - - SQL("SQL"), - - OKTA_LOGIN("OKTA_LOGIN"); - - private final String value; - - AuditServiceListAuditEventsRequestFilterOpsContextAccessType(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/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java b/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java deleted file mode 100644 index 76a357f4..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextActorType.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuditServiceListAuditEventsRequestFilterOpsContextActorType { - NONE("NONE"), - - USER("USER"), - - SERVICE_ACCOUNT("SERVICE_ACCOUNT"); - - private final String value; - - AuditServiceListAuditEventsRequestFilterOpsContextActorType(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/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java b/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java deleted file mode 100644 index cfca2e35..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsContextAuthMode.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuditServiceListAuditEventsRequestFilterOpsContextAuthMode { - AUTH_NONE("AUTH_NONE"), - - OKTA_JWT("OKTA_JWT"), - - SERVICE_ACCOUNT_JWT("SERVICE_ACCOUNT_JWT"), - - PAT_JWT("PAT_JWT"); - - private final String value; - - AuditServiceListAuditEventsRequestFilterOpsContextAuthMode(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/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java b/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java deleted file mode 100644 index f5d2eafe..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestFilterOpsResourceType.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuditServiceListAuditEventsRequestFilterOpsResourceType { - NONE_API("NONE_API"), - - ACCOUNT("ACCOUNT"), - - AUDIT("AUDIT"), - - BASE_DATA_TYPE("BASE_DATA_TYPE"), - - FIELD_TEMPLATE("FIELD_TEMPLATE"), - - FILE("FILE"), - - KEY("KEY"), - - POLICY("POLICY"), - - PROTO_PARSE("PROTO_PARSE"), - - RECORD("RECORD"), - - ROLE("ROLE"), - - RULE("RULE"), - - SECRET("SECRET"), - - SERVICE_ACCOUNT("SERVICE_ACCOUNT"), - - TOKEN("TOKEN"), - - USER("USER"), - - VAULT("VAULT"), - - VAULT_TEMPLATE("VAULT_TEMPLATE"), - - WORKSPACE("WORKSPACE"), - - TABLE("TABLE"), - - POLICY_TEMPLATE("POLICY_TEMPLATE"), - - MEMBER("MEMBER"), - - TAG("TAG"), - - CONNECTION("CONNECTION"), - - MIGRATION("MIGRATION"), - - SCHEDULED_JOB("SCHEDULED_JOB"), - - JOB("JOB"), - - COLUMN_NAME("COLUMN_NAME"), - - NETWORK_TOKEN("NETWORK_TOKEN"), - - SUBSCRIPTION("SUBSCRIPTION"); - - private final String value; - - AuditServiceListAuditEventsRequestFilterOpsResourceType(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/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java b/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java deleted file mode 100644 index 51fc2715..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/audit/types/AuditServiceListAuditEventsRequestSortOpsOrderBy.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.audit.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuditServiceListAuditEventsRequestSortOpsOrderBy { - ASCENDING("ASCENDING"), - - DESCENDING("DESCENDING"); - - private final String value; - - AuditServiceListAuditEventsRequestSortOpsOrderBy(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/resources/binlookup/AsyncBinLookupClient.java b/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java deleted file mode 100644 index f10ed979..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncBinLookupClient.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.binlookup; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; -import com.skyflow.generated.rest.types.V1BinListResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncBinLookupClient { - protected final ClientOptions clientOptions; - - private final AsyncRawBinLookupClient rawClient; - - public AsyncBinLookupClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawBinLookupClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawBinLookupClient withRawResponse() { - return this.rawClient; - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public CompletableFuture binListServiceListCardsOfBin() { - return this.rawClient.binListServiceListCardsOfBin().thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public CompletableFuture binListServiceListCardsOfBin(V1BinListRequest request) { - return this.rawClient.binListServiceListCardsOfBin(request).thenApply(response -> response.body()); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public CompletableFuture binListServiceListCardsOfBin( - V1BinListRequest request, RequestOptions requestOptions) { - return this.rawClient - .binListServiceListCardsOfBin(request, requestOptions) - .thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java b/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java deleted file mode 100644 index 2a3f5f4f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/binlookup/AsyncRawBinLookupClient.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.binlookup; - -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.NotFoundError; -import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; -import com.skyflow.generated.rest.types.V1BinListResponse; -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 AsyncRawBinLookupClient { - protected final ClientOptions clientOptions; - - public AsyncRawBinLookupClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public CompletableFuture> binListServiceListCardsOfBin() { - return binListServiceListCardsOfBin(V1BinListRequest.builder().build()); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public CompletableFuture> binListServiceListCardsOfBin( - V1BinListRequest request) { - return binListServiceListCardsOfBin(request, null); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public CompletableFuture> binListServiceListCardsOfBin( - V1BinListRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/card_lookup") - .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(), V1BinListResponse.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/binlookup/BinLookupClient.java b/src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java deleted file mode 100644 index a7822986..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/binlookup/BinLookupClient.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.binlookup; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; -import com.skyflow.generated.rest.types.V1BinListResponse; - -public class BinLookupClient { - protected final ClientOptions clientOptions; - - private final RawBinLookupClient rawClient; - - public BinLookupClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawBinLookupClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawBinLookupClient withRawResponse() { - return this.rawClient; - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public V1BinListResponse binListServiceListCardsOfBin() { - return this.rawClient.binListServiceListCardsOfBin().body(); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public V1BinListResponse binListServiceListCardsOfBin(V1BinListRequest request) { - return this.rawClient.binListServiceListCardsOfBin(request).body(); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public V1BinListResponse binListServiceListCardsOfBin(V1BinListRequest request, RequestOptions requestOptions) { - return this.rawClient - .binListServiceListCardsOfBin(request, requestOptions) - .body(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java b/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java deleted file mode 100644 index bb08039b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/binlookup/RawBinLookupClient.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.binlookup; - -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.NotFoundError; -import com.skyflow.generated.rest.resources.binlookup.requests.V1BinListRequest; -import com.skyflow.generated.rest.types.V1BinListResponse; -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 RawBinLookupClient { - protected final ClientOptions clientOptions; - - public RawBinLookupClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public ApiClientHttpResponse binListServiceListCardsOfBin() { - return binListServiceListCardsOfBin(V1BinListRequest.builder().build()); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public ApiClientHttpResponse binListServiceListCardsOfBin(V1BinListRequest request) { - return binListServiceListCardsOfBin(request, null); - } - - /** - * <b>Note</b>: This endpoint is in beta and subject to change. <br><br> Returns the specified card metadata. - */ - public ApiClientHttpResponse binListServiceListCardsOfBin( - V1BinListRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/card_lookup") - .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(), V1BinListResponse.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/binlookup/requests/V1BinListRequest.java b/src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java deleted file mode 100644 index d4a1c21b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/binlookup/requests/V1BinListRequest.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.binlookup.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.V1VaultSchemaConfig; -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 = V1BinListRequest.Builder.class) -public final class V1BinListRequest { - private final Optional> fields; - - private final Optional bin; - - private final Optional vaultSchemaConfig; - - private final Optional skyflowId; - - private final Map additionalProperties; - - private V1BinListRequest( - Optional> fields, - Optional bin, - Optional vaultSchemaConfig, - Optional skyflowId, - Map additionalProperties) { - this.fields = fields; - this.bin = bin; - this.vaultSchemaConfig = vaultSchemaConfig; - this.skyflowId = skyflowId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Fields to return. If not specified, all fields are returned. - */ - @JsonProperty("fields") - public Optional> getFields() { - return fields; - } - - /** - * @return BIN of the card. - */ - @JsonProperty("BIN") - public Optional getBin() { - return bin; - } - - @JsonProperty("vault_schema_config") - public Optional getVaultSchemaConfig() { - return vaultSchemaConfig; - } - - /** - * @return <code>skyflow_id</code> of the record. - */ - @JsonProperty("skyflow_id") - public Optional getSkyflowId() { - return skyflowId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1BinListRequest && equalTo((V1BinListRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1BinListRequest other) { - return fields.equals(other.fields) - && bin.equals(other.bin) - && vaultSchemaConfig.equals(other.vaultSchemaConfig) - && skyflowId.equals(other.skyflowId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.fields, this.bin, this.vaultSchemaConfig, this.skyflowId); - } - - @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> fields = Optional.empty(); - - private Optional bin = Optional.empty(); - - private Optional vaultSchemaConfig = Optional.empty(); - - private Optional skyflowId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1BinListRequest other) { - fields(other.getFields()); - bin(other.getBin()); - vaultSchemaConfig(other.getVaultSchemaConfig()); - skyflowId(other.getSkyflowId()); - return this; - } - - /** - *

Fields to return. If not specified, all fields are returned.

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

BIN of the card.

- */ - @JsonSetter(value = "BIN", nulls = Nulls.SKIP) - public Builder bin(Optional bin) { - this.bin = bin; - return this; - } - - public Builder bin(String bin) { - this.bin = Optional.ofNullable(bin); - return this; - } - - @JsonSetter(value = "vault_schema_config", nulls = Nulls.SKIP) - public Builder vaultSchemaConfig(Optional vaultSchemaConfig) { - this.vaultSchemaConfig = vaultSchemaConfig; - return this; - } - - public Builder vaultSchemaConfig(V1VaultSchemaConfig vaultSchemaConfig) { - this.vaultSchemaConfig = Optional.ofNullable(vaultSchemaConfig); - return this; - } - - /** - *

<code>skyflow_id</code> of the record.

- */ - @JsonSetter(value = "skyflow_id", 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; - } - - public V1BinListRequest build() { - return new V1BinListRequest(fields, bin, vaultSchemaConfig, skyflowId, additionalProperties); - } - } -} 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 deleted file mode 100644 index 48692d9f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/AsyncFilesClient.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyAudioRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; -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.types.DeidentifyFileResponse; -import com.skyflow.generated.rest.types.DeidentifyStatusResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncFilesClient { - protected final ClientOptions clientOptions; - - private final AsyncRawFilesClient rawClient; - - public AsyncFilesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawFilesClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawFilesClient withRawResponse() { - return this.rawClient; - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public CompletableFuture deidentifyFile(DeidentifyFileRequest request) { - return this.rawClient.deidentifyFile(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public CompletableFuture deidentifyFile( - DeidentifyFileRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyFile(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyDocument(DeidentifyDocumentRequest request) { - return this.rawClient.deidentifyDocument(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyDocument( - DeidentifyDocumentRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyDocument(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyPdf(DeidentifyPdfRequest request) { - return this.rawClient.deidentifyPdf(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyPdf( - DeidentifyPdfRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyPdf(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyImage(DeidentifyImageRequest request) { - return this.rawClient.deidentifyImage(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyImage( - DeidentifyImageRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyImage(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyText(DeidentifyTextRequest request) { - return this.rawClient.deidentifyText(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyText( - DeidentifyTextRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyText(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyStructuredText(DeidentifyStructuredTextRequest request) { - return this.rawClient.deidentifyStructuredText(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyStructuredText( - DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyStructuredText(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifySpreadsheet(DeidentifySpreadsheetRequest request) { - return this.rawClient.deidentifySpreadsheet(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifySpreadsheet( - DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifySpreadsheet(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyPresentation(DeidentifyPresentationRequest request) { - return this.rawClient.deidentifyPresentation(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyPresentation( - DeidentifyPresentationRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyPresentation(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyAudio(DeidentifyAudioRequest request) { - return this.rawClient.deidentifyAudio(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture deidentifyAudio( - DeidentifyAudioRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyAudio(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Returns the status of the detect run. - */ - public CompletableFuture getRun(String runId, GetRunRequest request) { - return this.rawClient.getRun(runId, request).thenApply(response -> response.body()); - } - - /** - * Returns the status of the detect run. - */ - public CompletableFuture getRun( - String runId, GetRunRequest request, RequestOptions requestOptions) { - return this.rawClient.getRun(runId, 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 deleted file mode 100644 index f400bb2a..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/AsyncRawFilesClient.java +++ /dev/null @@ -1,929 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files; - -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.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.files.requests.DeidentifyAudioRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; -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.types.DeidentifyFileResponse; -import com.skyflow.generated.rest.types.DeidentifyStatusResponse; -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 AsyncRawFilesClient { - protected final ClientOptions clientOptions; - - public AsyncRawFilesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public CompletableFuture> deidentifyFile( - DeidentifyFileRequest request) { - return deidentifyFile(request, null); - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public CompletableFuture> deidentifyFile( - DeidentifyFileRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyDocument( - DeidentifyDocumentRequest request) { - return deidentifyDocument(request, null); - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyDocument( - DeidentifyDocumentRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/document") - .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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyPdf( - DeidentifyPdfRequest request) { - return deidentifyPdf(request, null); - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyPdf( - DeidentifyPdfRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/document/pdf") - .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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyImage( - DeidentifyImageRequest request) { - return deidentifyImage(request, null); - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyImage( - DeidentifyImageRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/image") - .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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyText( - DeidentifyTextRequest request) { - return deidentifyText(request, null); - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyText( - DeidentifyTextRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyStructuredText( - DeidentifyStructuredTextRequest request) { - return deidentifyStructuredText(request, null); - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyStructuredText( - DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/structured_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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifySpreadsheet( - DeidentifySpreadsheetRequest request) { - return deidentifySpreadsheet(request, null); - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifySpreadsheet( - DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/spreadsheet") - .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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyPresentation( - DeidentifyPresentationRequest request) { - return deidentifyPresentation(request, null); - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyPresentation( - DeidentifyPresentationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/presentation") - .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(), DeidentifyFileResponse.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; - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyAudio( - DeidentifyAudioRequest request) { - return deidentifyAudio(request, null); - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public CompletableFuture> deidentifyAudio( - DeidentifyAudioRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/audio") - .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(), DeidentifyFileResponse.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; - } - - /** - * Returns the status of the detect run. - */ - public CompletableFuture> getRun( - String runId, GetRunRequest request) { - return getRun(runId, request, null); - } - - /** - * Returns the status of the detect run. - */ - public CompletableFuture> getRun( - String runId, GetRunRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/runs") - .addPathSegment(runId); - QueryStringMapper.addQueryParameter(httpUrl, "vault_id", request.getVaultId(), 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(), DeidentifyStatusResponse.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/files/FilesClient.java b/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java deleted file mode 100644 index 89898d41..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/FilesClient.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyAudioRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; -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.types.DeidentifyFileResponse; -import com.skyflow.generated.rest.types.DeidentifyStatusResponse; - -public class FilesClient { - protected final ClientOptions clientOptions; - - private final RawFilesClient rawClient; - - public FilesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawFilesClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawFilesClient withRawResponse() { - return this.rawClient; - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) { - return this.rawClient.deidentifyFile(request).body(); - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyFile(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyDocument(DeidentifyDocumentRequest request) { - return this.rawClient.deidentifyDocument(request).body(); - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyDocument(DeidentifyDocumentRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyDocument(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyPdf(DeidentifyPdfRequest request) { - return this.rawClient.deidentifyPdf(request).body(); - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyPdf(DeidentifyPdfRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyPdf(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyImage(DeidentifyImageRequest request) { - return this.rawClient.deidentifyImage(request).body(); - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyImage(DeidentifyImageRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyImage(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyText(DeidentifyTextRequest request) { - return this.rawClient.deidentifyText(request).body(); - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyText(DeidentifyTextRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyText(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyStructuredText(DeidentifyStructuredTextRequest request) { - return this.rawClient.deidentifyStructuredText(request).body(); - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyStructuredText( - DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyStructuredText(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifySpreadsheet(DeidentifySpreadsheetRequest request) { - return this.rawClient.deidentifySpreadsheet(request).body(); - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifySpreadsheet( - DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifySpreadsheet(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyPresentation(DeidentifyPresentationRequest request) { - return this.rawClient.deidentifyPresentation(request).body(); - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyPresentation( - DeidentifyPresentationRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyPresentation(request, requestOptions).body(); - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyAudio(DeidentifyAudioRequest request) { - return this.rawClient.deidentifyAudio(request).body(); - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public DeidentifyFileResponse deidentifyAudio(DeidentifyAudioRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyAudio(request, requestOptions).body(); - } - - /** - * Returns the status of the detect run. - */ - public DeidentifyStatusResponse getRun(String runId, GetRunRequest request) { - return this.rawClient.getRun(runId, request).body(); - } - - /** - * Returns the status of the detect run. - */ - public DeidentifyStatusResponse getRun(String runId, GetRunRequest request, RequestOptions requestOptions) { - return this.rawClient.getRun(runId, 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 deleted file mode 100644 index 85939625..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/RawFilesClient.java +++ /dev/null @@ -1,714 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files; - -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.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.files.requests.DeidentifyAudioRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyDocumentRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyImageRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPdfRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifyPresentationRequest; -import com.skyflow.generated.rest.resources.files.requests.DeidentifySpreadsheetRequest; -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.types.DeidentifyFileResponse; -import com.skyflow.generated.rest.types.DeidentifyStatusResponse; -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 RawFilesClient { - protected final ClientOptions clientOptions; - - public RawFilesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public ApiClientHttpResponse deidentifyFile(DeidentifyFileRequest request) { - return deidentifyFile(request, null); - } - - /** - * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.<br/><br/>For more specific options, see the category-specific operations (like <a href='#deidentify_document'>De-identify Document</a>) and the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>). - */ - public ApiClientHttpResponse deidentifyFile( - DeidentifyFileRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyDocument(DeidentifyDocumentRequest request) { - return deidentifyDocument(request, null); - } - - /** - * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.<br/><br/>For more specific options, see the file type-specific opertions (like <a href='#deidentify_pdf'>De-identify PDF</a>) where they're available. For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyDocument( - DeidentifyDocumentRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/document") - .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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyPdf(DeidentifyPdfRequest request) { - return deidentifyPdf(request, null); - } - - /** - * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.<br/><br/>For broader file type support, see <a href='#deidentify_document'>De-identify Document</a> and <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyPdf( - DeidentifyPdfRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/document/pdf") - .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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyImage(DeidentifyImageRequest request) { - return deidentifyImage(request, null); - } - - /** - * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyImage( - DeidentifyImageRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/image") - .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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyText(DeidentifyTextRequest request) { - return deidentifyText(request, null); - } - - /** - * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyText( - DeidentifyTextRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyStructuredText( - DeidentifyStructuredTextRequest request) { - return deidentifyStructuredText(request, null); - } - - /** - * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyStructuredText( - DeidentifyStructuredTextRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/structured_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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifySpreadsheet(DeidentifySpreadsheetRequest request) { - return deidentifySpreadsheet(request, null); - } - - /** - * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifySpreadsheet( - DeidentifySpreadsheetRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/spreadsheet") - .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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyPresentation(DeidentifyPresentationRequest request) { - return deidentifyPresentation(request, null); - } - - /** - * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyPresentation( - DeidentifyPresentationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/presentation") - .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(), DeidentifyFileResponse.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); - } - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyAudio(DeidentifyAudioRequest request) { - return deidentifyAudio(request, null); - } - - /** - * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.<br/><br/>For broader file type support, see <a href='#deidentify_file'>De-identify File</a>. - */ - public ApiClientHttpResponse deidentifyAudio( - DeidentifyAudioRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/file/audio") - .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(), DeidentifyFileResponse.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); - } - } - - /** - * Returns the status of the detect run. - */ - public ApiClientHttpResponse getRun(String runId, GetRunRequest request) { - return getRun(runId, request, null); - } - - /** - * Returns the status of the detect run. - */ - public ApiClientHttpResponse getRun( - String runId, GetRunRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/runs") - .addPathSegment(runId); - QueryStringMapper.addQueryParameter(httpUrl, "vault_id", request.getVaultId(), 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(), DeidentifyStatusResponse.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/files/requests/DeidentifyAudioRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java deleted file mode 100644 index 5f4929aa..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyAudioRequest.java +++ /dev/null @@ -1,582 +0,0 @@ -/** - * 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.DeidentifyAudioRequestFile; -import com.skyflow.generated.rest.resources.files.types.DeidentifyAudioRequestOutputTranscription; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyAudioRequest.Builder.class) -public final class DeidentifyAudioRequest { - private final String vaultId; - - private final DeidentifyAudioRequestFile file; - - private final Optional outputProcessedAudio; - - private final Optional outputTranscription; - - private final Optional bleepGain; - - private final Optional bleepFrequency; - - private final Optional bleepStartPadding; - - private final Optional bleepStopPadding; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyAudioRequest( - String vaultId, - DeidentifyAudioRequestFile file, - Optional outputProcessedAudio, - Optional outputTranscription, - Optional bleepGain, - Optional bleepFrequency, - Optional bleepStartPadding, - Optional bleepStopPadding, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.outputProcessedAudio = outputProcessedAudio; - this.outputTranscription = outputTranscription; - this.bleepGain = bleepGain; - this.bleepFrequency = bleepFrequency; - this.bleepStartPadding = bleepStartPadding; - this.bleepStopPadding = bleepStopPadding; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyAudioRequestFile getFile() { - return file; - } - - /** - * @return If true, includes processed audio file in the response. - */ - @JsonProperty("output_processed_audio") - public Optional getOutputProcessedAudio() { - return outputProcessedAudio; - } - - /** - * @return Type of transcription to output. - */ - @JsonProperty("output_transcription") - public Optional getOutputTranscription() { - return outputTranscription; - } - - /** - * @return Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it. - */ - @JsonProperty("bleep_gain") - public Optional getBleepGain() { - return bleepGain; - } - - /** - * @return The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch. - */ - @JsonProperty("bleep_frequency") - public Optional getBleepFrequency() { - return bleepFrequency; - } - - /** - * @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_stop_padding") - public Optional getBleepStopPadding() { - return bleepStopPadding; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyAudioRequest && equalTo((DeidentifyAudioRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyAudioRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && outputProcessedAudio.equals(other.outputProcessedAudio) - && outputTranscription.equals(other.outputTranscription) - && bleepGain.equals(other.bleepGain) - && bleepFrequency.equals(other.bleepFrequency) - && bleepStartPadding.equals(other.bleepStartPadding) - && bleepStopPadding.equals(other.bleepStopPadding) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.outputProcessedAudio, - this.outputTranscription, - this.bleepGain, - this.bleepFrequency, - this.bleepStartPadding, - this.bleepStopPadding, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyAudioRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyAudioRequestFile file); - } - - public interface _FinalStage { - DeidentifyAudioRequest build(); - - /** - *

If true, includes processed audio file in the response.

- */ - _FinalStage outputProcessedAudio(Optional outputProcessedAudio); - - _FinalStage outputProcessedAudio(Boolean outputProcessedAudio); - - /** - *

Type of transcription to output.

- */ - _FinalStage outputTranscription(Optional outputTranscription); - - _FinalStage outputTranscription(DeidentifyAudioRequestOutputTranscription outputTranscription); - - /** - *

Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it.

- */ - _FinalStage bleepGain(Optional bleepGain); - - _FinalStage bleepGain(Double bleepGain); - - /** - *

The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch.

- */ - _FinalStage bleepFrequency(Optional bleepFrequency); - - _FinalStage bleepFrequency(Double bleepFrequency); - - /** - *

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

- */ - _FinalStage bleepStartPadding(Optional bleepStartPadding); - - _FinalStage bleepStartPadding(Double bleepStartPadding); - - /** - *

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

- */ - _FinalStage bleepStopPadding(Optional bleepStopPadding); - - _FinalStage bleepStopPadding(Double bleepStopPadding); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyAudioRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - private Optional bleepStopPadding = Optional.empty(); - - private Optional bleepStartPadding = Optional.empty(); - - private Optional bleepFrequency = Optional.empty(); - - private Optional bleepGain = Optional.empty(); - - private Optional outputTranscription = Optional.empty(); - - private Optional outputProcessedAudio = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyAudioRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - outputProcessedAudio(other.getOutputProcessedAudio()); - outputTranscription(other.getOutputTranscription()); - bleepGain(other.getBleepGain()); - bleepFrequency(other.getBleepFrequency()); - bleepStartPadding(other.getBleepStartPadding()); - bleepStopPadding(other.getBleepStopPadding()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyAudioRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - /** - *

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

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

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

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

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

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

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

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

The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch.

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

The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch.

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

Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it.

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

Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it.

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

Type of transcription to output.

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

Type of transcription to output.

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

If true, includes processed audio file in the response.

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

If true, includes processed audio file in the response.

- */ - @java.lang.Override - @JsonSetter(value = "output_processed_audio", nulls = Nulls.SKIP) - public _FinalStage outputProcessedAudio(Optional outputProcessedAudio) { - this.outputProcessedAudio = outputProcessedAudio; - return this; - } - - @java.lang.Override - public DeidentifyAudioRequest build() { - return new DeidentifyAudioRequest( - vaultId, - file, - outputProcessedAudio, - outputTranscription, - bleepGain, - bleepFrequency, - bleepStartPadding, - bleepStopPadding, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index bf6f307e..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyDocumentRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * 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.DeidentifyDocumentRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyDocumentRequest.Builder.class) -public final class DeidentifyDocumentRequest { - private final String vaultId; - - private final DeidentifyDocumentRequestFile file; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyDocumentRequest( - String vaultId, - DeidentifyDocumentRequestFile file, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyDocumentRequestFile getFile() { - return file; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyDocumentRequest && equalTo((DeidentifyDocumentRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyDocumentRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyDocumentRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyDocumentRequestFile file); - } - - public interface _FinalStage { - DeidentifyDocumentRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyDocumentRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyDocumentRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyDocumentRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifyDocumentRequest build() { - return new DeidentifyDocumentRequest( - vaultId, - file, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index 1cbcd8f1..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyFileRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * 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.DeidentifyFileRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyFileRequest.Builder.class) -public final class DeidentifyFileRequest { - private final String vaultId; - - private final DeidentifyFileRequestFile file; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyFileRequest( - String vaultId, - DeidentifyFileRequestFile file, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyFileRequestFile getFile() { - return file; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyFileRequest && equalTo((DeidentifyFileRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyFileRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyFileRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyFileRequestFile file); - } - - public interface _FinalStage { - DeidentifyFileRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyFileRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyFileRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyFileRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifyFileRequest build() { - return new DeidentifyFileRequest( - vaultId, - file, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index 41de24b2..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyImageRequest.java +++ /dev/null @@ -1,446 +0,0 @@ -/** - * 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.DeidentifyImageRequestFile; -import com.skyflow.generated.rest.resources.files.types.DeidentifyImageRequestMaskingMethod; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyImageRequest.Builder.class) -public final class DeidentifyImageRequest { - private final String vaultId; - - private final DeidentifyImageRequestFile file; - - private final Optional outputProcessedImage; - - private final Optional outputOcrText; - - private final Optional maskingMethod; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyImageRequest( - String vaultId, - DeidentifyImageRequestFile file, - Optional outputProcessedImage, - Optional outputOcrText, - Optional maskingMethod, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.outputProcessedImage = outputProcessedImage; - this.outputOcrText = outputOcrText; - this.maskingMethod = maskingMethod; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyImageRequestFile getFile() { - return file; - } - - /** - * @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; - } - - /** - * @return Method to mask the entities in the image. - */ - @JsonProperty("masking_method") - public Optional getMaskingMethod() { - return maskingMethod; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyImageRequest && equalTo((DeidentifyImageRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyImageRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && outputProcessedImage.equals(other.outputProcessedImage) - && outputOcrText.equals(other.outputOcrText) - && maskingMethod.equals(other.maskingMethod) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.outputProcessedImage, - this.outputOcrText, - this.maskingMethod, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyImageRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyImageRequestFile file); - } - - public interface _FinalStage { - DeidentifyImageRequest build(); - - /** - *

If true, includes processed image in the output.

- */ - _FinalStage outputProcessedImage(Optional outputProcessedImage); - - _FinalStage outputProcessedImage(Boolean outputProcessedImage); - - /** - *

If true, includes OCR text output in the response.

- */ - _FinalStage outputOcrText(Optional outputOcrText); - - _FinalStage outputOcrText(Boolean outputOcrText); - - /** - *

Method to mask the entities in the image.

- */ - _FinalStage maskingMethod(Optional maskingMethod); - - _FinalStage maskingMethod(DeidentifyImageRequestMaskingMethod maskingMethod); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyImageRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - private Optional maskingMethod = Optional.empty(); - - private Optional outputOcrText = Optional.empty(); - - private Optional outputProcessedImage = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyImageRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - outputProcessedImage(other.getOutputProcessedImage()); - outputOcrText(other.getOutputOcrText()); - maskingMethod(other.getMaskingMethod()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyImageRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - /** - *

Method to mask the entities in the image.

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

Method to mask the entities in the image.

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

If true, includes OCR text output in the response.

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

If true, includes OCR text output in the response.

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

If true, includes processed image in the output.

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

If true, includes processed image in the output.

- */ - @java.lang.Override - @JsonSetter(value = "output_processed_image", nulls = Nulls.SKIP) - public _FinalStage outputProcessedImage(Optional outputProcessedImage) { - this.outputProcessedImage = outputProcessedImage; - return this; - } - - @java.lang.Override - public DeidentifyImageRequest build() { - return new DeidentifyImageRequest( - vaultId, - file, - outputProcessedImage, - outputOcrText, - maskingMethod, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index 83fbb14f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPdfRequest.java +++ /dev/null @@ -1,400 +0,0 @@ -/** - * 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.DeidentifyPdfRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyPdfRequest.Builder.class) -public final class DeidentifyPdfRequest { - private final String vaultId; - - private final DeidentifyPdfRequestFile file; - - private final Optional density; - - private final Optional maxResolution; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyPdfRequest( - String vaultId, - DeidentifyPdfRequestFile file, - Optional density, - Optional maxResolution, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.density = density; - this.maxResolution = maxResolution; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyPdfRequestFile getFile() { - return file; - } - - /** - * @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; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyPdfRequest && equalTo((DeidentifyPdfRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyPdfRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && density.equals(other.density) - && maxResolution.equals(other.maxResolution) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.density, - this.maxResolution, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyPdfRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyPdfRequestFile file); - } - - public interface _FinalStage { - DeidentifyPdfRequest build(); - - /** - *

Pixel density at which to process the PDF file.

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

Max resolution at which to process the PDF file.

- */ - _FinalStage maxResolution(Optional maxResolution); - - _FinalStage maxResolution(Integer maxResolution); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyPdfRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - private Optional maxResolution = Optional.empty(); - - private Optional density = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyPdfRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - density(other.getDensity()); - maxResolution(other.getMaxResolution()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyPdfRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - /** - *

Max resolution at which to process the PDF file.

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

Max resolution at which to process the PDF file.

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

Pixel density at which to process the PDF file.

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

Pixel density at which to process the PDF file.

- */ - @java.lang.Override - @JsonSetter(value = "density", nulls = Nulls.SKIP) - public _FinalStage density(Optional density) { - this.density = density; - return this; - } - - @java.lang.Override - public DeidentifyPdfRequest build() { - return new DeidentifyPdfRequest( - vaultId, - file, - density, - maxResolution, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index 47a63a5b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyPresentationRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * 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.DeidentifyPresentationRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyPresentationRequest.Builder.class) -public final class DeidentifyPresentationRequest { - private final String vaultId; - - private final DeidentifyPresentationRequestFile file; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyPresentationRequest( - String vaultId, - DeidentifyPresentationRequestFile file, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyPresentationRequestFile getFile() { - return file; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyPresentationRequest && equalTo((DeidentifyPresentationRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyPresentationRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyPresentationRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyPresentationRequestFile file); - } - - public interface _FinalStage { - DeidentifyPresentationRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyPresentationRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyPresentationRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyPresentationRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifyPresentationRequest build() { - return new DeidentifyPresentationRequest( - vaultId, - file, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index b72b412b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifySpreadsheetRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * 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.DeidentifySpreadsheetRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifySpreadsheetRequest.Builder.class) -public final class DeidentifySpreadsheetRequest { - private final String vaultId; - - private final DeidentifySpreadsheetRequestFile file; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifySpreadsheetRequest( - String vaultId, - DeidentifySpreadsheetRequestFile file, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifySpreadsheetRequestFile getFile() { - return file; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifySpreadsheetRequest && equalTo((DeidentifySpreadsheetRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifySpreadsheetRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifySpreadsheetRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifySpreadsheetRequestFile file); - } - - public interface _FinalStage { - DeidentifySpreadsheetRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifySpreadsheetRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifySpreadsheetRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifySpreadsheetRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifySpreadsheetRequest build() { - return new DeidentifySpreadsheetRequest( - vaultId, - file, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index a61a5ba0..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyStructuredTextRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * 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.DeidentifyStructuredTextRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyStructuredTextRequest.Builder.class) -public final class DeidentifyStructuredTextRequest { - private final String vaultId; - - private final DeidentifyStructuredTextRequestFile file; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyStructuredTextRequest( - String vaultId, - DeidentifyStructuredTextRequestFile file, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyStructuredTextRequestFile getFile() { - return file; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyStructuredTextRequest && equalTo((DeidentifyStructuredTextRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyStructuredTextRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyStructuredTextRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyStructuredTextRequestFile file); - } - - public interface _FinalStage { - DeidentifyStructuredTextRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyStructuredTextRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyStructuredTextRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyStructuredTextRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifyStructuredTextRequest build() { - return new DeidentifyStructuredTextRequest( - vaultId, - file, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} 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 deleted file mode 100644 index 4eb0ac6c..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/DeidentifyTextRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * 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.DeidentifyTextRequestFile; -import com.skyflow.generated.rest.types.EntityType; -import com.skyflow.generated.rest.types.TokenTypeWithoutVault; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyTextRequest.Builder.class) -public final class DeidentifyTextRequest { - private final String vaultId; - - private final DeidentifyTextRequestFile file; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyTextRequest( - String vaultId, - DeidentifyTextRequestFile file, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.file = file; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return File to de-identify. Files are specified as Base64-encoded data. - */ - @JsonProperty("file") - public DeidentifyTextRequestFile getFile() { - return file; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyTextRequest && equalTo((DeidentifyTextRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyTextRequest other) { - return vaultId.equals(other.vaultId) - && file.equals(other.file) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.file, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyTextRequest other); - } - - public interface FileStage { - /** - * File to de-identify. Files are specified as Base64-encoded data. - */ - _FinalStage file(@NotNull DeidentifyTextRequestFile file); - } - - public interface _FinalStage { - DeidentifyTextRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenTypeWithoutVault tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, FileStage, _FinalStage { - private String vaultId; - - private DeidentifyTextRequestFile file; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyTextRequest other) { - vaultId(other.getVaultId()); - file(other.getFile()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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 de-identify. Files are specified as Base64-encoded data.

File to de-identify. Files are specified as Base64-encoded data.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("file") - public _FinalStage file(@NotNull DeidentifyTextRequestFile file) { - this.file = Objects.requireNonNull(file, "file must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenTypeWithoutVault tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifyTextRequest build() { - return new DeidentifyTextRequest( - vaultId, - file, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java b/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java deleted file mode 100644 index 390d2090..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/requests/GetRunRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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.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 = GetRunRequest.Builder.class) -public final class GetRunRequest { - private final String vaultId; - - private final Map additionalProperties; - - private GetRunRequest(String vaultId, Map additionalProperties) { - this.vaultId = vaultId; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the vault. - */ - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetRunRequest && equalTo((GetRunRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetRunRequest 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 VaultIdStage builder() { - return new Builder(); - } - - public interface VaultIdStage { - /** - * ID of the vault. - */ - _FinalStage vaultId(@NotNull String vaultId); - - Builder from(GetRunRequest other); - } - - public interface _FinalStage { - GetRunRequest build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, _FinalStage { - private String vaultId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetRunRequest other) { - vaultId(other.getVaultId()); - 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 GetRunRequest build() { - return new GetRunRequest(vaultId, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java deleted file mode 100644 index ad124de0..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFile.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * 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 = DeidentifyAudioRequestFile.Builder.class) -public final class DeidentifyAudioRequestFile { - private final String base64; - - private final DeidentifyAudioRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifyAudioRequestFile( - String base64, DeidentifyAudioRequestFileDataFormat dataFormat, Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifyAudioRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyAudioRequestFile && equalTo((DeidentifyAudioRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyAudioRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifyAudioRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifyAudioRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifyAudioRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifyAudioRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyAudioRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifyAudioRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyAudioRequestFile build() { - return new DeidentifyAudioRequestFile(base64, dataFormat, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java deleted file mode 100644 index 05203b05..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestFileDataFormat.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyAudioRequestFileDataFormat { - MP_3("mp3"), - - WAV("wav"); - - private final String value; - - DeidentifyAudioRequestFileDataFormat(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/resources/files/types/DeidentifyAudioRequestOutputTranscription.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java deleted file mode 100644 index bd2d8aac..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyAudioRequestOutputTranscription.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyAudioRequestOutputTranscription { - DIARIZED_TRANSCRIPTION("diarized_transcription"), - - MEDICAL_DIARIZED_TRANSCRIPTION("medical_diarized_transcription"), - - MEDICAL_TRANSCRIPTION("medical_transcription"), - - PLAINTEXT_TRANSCRIPTION("plaintext_transcription"), - - TRANSCRIPTION("transcription"); - - private final String value; - - DeidentifyAudioRequestOutputTranscription(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/resources/files/types/DeidentifyDocumentRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java deleted file mode 100644 index 76c7972c..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFile.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * 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 = DeidentifyDocumentRequestFile.Builder.class) -public final class DeidentifyDocumentRequestFile { - private final String base64; - - private final DeidentifyDocumentRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifyDocumentRequestFile( - String base64, - DeidentifyDocumentRequestFileDataFormat dataFormat, - Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifyDocumentRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyDocumentRequestFile && equalTo((DeidentifyDocumentRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyDocumentRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifyDocumentRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifyDocumentRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifyDocumentRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifyDocumentRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyDocumentRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifyDocumentRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyDocumentRequestFile build() { - return new DeidentifyDocumentRequestFile(base64, dataFormat, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java deleted file mode 100644 index 6b741b95..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyDocumentRequestFileDataFormat.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyDocumentRequestFileDataFormat { - DOC("doc"), - - DOCX("docx"), - - PDF("pdf"); - - private final String value; - - DeidentifyDocumentRequestFileDataFormat(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/resources/files/types/DeidentifyFileRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.java deleted file mode 100644 index f21ddeef..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFile.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * 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 = DeidentifyFileRequestFile.Builder.class) -public final class DeidentifyFileRequestFile { - private final String base64; - - private final DeidentifyFileRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifyFileRequestFile( - String base64, DeidentifyFileRequestFileDataFormat dataFormat, Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifyFileRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyFileRequestFile && equalTo((DeidentifyFileRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyFileRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifyFileRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifyFileRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifyFileRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifyFileRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyFileRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifyFileRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyFileRequestFile build() { - return new DeidentifyFileRequestFile(base64, dataFormat, 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 deleted file mode 100644 index afc90bc3..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyFileRequestFileDataFormat.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyFileRequestFileDataFormat { - BMP("bmp"), - - 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"), - - WAV("wav"), - - XLS("xls"), - - XLSX("xlsx"), - - XML("xml"); - - private final String value; - - DeidentifyFileRequestFileDataFormat(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/resources/files/types/DeidentifyImageRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.java deleted file mode 100644 index 116fd94d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFile.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * 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 = DeidentifyImageRequestFile.Builder.class) -public final class DeidentifyImageRequestFile { - private final String base64; - - private final DeidentifyImageRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifyImageRequestFile( - String base64, DeidentifyImageRequestFileDataFormat dataFormat, Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifyImageRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyImageRequestFile && equalTo((DeidentifyImageRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyImageRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifyImageRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifyImageRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifyImageRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifyImageRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyImageRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifyImageRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyImageRequestFile build() { - return new DeidentifyImageRequestFile(base64, dataFormat, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java deleted file mode 100644 index cfb324d9..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestFileDataFormat.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyImageRequestFileDataFormat { - BMP("bmp"), - - JPEG("jpeg"), - - JPG("jpg"), - - PNG("png"), - - TIF("tif"), - - TIFF("tiff"); - - private final String value; - - DeidentifyImageRequestFileDataFormat(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/resources/files/types/DeidentifyImageRequestMaskingMethod.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java deleted file mode 100644 index 8cf5bf3c..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyImageRequestMaskingMethod.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyImageRequestMaskingMethod { - BLACKBOX("blackbox"), - - BLUR("blur"); - - private final String value; - - DeidentifyImageRequestMaskingMethod(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/resources/files/types/DeidentifyPdfRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java deleted file mode 100644 index 14028aab..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPdfRequestFile.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * 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 = DeidentifyPdfRequestFile.Builder.class) -public final class DeidentifyPdfRequestFile { - private final String base64; - - private final Map additionalProperties; - - private DeidentifyPdfRequestFile(String base64, Map additionalProperties) { - this.base64 = base64; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public String getDataFormat() { - return "pdf"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyPdfRequestFile && equalTo((DeidentifyPdfRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyPdfRequestFile other) { - return base64.equals(other.base64); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.base64); - } - - @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 de-identify. - */ - _FinalStage base64(@NotNull String base64); - - Builder from(DeidentifyPdfRequestFile other); - } - - public interface _FinalStage { - DeidentifyPdfRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, _FinalStage { - private String base64; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyPdfRequestFile other) { - base64(other.getBase64()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("base64") - public _FinalStage base64(@NotNull String base64) { - this.base64 = Objects.requireNonNull(base64, "base64 must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyPdfRequestFile build() { - return new DeidentifyPdfRequestFile(base64, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java deleted file mode 100644 index 1b2e247f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFile.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * 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 = DeidentifyPresentationRequestFile.Builder.class) -public final class DeidentifyPresentationRequestFile { - private final String base64; - - private final DeidentifyPresentationRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifyPresentationRequestFile( - String base64, - DeidentifyPresentationRequestFileDataFormat dataFormat, - Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifyPresentationRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyPresentationRequestFile && equalTo((DeidentifyPresentationRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyPresentationRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifyPresentationRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifyPresentationRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifyPresentationRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifyPresentationRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyPresentationRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifyPresentationRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyPresentationRequestFile build() { - return new DeidentifyPresentationRequestFile(base64, dataFormat, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java deleted file mode 100644 index e6bcd268..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyPresentationRequestFileDataFormat.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyPresentationRequestFileDataFormat { - PPT("ppt"), - - PPTX("pptx"); - - private final String value; - - DeidentifyPresentationRequestFileDataFormat(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/resources/files/types/DeidentifySpreadsheetRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java deleted file mode 100644 index 2e291563..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFile.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * 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 = DeidentifySpreadsheetRequestFile.Builder.class) -public final class DeidentifySpreadsheetRequestFile { - private final String base64; - - private final DeidentifySpreadsheetRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifySpreadsheetRequestFile( - String base64, - DeidentifySpreadsheetRequestFileDataFormat dataFormat, - Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifySpreadsheetRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifySpreadsheetRequestFile && equalTo((DeidentifySpreadsheetRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifySpreadsheetRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifySpreadsheetRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifySpreadsheetRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifySpreadsheetRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifySpreadsheetRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifySpreadsheetRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifySpreadsheetRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifySpreadsheetRequestFile build() { - return new DeidentifySpreadsheetRequestFile(base64, dataFormat, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java deleted file mode 100644 index 795a2666..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifySpreadsheetRequestFileDataFormat { - CSV("csv"), - - XLS("xls"), - - XLSX("xlsx"); - - private final String value; - - DeidentifySpreadsheetRequestFileDataFormat(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/resources/files/types/DeidentifyStructuredTextRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java deleted file mode 100644 index d8d5193a..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFile.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * 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 = DeidentifyStructuredTextRequestFile.Builder.class) -public final class DeidentifyStructuredTextRequestFile { - private final String base64; - - private final DeidentifyStructuredTextRequestFileDataFormat dataFormat; - - private final Map additionalProperties; - - private DeidentifyStructuredTextRequestFile( - String base64, - DeidentifyStructuredTextRequestFileDataFormat dataFormat, - Map additionalProperties) { - this.base64 = base64; - this.dataFormat = dataFormat; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public DeidentifyStructuredTextRequestFileDataFormat getDataFormat() { - return dataFormat; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyStructuredTextRequestFile - && equalTo((DeidentifyStructuredTextRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyStructuredTextRequestFile 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 de-identify. - */ - DataFormatStage base64(@NotNull String base64); - - Builder from(DeidentifyStructuredTextRequestFile other); - } - - public interface DataFormatStage { - /** - * Data format of the file. - */ - _FinalStage dataFormat(@NotNull DeidentifyStructuredTextRequestFileDataFormat dataFormat); - } - - public interface _FinalStage { - DeidentifyStructuredTextRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, DataFormatStage, _FinalStage { - private String base64; - - private DeidentifyStructuredTextRequestFileDataFormat dataFormat; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyStructuredTextRequestFile other) { - base64(other.getBase64()); - dataFormat(other.getDataFormat()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

Base64-encoded data of the file to de-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 DeidentifyStructuredTextRequestFileDataFormat dataFormat) { - this.dataFormat = Objects.requireNonNull(dataFormat, "dataFormat must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyStructuredTextRequestFile build() { - return new DeidentifyStructuredTextRequestFile(base64, dataFormat, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java deleted file mode 100644 index 11b30288..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum DeidentifyStructuredTextRequestFileDataFormat { - JSON("json"), - - XML("xml"); - - private final String value; - - DeidentifyStructuredTextRequestFileDataFormat(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/resources/files/types/DeidentifyTextRequestFile.java b/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java deleted file mode 100644 index c7cbc5b3..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/files/types/DeidentifyTextRequestFile.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * 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 = DeidentifyTextRequestFile.Builder.class) -public final class DeidentifyTextRequestFile { - private final String base64; - - private final Map additionalProperties; - - private DeidentifyTextRequestFile(String base64, Map additionalProperties) { - this.base64 = base64; - this.additionalProperties = additionalProperties; - } - - /** - * @return Base64-encoded data of the file to de-identify. - */ - @JsonProperty("base64") - public String getBase64() { - return base64; - } - - /** - * @return Data format of the file. - */ - @JsonProperty("data_format") - public String getDataFormat() { - return "txt"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyTextRequestFile && equalTo((DeidentifyTextRequestFile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyTextRequestFile other) { - return base64.equals(other.base64); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.base64); - } - - @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 de-identify. - */ - _FinalStage base64(@NotNull String base64); - - Builder from(DeidentifyTextRequestFile other); - } - - public interface _FinalStage { - DeidentifyTextRequestFile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements Base64Stage, _FinalStage { - private String base64; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyTextRequestFile other) { - base64(other.getBase64()); - return this; - } - - /** - * Base64-encoded data of the file to de-identify.

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("base64") - public _FinalStage base64(@NotNull String base64) { - this.base64 = Objects.requireNonNull(base64, "base64 must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyTextRequestFile build() { - return new DeidentifyTextRequestFile(base64, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java b/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java deleted file mode 100644 index 894c97b5..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/query/AsyncQueryClient.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.query; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; -import com.skyflow.generated.rest.types.V1GetQueryResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncQueryClient { - protected final ClientOptions clientOptions; - - private final AsyncRawQueryClient rawClient; - - public AsyncQueryClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawQueryClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawQueryClient withRawResponse() { - return this.rawClient; - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public CompletableFuture queryServiceExecuteQuery(String vaultId) { - return this.rawClient.queryServiceExecuteQuery(vaultId).thenApply(response -> response.body()); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public CompletableFuture queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request) { - return this.rawClient.queryServiceExecuteQuery(vaultId, request).thenApply(response -> response.body()); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public CompletableFuture queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { - return this.rawClient - .queryServiceExecuteQuery(vaultId, request, requestOptions) - .thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java b/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java deleted file mode 100644 index 96e2dc0b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/query/AsyncRawQueryClient.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.query; - -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.NotFoundError; -import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; -import com.skyflow.generated.rest.types.V1GetQueryResponse; -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 AsyncRawQueryClient { - protected final ClientOptions clientOptions; - - public AsyncRawQueryClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public CompletableFuture> queryServiceExecuteQuery(String vaultId) { - return queryServiceExecuteQuery( - vaultId, QueryServiceExecuteQueryBody.builder().build()); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public CompletableFuture> queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request) { - return queryServiceExecuteQuery(vaultId, request, null); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public CompletableFuture> queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegments("query") - .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(), V1GetQueryResponse.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/query/QueryClient.java b/src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java deleted file mode 100644 index 39bb709d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/query/QueryClient.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.query; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; -import com.skyflow.generated.rest.types.V1GetQueryResponse; - -public class QueryClient { - protected final ClientOptions clientOptions; - - private final RawQueryClient rawClient; - - public QueryClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawQueryClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawQueryClient withRawResponse() { - return this.rawClient; - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public V1GetQueryResponse queryServiceExecuteQuery(String vaultId) { - return this.rawClient.queryServiceExecuteQuery(vaultId).body(); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public V1GetQueryResponse queryServiceExecuteQuery(String vaultId, QueryServiceExecuteQueryBody request) { - return this.rawClient.queryServiceExecuteQuery(vaultId, request).body(); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public V1GetQueryResponse queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { - return this.rawClient - .queryServiceExecuteQuery(vaultId, request, requestOptions) - .body(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java b/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java deleted file mode 100644 index 3e5bee51..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/query/RawQueryClient.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.query; - -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.NotFoundError; -import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; -import com.skyflow.generated.rest.types.V1GetQueryResponse; -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 RawQueryClient { - protected final ClientOptions clientOptions; - - public RawQueryClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public ApiClientHttpResponse queryServiceExecuteQuery(String vaultId) { - return queryServiceExecuteQuery( - vaultId, QueryServiceExecuteQueryBody.builder().build()); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public ApiClientHttpResponse queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request) { - return queryServiceExecuteQuery(vaultId, request, null); - } - - /** - * Returns records for a valid SQL query. This endpoint <ul><li>Can return redacted record values.</li><li>Supports only the <code>SELECT</code> command.</li><li>Returns a maximum of 25 records. To return additional records, perform another query using the <code>OFFSET</code> keyword.</li><li>Can't modify the vault or perform transactions.</li><li>Can't return tokens.</li><li>Can't return file download or render URLs.</li><li>Doesn't support the <code>WHERE</code> keyword with columns using transient tokenization.</li><li>Doesn't support ? conditional for columns with column-level encryption disabled.</li><ul> - */ - public ApiClientHttpResponse queryServiceExecuteQuery( - String vaultId, QueryServiceExecuteQueryBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegments("query") - .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(), V1GetQueryResponse.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/query/requests/QueryServiceExecuteQueryBody.java b/src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java deleted file mode 100644 index dfa21d15..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/query/requests/QueryServiceExecuteQueryBody.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.query.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 = QueryServiceExecuteQueryBody.Builder.class) -public final class QueryServiceExecuteQueryBody { - private final Optional query; - - private final Map additionalProperties; - - private QueryServiceExecuteQueryBody(Optional query, Map additionalProperties) { - this.query = query; - this.additionalProperties = additionalProperties; - } - - /** - * @return The SQL query to execute.<br><br><b>Supported commands:</b> <ul> <li><code>SELECT</code></li> </ul> <b>Supported operators:</b> <ul> <li><code>></code></li> <li><code><</code></li> <li><code>=</code></li> <li><code>AND</code></li> <li><code>OR</code></li> <li><code>NOT</code></li> <li><code>LIKE</code></li> <li><code>ILIKE</code></li> <li><code>NULL</code></li> <li><code>NOT NULL</code></li> </ul> <b>Supported keywords:</b> <ul> <li><code>FROM</code></li> <li><code>JOIN</code></li> <li><code>INNER JOIN</code></li> <li><code>LEFT OUTER JOIN</code></li> <li><code>LEFT JOIN</code></li> <li><code>RIGHT OUTER JOIN</code></li> <li><code>RIGHT JOIN</code></li> <li><code>FULL OUTER JOIN</code></li> <li><code>FULL JOIN</code></li> <li><code>OFFSET</code></li> <li><code>LIMIT</code></li> <li><code>WHERE</code></li> </ul> <b>Supported functions:</b> <ul> <li><code>AVG()</code></li> <li><code>SUM()</code></li> <li><code>COUNT()</code></li> <li><code>MIN()</code></li> <li><code>MAX()</code></li> <li><code>REDACTION()</code></li> </ul> - */ - @JsonProperty("query") - public Optional getQuery() { - return query; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof QueryServiceExecuteQueryBody && equalTo((QueryServiceExecuteQueryBody) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(QueryServiceExecuteQueryBody other) { - return query.equals(other.query); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.query); - } - - @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 query = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(QueryServiceExecuteQueryBody other) { - query(other.getQuery()); - return this; - } - - /** - *

The SQL query to execute.<br><br><b>Supported commands:</b> <ul> <li><code>SELECT</code></li> </ul> <b>Supported operators:</b> <ul> <li><code>></code></li> <li><code><</code></li> <li><code>=</code></li> <li><code>AND</code></li> <li><code>OR</code></li> <li><code>NOT</code></li> <li><code>LIKE</code></li> <li><code>ILIKE</code></li> <li><code>NULL</code></li> <li><code>NOT NULL</code></li> </ul> <b>Supported keywords:</b> <ul> <li><code>FROM</code></li> <li><code>JOIN</code></li> <li><code>INNER JOIN</code></li> <li><code>LEFT OUTER JOIN</code></li> <li><code>LEFT JOIN</code></li> <li><code>RIGHT OUTER JOIN</code></li> <li><code>RIGHT JOIN</code></li> <li><code>FULL OUTER JOIN</code></li> <li><code>FULL JOIN</code></li> <li><code>OFFSET</code></li> <li><code>LIMIT</code></li> <li><code>WHERE</code></li> </ul> <b>Supported functions:</b> <ul> <li><code>AVG()</code></li> <li><code>SUM()</code></li> <li><code>COUNT()</code></li> <li><code>MIN()</code></li> <li><code>MAX()</code></li> <li><code>REDACTION()</code></li> </ul>

- */ - @JsonSetter(value = "query", nulls = Nulls.SKIP) - public Builder query(Optional query) { - this.query = query; - return this; - } - - public Builder query(String query) { - this.query = Optional.ofNullable(query); - return this; - } - - public QueryServiceExecuteQueryBody build() { - return new QueryServiceExecuteQueryBody(query, 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 deleted file mode 100644 index 757ee8e4..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRawRecordsClient.java +++ /dev/null @@ -1,956 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records; - -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.records.requests.FileServiceUploadFileRequest; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkDeleteRecordBody; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; -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.types.V1BatchOperationResponse; -import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; -import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; -import com.skyflow.generated.rest.types.V1DeleteFileResponse; -import com.skyflow.generated.rest.types.V1DeleteRecordResponse; -import com.skyflow.generated.rest.types.V1FieldRecords; -import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; -import com.skyflow.generated.rest.types.V1InsertRecordResponse; -import com.skyflow.generated.rest.types.V1UpdateRecordResponse; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; -import org.jetbrains.annotations.NotNull; - -public class AsyncRawRecordsClient { - protected final ClientOptions clientOptions; - - public AsyncRawRecordsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Performs multiple record operations in a single transaction. - */ - public CompletableFuture> recordServiceBatchOperation( - String vaultId) { - return recordServiceBatchOperation( - vaultId, RecordServiceBatchOperationBody.builder().build()); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public CompletableFuture> recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request) { - return recordServiceBatchOperation(vaultId, request, null); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public CompletableFuture> recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .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(), V1BatchOperationResponse.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; - } - - /** - * Gets the specified records from a table. - */ - public CompletableFuture> recordServiceBulkGetRecord( - String vaultId, String objectName) { - return recordServiceBulkGetRecord( - vaultId, objectName, RecordServiceBulkGetRecordRequest.builder().build()); - } - - /** - * Gets the specified records from a table. - */ - public CompletableFuture> recordServiceBulkGetRecord( - String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { - return recordServiceBulkGetRecord(vaultId, objectName, request, null); - } - - /** - * Gets the specified records from a table. - */ - public CompletableFuture> recordServiceBulkGetRecord( - String vaultId, - String objectName, - RecordServiceBulkGetRecordRequest request, - RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName); - if (request.getRedaction().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "redaction", request.getRedaction().get(), false); - } - if (request.getTokenization().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "tokenization", request.getTokenization().get(), false); - } - if (request.getOffset().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "offset", request.getOffset().get(), false); - } - if (request.getLimit().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "limit", request.getLimit().get(), false); - } - if (request.getDownloadUrl().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "downloadURL", request.getDownloadUrl().get(), false); - } - if (request.getColumnName().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "column_name", request.getColumnName().get(), false); - } - if (request.getOrderBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "order_by", request.getOrderBy().get(), false); - } - if (request.getSkyflowIds().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "skyflow_ids", request.getSkyflowIds().get(), true); - } - if (request.getFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "fields", request.getFields().get(), true); - } - if (request.getColumnValues().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "column_values", request.getColumnValues().get(), true); - } - 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(), V1BulkGetRecordResponse.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; - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public CompletableFuture> recordServiceInsertRecord( - String vaultId, String objectName) { - return recordServiceInsertRecord( - vaultId, objectName, RecordServiceInsertRecordBody.builder().build()); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public CompletableFuture> recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request) { - return recordServiceInsertRecord(vaultId, objectName, request, null); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public CompletableFuture> recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .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(), V1InsertRecordResponse.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; - } - - /** - * Deletes the specified records from a table. - */ - public CompletableFuture> recordServiceBulkDeleteRecord( - String vaultId, String objectName) { - return recordServiceBulkDeleteRecord( - vaultId, objectName, RecordServiceBulkDeleteRecordBody.builder().build()); - } - - /** - * Deletes the specified records from a table. - */ - public CompletableFuture> recordServiceBulkDeleteRecord( - String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { - return recordServiceBulkDeleteRecord(vaultId, objectName, request, null); - } - - /** - * Deletes the specified records from a table. - */ - public CompletableFuture> recordServiceBulkDeleteRecord( - String vaultId, - String objectName, - RecordServiceBulkDeleteRecordBody request, - RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .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("DELETE", 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(), V1BulkDeleteRecordResponse.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; - } - - /** - * Returns the specified record from a table. - */ - public CompletableFuture> recordServiceGetRecord( - String vaultId, String objectName, String id) { - return recordServiceGetRecord( - vaultId, objectName, id, RecordServiceGetRecordRequest.builder().build()); - } - - /** - * Returns the specified record from a table. - */ - public CompletableFuture> recordServiceGetRecord( - String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { - return recordServiceGetRecord(vaultId, objectName, id, request, null); - } - - /** - * Returns the specified record from a table. - */ - public CompletableFuture> recordServiceGetRecord( - String vaultId, - String objectName, - String id, - RecordServiceGetRecordRequest request, - RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id); - if (request.getRedaction().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "redaction", request.getRedaction().get(), false); - } - if (request.getTokenization().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "tokenization", request.getTokenization().get(), false); - } - if (request.getDownloadUrl().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "downloadURL", request.getDownloadUrl().get(), false); - } - if (request.getFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "fields", request.getFields().get(), true); - } - 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(), V1FieldRecords.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; - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public CompletableFuture> recordServiceUpdateRecord( - String vaultId, String objectName, String id) { - return recordServiceUpdateRecord( - vaultId, objectName, id, RecordServiceUpdateRecordBody.builder().build()); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public CompletableFuture> recordServiceUpdateRecord( - String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { - return recordServiceUpdateRecord(vaultId, objectName, id, request, null); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public CompletableFuture> recordServiceUpdateRecord( - String vaultId, - String objectName, - String id, - RecordServiceUpdateRecordBody request, - RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id) - .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("PUT", 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(), V1UpdateRecordResponse.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; - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public CompletableFuture> recordServiceDeleteRecord( - String vaultId, String objectName, String id) { - return recordServiceDeleteRecord(vaultId, objectName, id, null); - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public CompletableFuture> recordServiceDeleteRecord( - String vaultId, String objectName, String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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(), V1DeleteRecordResponse.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; - } - - /** - * Uploads a file to the specified record. - */ - public CompletableFuture> fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { - return fileServiceUploadFile( - vaultId, - objectName, - id, - fileColumnName, - FileServiceUploadFileRequest.builder().build()); - } - - /** - * 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); - } - - /** - * Uploads a file to the specified record. - */ - public CompletableFuture> fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request, - RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id) - .addPathSegments("files") - .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; - body.addFormDataPart( - "fileColumnName", - fileColumnName.get().getName(), - RequestBody.create(fileColumnName.get(), fileColumnNameMimeTypeMediaType)); - } - } 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(), V1UpdateRecordResponse.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; - } - - /** - * Deletes a file from the specified record. - */ - public CompletableFuture> fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName) { - return fileServiceDeleteFile(vaultId, tableName, id, columnName, null); - } - - /** - * Deletes a file from the specified record. - */ - public CompletableFuture> fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(tableName) - .addPathSegment(id) - .addPathSegments("files") - .addPathSegment(columnName) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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(), V1DeleteFileResponse.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; - } - - /** - * Returns the anti-virus scan status of a file. - */ - public CompletableFuture> fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName) { - return fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, null); - } - - /** - * Returns the anti-virus scan status of a file. - */ - public CompletableFuture> fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(tableName) - .addPathSegment(id) - .addPathSegments("files") - .addPathSegment(columnName) - .addPathSegments("scan-status") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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(), V1GetFileScanStatusResponse.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/records/AsyncRecordsClient.java b/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java deleted file mode 100644 index baf98c1d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/AsyncRecordsClient.java +++ /dev/null @@ -1,317 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -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; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; -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.types.V1BatchOperationResponse; -import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; -import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; -import com.skyflow.generated.rest.types.V1DeleteFileResponse; -import com.skyflow.generated.rest.types.V1DeleteRecordResponse; -import com.skyflow.generated.rest.types.V1FieldRecords; -import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; -import com.skyflow.generated.rest.types.V1InsertRecordResponse; -import com.skyflow.generated.rest.types.V1UpdateRecordResponse; -import java.io.File; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; - -public class AsyncRecordsClient { - protected final ClientOptions clientOptions; - - private final AsyncRawRecordsClient rawClient; - - public AsyncRecordsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawRecordsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawRecordsClient withRawResponse() { - return this.rawClient; - } - - /** - * Performs multiple record operations in a single transaction. - */ - public CompletableFuture recordServiceBatchOperation(String vaultId) { - return this.rawClient.recordServiceBatchOperation(vaultId).thenApply(response -> response.body()); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public CompletableFuture recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request) { - return this.rawClient.recordServiceBatchOperation(vaultId, request).thenApply(response -> response.body()); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public CompletableFuture recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceBatchOperation(vaultId, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Gets the specified records from a table. - */ - public CompletableFuture recordServiceBulkGetRecord(String vaultId, String objectName) { - return this.rawClient.recordServiceBulkGetRecord(vaultId, objectName).thenApply(response -> response.body()); - } - - /** - * Gets the specified records from a table. - */ - public CompletableFuture recordServiceBulkGetRecord( - String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { - return this.rawClient - .recordServiceBulkGetRecord(vaultId, objectName, request) - .thenApply(response -> response.body()); - } - - /** - * Gets the specified records from a table. - */ - public CompletableFuture recordServiceBulkGetRecord( - String vaultId, - String objectName, - RecordServiceBulkGetRecordRequest request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceBulkGetRecord(vaultId, objectName, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public CompletableFuture recordServiceInsertRecord(String vaultId, String objectName) { - return this.rawClient.recordServiceInsertRecord(vaultId, objectName).thenApply(response -> response.body()); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public CompletableFuture recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request) { - return this.rawClient - .recordServiceInsertRecord(vaultId, objectName, request) - .thenApply(response -> response.body()); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public CompletableFuture recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceInsertRecord(vaultId, objectName, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Deletes the specified records from a table. - */ - public CompletableFuture recordServiceBulkDeleteRecord( - String vaultId, String objectName) { - return this.rawClient.recordServiceBulkDeleteRecord(vaultId, objectName).thenApply(response -> response.body()); - } - - /** - * Deletes the specified records from a table. - */ - public CompletableFuture recordServiceBulkDeleteRecord( - String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { - return this.rawClient - .recordServiceBulkDeleteRecord(vaultId, objectName, request) - .thenApply(response -> response.body()); - } - - /** - * Deletes the specified records from a table. - */ - public CompletableFuture recordServiceBulkDeleteRecord( - String vaultId, - String objectName, - RecordServiceBulkDeleteRecordBody request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceBulkDeleteRecord(vaultId, objectName, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Returns the specified record from a table. - */ - public CompletableFuture recordServiceGetRecord(String vaultId, String objectName, String id) { - return this.rawClient.recordServiceGetRecord(vaultId, objectName, id).thenApply(response -> response.body()); - } - - /** - * Returns the specified record from a table. - */ - public CompletableFuture recordServiceGetRecord( - String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { - return this.rawClient - .recordServiceGetRecord(vaultId, objectName, id, request) - .thenApply(response -> response.body()); - } - - /** - * Returns the specified record from a table. - */ - public CompletableFuture recordServiceGetRecord( - String vaultId, - String objectName, - String id, - RecordServiceGetRecordRequest request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceGetRecord(vaultId, objectName, id, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public CompletableFuture recordServiceUpdateRecord( - String vaultId, String objectName, String id) { - return this.rawClient.recordServiceUpdateRecord(vaultId, objectName, id).thenApply(response -> response.body()); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public CompletableFuture recordServiceUpdateRecord( - String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { - return this.rawClient - .recordServiceUpdateRecord(vaultId, objectName, id, request) - .thenApply(response -> response.body()); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public CompletableFuture recordServiceUpdateRecord( - String vaultId, - String objectName, - String id, - RecordServiceUpdateRecordBody request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceUpdateRecord(vaultId, objectName, id, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public CompletableFuture recordServiceDeleteRecord( - String vaultId, String objectName, String id) { - return this.rawClient.recordServiceDeleteRecord(vaultId, objectName, id).thenApply(response -> response.body()); - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public CompletableFuture recordServiceDeleteRecord( - String vaultId, String objectName, String id, RequestOptions requestOptions) { - return this.rawClient - .recordServiceDeleteRecord(vaultId, objectName, id, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Uploads a file to the specified record. - */ - public CompletableFuture fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { - return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName) - .thenApply(response -> response.body()); - } - - /** - * Uploads a file to the specified record. - */ - public CompletableFuture fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request) { - return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request) - .thenApply(response -> response.body()); - } - - /** - * Uploads a file to the specified record. - */ - public CompletableFuture fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request, - RequestOptions requestOptions) { - return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Deletes a file from the specified record. - */ - public CompletableFuture fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName) { - return this.rawClient - .fileServiceDeleteFile(vaultId, tableName, id, columnName) - .thenApply(response -> response.body()); - } - - /** - * Deletes a file from the specified record. - */ - public CompletableFuture fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - return this.rawClient - .fileServiceDeleteFile(vaultId, tableName, id, columnName, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Returns the anti-virus scan status of a file. - */ - public CompletableFuture fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName) { - return this.rawClient - .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName) - .thenApply(response -> response.body()); - } - - /** - * Returns the anti-virus scan status of a file. - */ - public CompletableFuture fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - return this.rawClient - .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, 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 deleted file mode 100644 index 593f5e3d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/RawRecordsClient.java +++ /dev/null @@ -1,800 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records; - -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.records.requests.FileServiceUploadFileRequest; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBatchOperationBody; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkDeleteRecordBody; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; -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.types.V1BatchOperationResponse; -import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; -import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; -import com.skyflow.generated.rest.types.V1DeleteFileResponse; -import com.skyflow.generated.rest.types.V1DeleteRecordResponse; -import com.skyflow.generated.rest.types.V1FieldRecords; -import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; -import com.skyflow.generated.rest.types.V1InsertRecordResponse; -import com.skyflow.generated.rest.types.V1UpdateRecordResponse; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Optional; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawRecordsClient { - protected final ClientOptions clientOptions; - - public RawRecordsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Performs multiple record operations in a single transaction. - */ - public ApiClientHttpResponse recordServiceBatchOperation(String vaultId) { - return recordServiceBatchOperation( - vaultId, RecordServiceBatchOperationBody.builder().build()); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public ApiClientHttpResponse recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request) { - return recordServiceBatchOperation(vaultId, request, null); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public ApiClientHttpResponse recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .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(), V1BatchOperationResponse.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); - } - } - - /** - * Gets the specified records from a table. - */ - public ApiClientHttpResponse recordServiceBulkGetRecord( - String vaultId, String objectName) { - return recordServiceBulkGetRecord( - vaultId, objectName, RecordServiceBulkGetRecordRequest.builder().build()); - } - - /** - * Gets the specified records from a table. - */ - public ApiClientHttpResponse recordServiceBulkGetRecord( - String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { - return recordServiceBulkGetRecord(vaultId, objectName, request, null); - } - - /** - * Gets the specified records from a table. - */ - public ApiClientHttpResponse recordServiceBulkGetRecord( - String vaultId, - String objectName, - RecordServiceBulkGetRecordRequest request, - RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName); - if (request.getRedaction().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "redaction", request.getRedaction().get(), false); - } - if (request.getTokenization().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "tokenization", request.getTokenization().get(), false); - } - if (request.getOffset().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "offset", request.getOffset().get(), false); - } - if (request.getLimit().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "limit", request.getLimit().get(), false); - } - if (request.getDownloadUrl().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "downloadURL", request.getDownloadUrl().get(), false); - } - if (request.getColumnName().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "column_name", request.getColumnName().get(), false); - } - if (request.getOrderBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "order_by", request.getOrderBy().get(), false); - } - if (request.getSkyflowIds().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "skyflow_ids", request.getSkyflowIds().get(), true); - } - if (request.getFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "fields", request.getFields().get(), true); - } - if (request.getColumnValues().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "column_values", request.getColumnValues().get(), true); - } - 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(), V1BulkGetRecordResponse.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); - } - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public ApiClientHttpResponse recordServiceInsertRecord(String vaultId, String objectName) { - return recordServiceInsertRecord( - vaultId, objectName, RecordServiceInsertRecordBody.builder().build()); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public ApiClientHttpResponse recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request) { - return recordServiceInsertRecord(vaultId, objectName, request, null); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public ApiClientHttpResponse recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .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(), V1InsertRecordResponse.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); - } - } - - /** - * Deletes the specified records from a table. - */ - public ApiClientHttpResponse recordServiceBulkDeleteRecord( - String vaultId, String objectName) { - return recordServiceBulkDeleteRecord( - vaultId, objectName, RecordServiceBulkDeleteRecordBody.builder().build()); - } - - /** - * Deletes the specified records from a table. - */ - public ApiClientHttpResponse recordServiceBulkDeleteRecord( - String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { - return recordServiceBulkDeleteRecord(vaultId, objectName, request, null); - } - - /** - * Deletes the specified records from a table. - */ - public ApiClientHttpResponse recordServiceBulkDeleteRecord( - String vaultId, - String objectName, - RecordServiceBulkDeleteRecordBody request, - RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .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("DELETE", 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(), V1BulkDeleteRecordResponse.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); - } - } - - /** - * Returns the specified record from a table. - */ - public ApiClientHttpResponse recordServiceGetRecord(String vaultId, String objectName, String id) { - return recordServiceGetRecord( - vaultId, objectName, id, RecordServiceGetRecordRequest.builder().build()); - } - - /** - * Returns the specified record from a table. - */ - public ApiClientHttpResponse recordServiceGetRecord( - String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { - return recordServiceGetRecord(vaultId, objectName, id, request, null); - } - - /** - * Returns the specified record from a table. - */ - public ApiClientHttpResponse recordServiceGetRecord( - String vaultId, - String objectName, - String id, - RecordServiceGetRecordRequest request, - RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id); - if (request.getRedaction().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "redaction", request.getRedaction().get(), false); - } - if (request.getTokenization().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "tokenization", request.getTokenization().get(), false); - } - if (request.getDownloadUrl().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "downloadURL", request.getDownloadUrl().get(), false); - } - if (request.getFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "fields", request.getFields().get(), true); - } - 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(), V1FieldRecords.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); - } - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public ApiClientHttpResponse recordServiceUpdateRecord( - String vaultId, String objectName, String id) { - return recordServiceUpdateRecord( - vaultId, objectName, id, RecordServiceUpdateRecordBody.builder().build()); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public ApiClientHttpResponse recordServiceUpdateRecord( - String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { - return recordServiceUpdateRecord(vaultId, objectName, id, request, null); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public ApiClientHttpResponse recordServiceUpdateRecord( - String vaultId, - String objectName, - String id, - RecordServiceUpdateRecordBody request, - RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id) - .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("PUT", 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(), V1UpdateRecordResponse.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); - } - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public ApiClientHttpResponse recordServiceDeleteRecord( - String vaultId, String objectName, String id) { - return recordServiceDeleteRecord(vaultId, objectName, id, null); - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public ApiClientHttpResponse recordServiceDeleteRecord( - String vaultId, String objectName, String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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(), V1DeleteRecordResponse.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); - } - } - - /** - * Uploads a file to the specified record. - */ - public ApiClientHttpResponse fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { - return fileServiceUploadFile( - vaultId, - objectName, - id, - fileColumnName, - FileServiceUploadFileRequest.builder().build()); - } - - /** - * 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); - } - - /** - * Uploads a file to the specified record. - */ - public ApiClientHttpResponse fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request, - RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(objectName) - .addPathSegment(id) - .addPathSegments("files") - .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; - body.addFormDataPart( - "fileColumnName", - fileColumnName.get().getName(), - RequestBody.create(fileColumnName.get(), fileColumnNameMimeTypeMediaType)); - } - } 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(), V1UpdateRecordResponse.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); - } - } - - /** - * Deletes a file from the specified record. - */ - public ApiClientHttpResponse fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName) { - return fileServiceDeleteFile(vaultId, tableName, id, columnName, null); - } - - /** - * Deletes a file from the specified record. - */ - public ApiClientHttpResponse fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(tableName) - .addPathSegment(id) - .addPathSegments("files") - .addPathSegment(columnName) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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(), V1DeleteFileResponse.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); - } - } - - /** - * Returns the anti-virus scan status of a file. - */ - public ApiClientHttpResponse fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName) { - return fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, null); - } - - /** - * Returns the anti-virus scan status of a file. - */ - public ApiClientHttpResponse fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegment(tableName) - .addPathSegment(id) - .addPathSegments("files") - .addPathSegment(columnName) - .addPathSegments("scan-status") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .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(), V1GetFileScanStatusResponse.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/records/RecordsClient.java b/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java deleted file mode 100644 index fee9d49b..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/RecordsClient.java +++ /dev/null @@ -1,312 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -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; -import com.skyflow.generated.rest.resources.records.requests.RecordServiceBulkGetRecordRequest; -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.types.V1BatchOperationResponse; -import com.skyflow.generated.rest.types.V1BulkDeleteRecordResponse; -import com.skyflow.generated.rest.types.V1BulkGetRecordResponse; -import com.skyflow.generated.rest.types.V1DeleteFileResponse; -import com.skyflow.generated.rest.types.V1DeleteRecordResponse; -import com.skyflow.generated.rest.types.V1FieldRecords; -import com.skyflow.generated.rest.types.V1GetFileScanStatusResponse; -import com.skyflow.generated.rest.types.V1InsertRecordResponse; -import com.skyflow.generated.rest.types.V1UpdateRecordResponse; -import java.io.File; -import java.util.Optional; - -public class RecordsClient { - protected final ClientOptions clientOptions; - - private final RawRecordsClient rawClient; - - public RecordsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawRecordsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawRecordsClient withRawResponse() { - return this.rawClient; - } - - /** - * Performs multiple record operations in a single transaction. - */ - public V1BatchOperationResponse recordServiceBatchOperation(String vaultId) { - return this.rawClient.recordServiceBatchOperation(vaultId).body(); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public V1BatchOperationResponse recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request) { - return this.rawClient.recordServiceBatchOperation(vaultId, request).body(); - } - - /** - * Performs multiple record operations in a single transaction. - */ - public V1BatchOperationResponse recordServiceBatchOperation( - String vaultId, RecordServiceBatchOperationBody request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceBatchOperation(vaultId, request, requestOptions) - .body(); - } - - /** - * Gets the specified records from a table. - */ - public V1BulkGetRecordResponse recordServiceBulkGetRecord(String vaultId, String objectName) { - return this.rawClient.recordServiceBulkGetRecord(vaultId, objectName).body(); - } - - /** - * Gets the specified records from a table. - */ - public V1BulkGetRecordResponse recordServiceBulkGetRecord( - String vaultId, String objectName, RecordServiceBulkGetRecordRequest request) { - return this.rawClient - .recordServiceBulkGetRecord(vaultId, objectName, request) - .body(); - } - - /** - * Gets the specified records from a table. - */ - public V1BulkGetRecordResponse recordServiceBulkGetRecord( - String vaultId, - String objectName, - RecordServiceBulkGetRecordRequest request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceBulkGetRecord(vaultId, objectName, request, requestOptions) - .body(); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public V1InsertRecordResponse recordServiceInsertRecord(String vaultId, String objectName) { - return this.rawClient.recordServiceInsertRecord(vaultId, objectName).body(); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public V1InsertRecordResponse recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request) { - return this.rawClient - .recordServiceInsertRecord(vaultId, objectName, request) - .body(); - } - - /** - * Inserts a record in the specified table.<br /><br />The time-to-live (TTL) for a transient field begins when the field value is set during record insertion.<br /><br />Columns that have a string data type and a uniqueness constraint accept strings up to 2500 characters. If an inserted string exceeds 2500 characters, the call returns a token insertion error. - */ - public V1InsertRecordResponse recordServiceInsertRecord( - String vaultId, String objectName, RecordServiceInsertRecordBody request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceInsertRecord(vaultId, objectName, request, requestOptions) - .body(); - } - - /** - * Deletes the specified records from a table. - */ - public V1BulkDeleteRecordResponse recordServiceBulkDeleteRecord(String vaultId, String objectName) { - return this.rawClient.recordServiceBulkDeleteRecord(vaultId, objectName).body(); - } - - /** - * Deletes the specified records from a table. - */ - public V1BulkDeleteRecordResponse recordServiceBulkDeleteRecord( - String vaultId, String objectName, RecordServiceBulkDeleteRecordBody request) { - return this.rawClient - .recordServiceBulkDeleteRecord(vaultId, objectName, request) - .body(); - } - - /** - * Deletes the specified records from a table. - */ - public V1BulkDeleteRecordResponse recordServiceBulkDeleteRecord( - String vaultId, - String objectName, - RecordServiceBulkDeleteRecordBody request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceBulkDeleteRecord(vaultId, objectName, request, requestOptions) - .body(); - } - - /** - * Returns the specified record from a table. - */ - public V1FieldRecords recordServiceGetRecord(String vaultId, String objectName, String id) { - return this.rawClient.recordServiceGetRecord(vaultId, objectName, id).body(); - } - - /** - * Returns the specified record from a table. - */ - public V1FieldRecords recordServiceGetRecord( - String vaultId, String objectName, String id, RecordServiceGetRecordRequest request) { - return this.rawClient - .recordServiceGetRecord(vaultId, objectName, id, request) - .body(); - } - - /** - * Returns the specified record from a table. - */ - public V1FieldRecords recordServiceGetRecord( - String vaultId, - String objectName, - String id, - RecordServiceGetRecordRequest request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceGetRecord(vaultId, objectName, id, request, requestOptions) - .body(); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public V1UpdateRecordResponse recordServiceUpdateRecord(String vaultId, String objectName, String id) { - return this.rawClient.recordServiceUpdateRecord(vaultId, objectName, id).body(); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public V1UpdateRecordResponse recordServiceUpdateRecord( - String vaultId, String objectName, String id, RecordServiceUpdateRecordBody request) { - return this.rawClient - .recordServiceUpdateRecord(vaultId, objectName, id, request) - .body(); - } - - /** - * Updates the specified record in a table.<br /><br />When you update a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.<br /><br />The time-to-live (TTL) for a transient field resets when the field value is updated. - */ - public V1UpdateRecordResponse recordServiceUpdateRecord( - String vaultId, - String objectName, - String id, - RecordServiceUpdateRecordBody request, - RequestOptions requestOptions) { - return this.rawClient - .recordServiceUpdateRecord(vaultId, objectName, id, request, requestOptions) - .body(); - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public V1DeleteRecordResponse recordServiceDeleteRecord(String vaultId, String objectName, String id) { - return this.rawClient.recordServiceDeleteRecord(vaultId, objectName, id).body(); - } - - /** - * Deletes the specified record from a table.<br /><br /><b>Note:</b> This method doesn't delete transient field tokens. Transient field values are available until they expire based on the fields' time-to-live (TTL) setting. - */ - public V1DeleteRecordResponse recordServiceDeleteRecord( - String vaultId, String objectName, String id, RequestOptions requestOptions) { - return this.rawClient - .recordServiceDeleteRecord(vaultId, objectName, id, requestOptions) - .body(); - } - - /** - * Uploads a file to the specified record. - */ - public V1UpdateRecordResponse fileServiceUploadFile( - String vaultId, String objectName, String id, Optional fileColumnName) { - return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName) - .body(); - } - - /** - * Uploads a file to the specified record. - */ - public V1UpdateRecordResponse fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request) { - return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request) - .body(); - } - - /** - * Uploads a file to the specified record. - */ - public V1UpdateRecordResponse fileServiceUploadFile( - String vaultId, - String objectName, - String id, - Optional fileColumnName, - FileServiceUploadFileRequest request, - RequestOptions requestOptions) { - return this.rawClient - .fileServiceUploadFile(vaultId, objectName, id, fileColumnName, request, requestOptions) - .body(); - } - - /** - * Deletes a file from the specified record. - */ - public V1DeleteFileResponse fileServiceDeleteFile(String vaultId, String tableName, String id, String columnName) { - return this.rawClient - .fileServiceDeleteFile(vaultId, tableName, id, columnName) - .body(); - } - - /** - * Deletes a file from the specified record. - */ - public V1DeleteFileResponse fileServiceDeleteFile( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - return this.rawClient - .fileServiceDeleteFile(vaultId, tableName, id, columnName, requestOptions) - .body(); - } - - /** - * Returns the anti-virus scan status of a file. - */ - public V1GetFileScanStatusResponse fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName) { - return this.rawClient - .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName) - .body(); - } - - /** - * Returns the anti-virus scan status of a file. - */ - public V1GetFileScanStatusResponse fileServiceGetFileScanStatus( - String vaultId, String tableName, String id, String columnName, RequestOptions requestOptions) { - return this.rawClient - .fileServiceGetFileScanStatus(vaultId, tableName, id, columnName, 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 deleted file mode 100644 index d1b64906..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/FileServiceUploadFileRequest.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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.databind.annotation.JsonDeserialize; -import com.skyflow.generated.rest.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = FileServiceUploadFileRequest.Builder.class) -public final class FileServiceUploadFileRequest { - private final Map additionalProperties; - - private FileServiceUploadFileRequest(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof FileServiceUploadFileRequest; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @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 { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(FileServiceUploadFileRequest other) { - return this; - } - - public FileServiceUploadFileRequest build() { - return new FileServiceUploadFileRequest(additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java deleted file mode 100644 index 33b92483..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBatchOperationBody.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * 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 com.skyflow.generated.rest.types.V1BatchRecord; -import com.skyflow.generated.rest.types.V1Byot; -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 = RecordServiceBatchOperationBody.Builder.class) -public final class RecordServiceBatchOperationBody { - private final Optional> records; - - private final Optional continueOnError; - - private final Optional byot; - - private final Map additionalProperties; - - private RecordServiceBatchOperationBody( - Optional> records, - Optional continueOnError, - Optional byot, - Map additionalProperties) { - this.records = records; - this.continueOnError = continueOnError; - this.byot = byot; - this.additionalProperties = additionalProperties; - } - - /** - * @return Record operations to perform. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - /** - * @return Continue performing operations on partial errors. - */ - @JsonProperty("continueOnError") - public Optional getContinueOnError() { - return continueOnError; - } - - @JsonProperty("byot") - public Optional getByot() { - return byot; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecordServiceBatchOperationBody && equalTo((RecordServiceBatchOperationBody) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecordServiceBatchOperationBody other) { - return records.equals(other.records) - && continueOnError.equals(other.continueOnError) - && byot.equals(other.byot); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records, this.continueOnError, this.byot); - } - - @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> records = Optional.empty(); - - private Optional continueOnError = Optional.empty(); - - private Optional byot = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecordServiceBatchOperationBody other) { - records(other.getRecords()); - continueOnError(other.getContinueOnError()); - byot(other.getByot()); - return this; - } - - /** - *

Record operations to perform.

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

Continue performing operations on partial errors.

- */ - @JsonSetter(value = "continueOnError", nulls = Nulls.SKIP) - public Builder continueOnError(Optional continueOnError) { - this.continueOnError = continueOnError; - return this; - } - - public Builder continueOnError(Boolean continueOnError) { - this.continueOnError = Optional.ofNullable(continueOnError); - return this; - } - - @JsonSetter(value = "byot", nulls = Nulls.SKIP) - public Builder byot(Optional byot) { - this.byot = byot; - return this; - } - - public Builder byot(V1Byot byot) { - this.byot = Optional.ofNullable(byot); - return this; - } - - public RecordServiceBatchOperationBody build() { - return new RecordServiceBatchOperationBody(records, continueOnError, byot, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java deleted file mode 100644 index b2c991f9..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkDeleteRecordBody.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * 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.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = RecordServiceBulkDeleteRecordBody.Builder.class) -public final class RecordServiceBulkDeleteRecordBody { - private final Optional> skyflowIds; - - private final Map additionalProperties; - - private RecordServiceBulkDeleteRecordBody( - Optional> skyflowIds, Map additionalProperties) { - this.skyflowIds = skyflowIds; - this.additionalProperties = additionalProperties; - } - - /** - * @return skyflow_id values of the records to delete. If * is specified, this operation deletes all records in the table. - */ - @JsonProperty("skyflow_ids") - public Optional> getSkyflowIds() { - return skyflowIds; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecordServiceBulkDeleteRecordBody && equalTo((RecordServiceBulkDeleteRecordBody) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecordServiceBulkDeleteRecordBody other) { - return skyflowIds.equals(other.skyflowIds); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.skyflowIds); - } - - @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> skyflowIds = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecordServiceBulkDeleteRecordBody other) { - skyflowIds(other.getSkyflowIds()); - return this; - } - - /** - *

skyflow_id values of the records to delete. If * is specified, this operation deletes all records in the table.

- */ - @JsonSetter(value = "skyflow_ids", nulls = Nulls.SKIP) - public Builder skyflowIds(Optional> skyflowIds) { - this.skyflowIds = skyflowIds; - return this; - } - - public Builder skyflowIds(List skyflowIds) { - this.skyflowIds = Optional.ofNullable(skyflowIds); - return this; - } - - public RecordServiceBulkDeleteRecordBody build() { - return new RecordServiceBulkDeleteRecordBody(skyflowIds, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java deleted file mode 100644 index f8cccf09..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceBulkGetRecordRequest.java +++ /dev/null @@ -1,413 +0,0 @@ -/** - * 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 com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestOrderBy; -import com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestRedaction; -import java.util.Collections; -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 = RecordServiceBulkGetRecordRequest.Builder.class) -public final class RecordServiceBulkGetRecordRequest { - private final Optional> skyflowIds; - - private final Optional> fields; - - private final Optional> columnValues; - - private final Optional redaction; - - private final Optional tokenization; - - private final Optional offset; - - private final Optional limit; - - private final Optional downloadUrl; - - private final Optional columnName; - - private final Optional orderBy; - - private final Map additionalProperties; - - private RecordServiceBulkGetRecordRequest( - Optional> skyflowIds, - Optional> fields, - Optional> columnValues, - Optional redaction, - Optional tokenization, - Optional offset, - Optional limit, - Optional downloadUrl, - Optional columnName, - Optional orderBy, - Map additionalProperties) { - this.skyflowIds = skyflowIds; - this.fields = fields; - this.columnValues = columnValues; - this.redaction = redaction; - this.tokenization = tokenization; - this.offset = offset; - this.limit = limit; - this.downloadUrl = downloadUrl; - this.columnName = columnName; - this.orderBy = orderBy; - this.additionalProperties = additionalProperties; - } - - /** - * @return skyflow_id values of the records to return, with one value per skyflow_ids URL parameter. For example, ?skyflow_ids=abc&skyflow_ids=123.<br /><br />If not specified, returns the first 25 records in the table. - */ - @JsonProperty("skyflow_ids") - public Optional> getSkyflowIds() { - return skyflowIds; - } - - /** - * @return Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields. - */ - @JsonProperty("fields") - public Optional> getFields() { - return fields; - } - - /** - * @return Column values of the records to return, with one value per column_values URL parameter. For example, ?column_values=abc&column_values=123.<br /><br />column_name is mandatory when providing column_values. If you use column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error. - */ - @JsonProperty("column_values") - public Optional> getColumnValues() { - return columnValues; - } - - /** - * @return Redaction level to enforce for the returned records. Subject to policies assigned to the API caller. - */ - @JsonProperty("redaction") - public Optional getRedaction() { - return redaction; - } - - /** - * @return If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified. - */ - @JsonProperty("tokenization") - public Optional getTokenization() { - return tokenization; - } - - /** - * @return Record position at which to start receiving data. - */ - @JsonProperty("offset") - public Optional getOffset() { - return offset; - } - - /** - * @return Number of record to return. Maximum 25. - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. - */ - @JsonProperty("downloadURL") - public Optional getDownloadUrl() { - return downloadUrl; - } - - /** - * @return Name of the column. It must be configured as unique in the schema. If you provide both column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error. - */ - @JsonProperty("column_name") - public Optional getColumnName() { - return columnName; - } - - /** - * @return Order to return records, based on skyflow_id values. To disable, set to NONE. - */ - @JsonProperty("order_by") - public Optional getOrderBy() { - return orderBy; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecordServiceBulkGetRecordRequest && equalTo((RecordServiceBulkGetRecordRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecordServiceBulkGetRecordRequest other) { - return skyflowIds.equals(other.skyflowIds) - && fields.equals(other.fields) - && columnValues.equals(other.columnValues) - && redaction.equals(other.redaction) - && tokenization.equals(other.tokenization) - && offset.equals(other.offset) - && limit.equals(other.limit) - && downloadUrl.equals(other.downloadUrl) - && columnName.equals(other.columnName) - && orderBy.equals(other.orderBy); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.skyflowIds, - this.fields, - this.columnValues, - this.redaction, - this.tokenization, - this.offset, - this.limit, - this.downloadUrl, - this.columnName, - this.orderBy); - } - - @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> skyflowIds = Optional.empty(); - - private Optional> fields = Optional.empty(); - - private Optional> columnValues = Optional.empty(); - - private Optional redaction = Optional.empty(); - - private Optional tokenization = Optional.empty(); - - private Optional offset = Optional.empty(); - - private Optional limit = Optional.empty(); - - private Optional downloadUrl = Optional.empty(); - - private Optional columnName = Optional.empty(); - - private Optional orderBy = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecordServiceBulkGetRecordRequest other) { - skyflowIds(other.getSkyflowIds()); - fields(other.getFields()); - columnValues(other.getColumnValues()); - redaction(other.getRedaction()); - tokenization(other.getTokenization()); - offset(other.getOffset()); - limit(other.getLimit()); - downloadUrl(other.getDownloadUrl()); - columnName(other.getColumnName()); - orderBy(other.getOrderBy()); - return this; - } - - /** - *

skyflow_id values of the records to return, with one value per skyflow_ids URL parameter. For example, ?skyflow_ids=abc&skyflow_ids=123.<br /><br />If not specified, returns the first 25 records in the table.

- */ - @JsonSetter(value = "skyflow_ids", nulls = Nulls.SKIP) - public Builder skyflowIds(Optional> skyflowIds) { - this.skyflowIds = skyflowIds; - return this; - } - - public Builder skyflowIds(List skyflowIds) { - this.skyflowIds = Optional.ofNullable(skyflowIds); - return this; - } - - public Builder skyflowIds(String skyflowIds) { - this.skyflowIds = Optional.of(Collections.singletonList(skyflowIds)); - return this; - } - - /** - *

Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields.

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

Column values of the records to return, with one value per column_values URL parameter. For example, ?column_values=abc&column_values=123.<br /><br />column_name is mandatory when providing column_values. If you use column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error.

- */ - @JsonSetter(value = "column_values", nulls = Nulls.SKIP) - public Builder columnValues(Optional> columnValues) { - this.columnValues = columnValues; - return this; - } - - public Builder columnValues(List columnValues) { - this.columnValues = Optional.ofNullable(columnValues); - return this; - } - - public Builder columnValues(String columnValues) { - this.columnValues = Optional.of(Collections.singletonList(columnValues)); - return this; - } - - /** - *

Redaction level to enforce for the returned records. Subject to policies assigned to the API caller.

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

If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified.

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

Record position at which to start receiving data.

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

Number of record to return. Maximum 25.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

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

Name of the column. It must be configured as unique in the schema. If you provide both column name or column value, you cannot use skyflow_ids. Passing either of these parameters with skyflow_ids returns an error.

- */ - @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; - } - - /** - *

Order to return records, based on skyflow_id values. To disable, set to NONE.

- */ - @JsonSetter(value = "order_by", nulls = Nulls.SKIP) - public Builder orderBy(Optional orderBy) { - this.orderBy = orderBy; - return this; - } - - public Builder orderBy(RecordServiceBulkGetRecordRequestOrderBy orderBy) { - this.orderBy = Optional.ofNullable(orderBy); - return this; - } - - public RecordServiceBulkGetRecordRequest build() { - return new RecordServiceBulkGetRecordRequest( - skyflowIds, - fields, - columnValues, - redaction, - tokenization, - offset, - limit, - downloadUrl, - columnName, - orderBy, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java deleted file mode 100644 index 0fa5319d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceGetRecordRequest.java +++ /dev/null @@ -1,202 +0,0 @@ -/** - * 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 com.skyflow.generated.rest.resources.records.types.RecordServiceGetRecordRequestRedaction; -import java.util.Collections; -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 = RecordServiceGetRecordRequest.Builder.class) -public final class RecordServiceGetRecordRequest { - private final Optional> fields; - - private final Optional redaction; - - private final Optional tokenization; - - private final Optional downloadUrl; - - private final Map additionalProperties; - - private RecordServiceGetRecordRequest( - Optional> fields, - Optional redaction, - Optional tokenization, - Optional downloadUrl, - Map additionalProperties) { - this.fields = fields; - this.redaction = redaction; - this.tokenization = tokenization; - this.downloadUrl = downloadUrl; - this.additionalProperties = additionalProperties; - } - - /** - * @return Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields. - */ - @JsonProperty("fields") - public Optional> getFields() { - return fields; - } - - /** - * @return Redaction level to enforce for the returned record. Subject to policies assigned to the API caller. - */ - @JsonProperty("redaction") - public Optional getRedaction() { - return redaction; - } - - /** - * @return If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified. - */ - @JsonProperty("tokenization") - public Optional getTokenization() { - return tokenization; - } - - /** - * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. - */ - @JsonProperty("downloadURL") - public Optional getDownloadUrl() { - return downloadUrl; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecordServiceGetRecordRequest && equalTo((RecordServiceGetRecordRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecordServiceGetRecordRequest other) { - return fields.equals(other.fields) - && redaction.equals(other.redaction) - && tokenization.equals(other.tokenization) - && downloadUrl.equals(other.downloadUrl); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.fields, this.redaction, this.tokenization, this.downloadUrl); - } - - @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> fields = Optional.empty(); - - private Optional redaction = Optional.empty(); - - private Optional tokenization = Optional.empty(); - - private Optional downloadUrl = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecordServiceGetRecordRequest other) { - fields(other.getFields()); - redaction(other.getRedaction()); - tokenization(other.getTokenization()); - downloadUrl(other.getDownloadUrl()); - return this; - } - - /** - *

Fields to return for the record, with one value per fields URL parameter. For example, ?fields=abc&fields=123.<br /><br />If not specified, returns all fields.

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

Redaction level to enforce for the returned record. Subject to policies assigned to the API caller.

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

If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

- */ - @JsonSetter(value = "downloadURL", nulls = Nulls.SKIP) - public Builder downloadUrl(Optional downloadUrl) { - this.downloadUrl = downloadUrl; - return this; - } - - public Builder downloadUrl(Boolean downloadUrl) { - this.downloadUrl = Optional.ofNullable(downloadUrl); - return this; - } - - public RecordServiceGetRecordRequest build() { - return new RecordServiceGetRecordRequest( - fields, redaction, tokenization, downloadUrl, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java deleted file mode 100644 index 4ac78692..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceInsertRecordBody.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * 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 com.skyflow.generated.rest.types.V1Byot; -import com.skyflow.generated.rest.types.V1FieldRecords; -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 = RecordServiceInsertRecordBody.Builder.class) -public final class RecordServiceInsertRecordBody { - private final Optional> records; - - private final Optional tokenization; - - private final Optional upsert; - - private final Optional homogeneous; - - private final Optional byot; - - private final Map additionalProperties; - - private RecordServiceInsertRecordBody( - Optional> records, - Optional tokenization, - Optional upsert, - Optional homogeneous, - Optional byot, - Map additionalProperties) { - this.records = records; - this.tokenization = tokenization; - this.upsert = upsert; - this.homogeneous = homogeneous; - this.byot = byot; - this.additionalProperties = additionalProperties; - } - - /** - * @return Record values and tokens. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - /** - * @return If true, this operation returns tokens for fields with tokenization enabled. - */ - @JsonProperty("tokenization") - public Optional getTokenization() { - return tokenization; - } - - /** - * @return Name of a unique column in the table. Uses upsert operations to check if a record exists based on the unique column's value. If a matching record exists, the record updates with the values you provide. If a matching record doesn't exist, the upsert operation inserts a new record.<br /><br />When you upsert a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed. - */ - @JsonProperty("upsert") - public Optional getUpsert() { - return upsert; - } - - /** - * @return If true, this operation mandates that all the records have the same fields. This parameter does not work with upsert. - */ - @JsonProperty("homogeneous") - public Optional getHomogeneous() { - return homogeneous; - } - - @JsonProperty("byot") - public Optional getByot() { - return byot; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecordServiceInsertRecordBody && equalTo((RecordServiceInsertRecordBody) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecordServiceInsertRecordBody other) { - return records.equals(other.records) - && tokenization.equals(other.tokenization) - && upsert.equals(other.upsert) - && homogeneous.equals(other.homogeneous) - && byot.equals(other.byot); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records, this.tokenization, this.upsert, this.homogeneous, this.byot); - } - - @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> records = Optional.empty(); - - private Optional tokenization = Optional.empty(); - - private Optional upsert = Optional.empty(); - - private Optional homogeneous = Optional.empty(); - - private Optional byot = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecordServiceInsertRecordBody other) { - records(other.getRecords()); - tokenization(other.getTokenization()); - upsert(other.getUpsert()); - homogeneous(other.getHomogeneous()); - byot(other.getByot()); - return this; - } - - /** - *

Record values and tokens.

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

If true, this operation returns tokens for fields with tokenization enabled.

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

Name of a unique column in the table. Uses upsert operations to check if a record exists based on the unique column's value. If a matching record exists, the record updates with the values you provide. If a matching record doesn't exist, the upsert operation inserts a new record.<br /><br />When you upsert a field, include the entire contents you want the field to store. For JSON fields, include all nested fields and values. If a nested field isn't included, it's removed.

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

If true, this operation mandates that all the records have the same fields. This parameter does not work with upsert.

- */ - @JsonSetter(value = "homogeneous", nulls = Nulls.SKIP) - public Builder homogeneous(Optional homogeneous) { - this.homogeneous = homogeneous; - return this; - } - - public Builder homogeneous(Boolean homogeneous) { - this.homogeneous = Optional.ofNullable(homogeneous); - return this; - } - - @JsonSetter(value = "byot", nulls = Nulls.SKIP) - public Builder byot(Optional byot) { - this.byot = byot; - return this; - } - - public Builder byot(V1Byot byot) { - this.byot = Optional.ofNullable(byot); - return this; - } - - public RecordServiceInsertRecordBody build() { - return new RecordServiceInsertRecordBody( - records, tokenization, upsert, homogeneous, byot, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java b/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java deleted file mode 100644 index 19e0ae23..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/requests/RecordServiceUpdateRecordBody.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * 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 com.skyflow.generated.rest.types.V1Byot; -import com.skyflow.generated.rest.types.V1FieldRecords; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = RecordServiceUpdateRecordBody.Builder.class) -public final class RecordServiceUpdateRecordBody { - private final Optional record; - - private final Optional tokenization; - - private final Optional byot; - - private final Map additionalProperties; - - private RecordServiceUpdateRecordBody( - Optional record, - Optional tokenization, - Optional byot, - Map additionalProperties) { - this.record = record; - this.tokenization = tokenization; - this.byot = byot; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("record") - public Optional getRecord() { - return record; - } - - /** - * @return If true, this operation returns tokens for fields with tokenization enabled. - */ - @JsonProperty("tokenization") - public Optional getTokenization() { - return tokenization; - } - - @JsonProperty("byot") - public Optional getByot() { - return byot; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecordServiceUpdateRecordBody && equalTo((RecordServiceUpdateRecordBody) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecordServiceUpdateRecordBody other) { - return record.equals(other.record) && tokenization.equals(other.tokenization) && byot.equals(other.byot); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.record, this.tokenization, this.byot); - } - - @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 record = Optional.empty(); - - private Optional tokenization = Optional.empty(); - - private Optional byot = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecordServiceUpdateRecordBody other) { - record(other.getRecord()); - tokenization(other.getTokenization()); - byot(other.getByot()); - return this; - } - - @JsonSetter(value = "record", nulls = Nulls.SKIP) - public Builder record(Optional record) { - this.record = record; - return this; - } - - public Builder record(V1FieldRecords record) { - this.record = Optional.ofNullable(record); - return this; - } - - /** - *

If true, this operation returns tokens for fields with tokenization enabled.

- */ - @JsonSetter(value = "tokenization", nulls = Nulls.SKIP) - public Builder tokenization(Optional tokenization) { - this.tokenization = tokenization; - return this; - } - - public Builder tokenization(Boolean tokenization) { - this.tokenization = Optional.ofNullable(tokenization); - return this; - } - - @JsonSetter(value = "byot", nulls = Nulls.SKIP) - public Builder byot(Optional byot) { - this.byot = byot; - return this; - } - - public Builder byot(V1Byot byot) { - this.byot = Optional.ofNullable(byot); - return this; - } - - public RecordServiceUpdateRecordBody build() { - return new RecordServiceUpdateRecordBody(record, tokenization, byot, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java b/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java deleted file mode 100644 index 2563652f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestOrderBy.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum RecordServiceBulkGetRecordRequestOrderBy { - ASCENDING("ASCENDING"), - - DESCENDING("DESCENDING"), - - NONE("NONE"); - - private final String value; - - RecordServiceBulkGetRecordRequestOrderBy(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/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java b/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java deleted file mode 100644 index b20f2541..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceBulkGetRecordRequestRedaction.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum RecordServiceBulkGetRecordRequestRedaction { - DEFAULT("DEFAULT"), - - REDACTED("REDACTED"), - - MASKED("MASKED"), - - PLAIN_TEXT("PLAIN_TEXT"); - - private final String value; - - RecordServiceBulkGetRecordRequestRedaction(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/resources/records/types/RecordServiceGetRecordRequestRedaction.java b/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java deleted file mode 100644 index 468e3edd..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/records/types/RecordServiceGetRecordRequestRedaction.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.records.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum RecordServiceGetRecordRequestRedaction { - DEFAULT("DEFAULT"), - - REDACTED("REDACTED"), - - MASKED("MASKED"), - - PLAIN_TEXT("PLAIN_TEXT"); - - private final String value; - - RecordServiceGetRecordRequestRedaction(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/resources/strings/AsyncRawStringsClient.java b/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java deleted file mode 100644 index 0dc804b2..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncRawStringsClient.java +++ /dev/null @@ -1,217 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings; - -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.strings.requests.DeidentifyStringRequest; -import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; -import com.skyflow.generated.rest.types.DeidentifyStringResponse; -import com.skyflow.generated.rest.types.ErrorResponse; -import com.skyflow.generated.rest.types.ReidentifyStringResponse; -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 AsyncRawStringsClient { - protected final ClientOptions clientOptions; - - public AsyncRawStringsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * De-identifies sensitive data from a string. - */ - public CompletableFuture> deidentifyString( - DeidentifyStringRequest request) { - return deidentifyString(request, null); - } - - /** - * De-identifies sensitive data from a string. - */ - public CompletableFuture> deidentifyString( - DeidentifyStringRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/string") - .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(), DeidentifyStringResponse.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; - } - - /** - * Re-identifies tokens in a string. - */ - public CompletableFuture> reidentifyString( - ReidentifyStringRequest request) { - return reidentifyString(request, null); - } - - /** - * Re-identifies tokens in a string. - */ - public CompletableFuture> reidentifyString( - ReidentifyStringRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/reidentify/string") - .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(), ReidentifyStringResponse.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/strings/AsyncStringsClient.java b/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java deleted file mode 100644 index 86e5cd0d..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/AsyncStringsClient.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; -import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; -import com.skyflow.generated.rest.types.DeidentifyStringResponse; -import com.skyflow.generated.rest.types.ReidentifyStringResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncStringsClient { - protected final ClientOptions clientOptions; - - private final AsyncRawStringsClient rawClient; - - public AsyncStringsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawStringsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawStringsClient withRawResponse() { - return this.rawClient; - } - - /** - * De-identifies sensitive data from a string. - */ - public CompletableFuture deidentifyString(DeidentifyStringRequest request) { - return this.rawClient.deidentifyString(request).thenApply(response -> response.body()); - } - - /** - * De-identifies sensitive data from a string. - */ - public CompletableFuture deidentifyString( - DeidentifyStringRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyString(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Re-identifies tokens in a string. - */ - public CompletableFuture reidentifyString(ReidentifyStringRequest request) { - return this.rawClient.reidentifyString(request).thenApply(response -> response.body()); - } - - /** - * Re-identifies tokens in a string. - */ - public CompletableFuture reidentifyString( - ReidentifyStringRequest request, RequestOptions requestOptions) { - return this.rawClient.reidentifyString(request, requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java b/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java deleted file mode 100644 index 0e1fbad0..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/RawStringsClient.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings; - -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.strings.requests.DeidentifyStringRequest; -import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; -import com.skyflow.generated.rest.types.DeidentifyStringResponse; -import com.skyflow.generated.rest.types.ErrorResponse; -import com.skyflow.generated.rest.types.ReidentifyStringResponse; -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 RawStringsClient { - protected final ClientOptions clientOptions; - - public RawStringsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * De-identifies sensitive data from a string. - */ - public ApiClientHttpResponse deidentifyString(DeidentifyStringRequest request) { - return deidentifyString(request, null); - } - - /** - * De-identifies sensitive data from a string. - */ - public ApiClientHttpResponse deidentifyString( - DeidentifyStringRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/deidentify/string") - .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(), DeidentifyStringResponse.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); - } - } - - /** - * Re-identifies tokens in a string. - */ - public ApiClientHttpResponse reidentifyString(ReidentifyStringRequest request) { - return reidentifyString(request, null); - } - - /** - * Re-identifies tokens in a string. - */ - public ApiClientHttpResponse reidentifyString( - ReidentifyStringRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/detect/reidentify/string") - .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(), ReidentifyStringResponse.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/strings/StringsClient.java b/src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java deleted file mode 100644 index 153efe07..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/StringsClient.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.strings.requests.DeidentifyStringRequest; -import com.skyflow.generated.rest.resources.strings.requests.ReidentifyStringRequest; -import com.skyflow.generated.rest.types.DeidentifyStringResponse; -import com.skyflow.generated.rest.types.ReidentifyStringResponse; - -public class StringsClient { - protected final ClientOptions clientOptions; - - private final RawStringsClient rawClient; - - public StringsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawStringsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawStringsClient withRawResponse() { - return this.rawClient; - } - - /** - * De-identifies sensitive data from a string. - */ - public DeidentifyStringResponse deidentifyString(DeidentifyStringRequest request) { - return this.rawClient.deidentifyString(request).body(); - } - - /** - * De-identifies sensitive data from a string. - */ - public DeidentifyStringResponse deidentifyString(DeidentifyStringRequest request, RequestOptions requestOptions) { - return this.rawClient.deidentifyString(request, requestOptions).body(); - } - - /** - * Re-identifies tokens in a string. - */ - public ReidentifyStringResponse reidentifyString(ReidentifyStringRequest request) { - return this.rawClient.reidentifyString(request).body(); - } - - /** - * Re-identifies tokens in a string. - */ - public ReidentifyStringResponse reidentifyString(ReidentifyStringRequest request, RequestOptions requestOptions) { - return this.rawClient.reidentifyString(request, requestOptions).body(); - } -} 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 deleted file mode 100644 index 4a74fcba..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/requests/DeidentifyStringRequest.java +++ /dev/null @@ -1,309 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings.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.EntityType; -import com.skyflow.generated.rest.types.TokenType; -import com.skyflow.generated.rest.types.Transformations; -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 = DeidentifyStringRequest.Builder.class) -public final class DeidentifyStringRequest { - private final String vaultId; - - private final String text; - - private final Optional> entityTypes; - - private final Optional tokenType; - - private final Optional> allowRegex; - - private final Optional> restrictRegex; - - private final Optional transformations; - - private final Map additionalProperties; - - private DeidentifyStringRequest( - String vaultId, - String text, - Optional> entityTypes, - Optional tokenType, - Optional> allowRegex, - Optional> restrictRegex, - Optional transformations, - Map additionalProperties) { - this.vaultId = vaultId; - this.text = text; - this.entityTypes = entityTypes; - this.tokenType = tokenType; - this.allowRegex = allowRegex; - this.restrictRegex = restrictRegex; - this.transformations = transformations; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return String to de-identify. - */ - @JsonProperty("text") - public String getText() { - return text; - } - - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @JsonProperty("token_type") - public Optional getTokenType() { - return tokenType; - } - - @JsonProperty("allow_regex") - public Optional> getAllowRegex() { - return allowRegex; - } - - @JsonProperty("restrict_regex") - public Optional> getRestrictRegex() { - return restrictRegex; - } - - @JsonProperty("transformations") - public Optional getTransformations() { - return transformations; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyStringRequest && equalTo((DeidentifyStringRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyStringRequest other) { - return vaultId.equals(other.vaultId) - && text.equals(other.text) - && entityTypes.equals(other.entityTypes) - && tokenType.equals(other.tokenType) - && allowRegex.equals(other.allowRegex) - && restrictRegex.equals(other.restrictRegex) - && transformations.equals(other.transformations); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.vaultId, - this.text, - this.entityTypes, - this.tokenType, - this.allowRegex, - this.restrictRegex, - this.transformations); - } - - @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(DeidentifyStringRequest other); - } - - public interface TextStage { - /** - * String to de-identify. - */ - _FinalStage text(@NotNull String text); - } - - public interface _FinalStage { - DeidentifyStringRequest build(); - - _FinalStage entityTypes(Optional> entityTypes); - - _FinalStage entityTypes(List entityTypes); - - _FinalStage tokenType(Optional tokenType); - - _FinalStage tokenType(TokenType tokenType); - - _FinalStage allowRegex(Optional> allowRegex); - - _FinalStage allowRegex(List allowRegex); - - _FinalStage restrictRegex(Optional> restrictRegex); - - _FinalStage restrictRegex(List restrictRegex); - - _FinalStage transformations(Optional transformations); - - _FinalStage transformations(Transformations transformations); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VaultIdStage, TextStage, _FinalStage { - private String vaultId; - - private String text; - - private Optional transformations = Optional.empty(); - - private Optional> restrictRegex = Optional.empty(); - - private Optional> allowRegex = Optional.empty(); - - private Optional tokenType = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyStringRequest other) { - vaultId(other.getVaultId()); - text(other.getText()); - entityTypes(other.getEntityTypes()); - tokenType(other.getTokenType()); - allowRegex(other.getAllowRegex()); - restrictRegex(other.getRestrictRegex()); - transformations(other.getTransformations()); - 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; - } - - /** - * String to de-identify.

String to de-identify.

- * @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; - } - - @java.lang.Override - public _FinalStage transformations(Transformations transformations) { - this.transformations = Optional.ofNullable(transformations); - return this; - } - - @java.lang.Override - @JsonSetter(value = "transformations", nulls = Nulls.SKIP) - public _FinalStage transformations(Optional transformations) { - this.transformations = transformations; - return this; - } - - @java.lang.Override - public _FinalStage restrictRegex(List restrictRegex) { - this.restrictRegex = Optional.ofNullable(restrictRegex); - return this; - } - - @java.lang.Override - @JsonSetter(value = "restrict_regex", nulls = Nulls.SKIP) - public _FinalStage restrictRegex(Optional> restrictRegex) { - this.restrictRegex = restrictRegex; - return this; - } - - @java.lang.Override - public _FinalStage allowRegex(List allowRegex) { - this.allowRegex = Optional.ofNullable(allowRegex); - return this; - } - - @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 tokenType(TokenType tokenType) { - this.tokenType = Optional.ofNullable(tokenType); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token_type", nulls = Nulls.SKIP) - public _FinalStage tokenType(Optional tokenType) { - this.tokenType = tokenType; - return this; - } - - @java.lang.Override - public _FinalStage entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public _FinalStage entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - @java.lang.Override - public DeidentifyStringRequest build() { - return new DeidentifyStringRequest( - vaultId, - text, - entityTypes, - tokenType, - allowRegex, - restrictRegex, - transformations, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java b/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java deleted file mode 100644 index e61cb5a2..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/requests/ReidentifyStringRequest.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings.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.strings.types.ReidentifyStringRequestFormat; -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 = ReidentifyStringRequest.Builder.class) -public final class ReidentifyStringRequest { - private final String text; - - private final String vaultId; - - private final Optional format; - - private final Map additionalProperties; - - private ReidentifyStringRequest( - String text, - String vaultId, - Optional format, - Map additionalProperties) { - this.text = text; - this.vaultId = vaultId; - this.format = format; - this.additionalProperties = additionalProperties; - } - - /** - * @return String to re-identify. - */ - @JsonProperty("text") - public String getText() { - return text; - } - - /** - * @return ID of the vault where the entities are stored. - */ - @JsonProperty("vault_id") - public String getVaultId() { - return vaultId; - } - - /** - * @return Mapping of perferred 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 ReidentifyStringRequest && equalTo((ReidentifyStringRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ReidentifyStringRequest other) { - return text.equals(other.text) && vaultId.equals(other.vaultId) && format.equals(other.format); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.text, this.vaultId, this.format); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TextStage builder() { - return new Builder(); - } - - public interface TextStage { - /** - * String to re-identify. - */ - VaultIdStage text(@NotNull String text); - - Builder from(ReidentifyStringRequest other); - } - - public interface VaultIdStage { - /** - * ID of the vault where the entities are stored. - */ - _FinalStage vaultId(@NotNull String vaultId); - } - - public interface _FinalStage { - ReidentifyStringRequest build(); - - /** - *

Mapping of perferred 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(ReidentifyStringRequestFormat format); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TextStage, VaultIdStage, _FinalStage { - private String text; - - private String vaultId; - - private Optional format = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ReidentifyStringRequest other) { - text(other.getText()); - vaultId(other.getVaultId()); - format(other.getFormat()); - return this; - } - - /** - * String to re-identify.

String to re-identify.

- * @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 where the entities are stored.

ID of the vault where the entities are stored.

- * @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; - } - - /** - *

Mapping of perferred 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(ReidentifyStringRequestFormat format) { - this.format = Optional.ofNullable(format); - return this; - } - - /** - *

Mapping of perferred 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 ReidentifyStringRequest build() { - return new ReidentifyStringRequest(text, vaultId, format, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java b/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java deleted file mode 100644 index 68c5209f..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/strings/types/ReidentifyStringRequestFormat.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.strings.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 = ReidentifyStringRequestFormat.Builder.class) -public final class ReidentifyStringRequestFormat { - private final Optional> redacted; - - private final Optional> masked; - - private final Optional> plaintext; - - private final Map additionalProperties; - - private ReidentifyStringRequestFormat( - 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 ReidentifyStringRequestFormat && equalTo((ReidentifyStringRequestFormat) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ReidentifyStringRequestFormat 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(ReidentifyStringRequestFormat 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 ReidentifyStringRequestFormat build() { - return new ReidentifyStringRequestFormat(redacted, masked, plaintext, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java b/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java deleted file mode 100644 index fbf69580..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncRawTokensClient.java +++ /dev/null @@ -1,206 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.tokens; - -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.NotFoundError; -import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; -import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.V1DetokenizeResponse; -import com.skyflow.generated.rest.types.V1TokenizeResponse; -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 AsyncRawTokensClient { - protected final ClientOptions clientOptions; - - public AsyncRawTokensClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns records that correspond to the specified tokens. - */ - public CompletableFuture> recordServiceDetokenize(String vaultId) { - return recordServiceDetokenize(vaultId, V1DetokenizePayload.builder().build()); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public CompletableFuture> recordServiceDetokenize( - String vaultId, V1DetokenizePayload request) { - return recordServiceDetokenize(vaultId, request, null); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public CompletableFuture> recordServiceDetokenize( - String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegments("detokenize") - .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(), V1DetokenizeResponse.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; - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public CompletableFuture> recordServiceTokenize(String vaultId) { - return recordServiceTokenize(vaultId, V1TokenizePayload.builder().build()); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public CompletableFuture> recordServiceTokenize( - String vaultId, V1TokenizePayload request) { - return recordServiceTokenize(vaultId, request, null); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public CompletableFuture> recordServiceTokenize( - String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegments("tokenize") - .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(), V1TokenizeResponse.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/tokens/AsyncTokensClient.java b/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java deleted file mode 100644 index 26d5ea05..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/tokens/AsyncTokensClient.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.tokens; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; -import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.V1DetokenizeResponse; -import com.skyflow.generated.rest.types.V1TokenizeResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncTokensClient { - protected final ClientOptions clientOptions; - - private final AsyncRawTokensClient rawClient; - - public AsyncTokensClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawTokensClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawTokensClient withRawResponse() { - return this.rawClient; - } - - /** - * Returns records that correspond to the specified tokens. - */ - public CompletableFuture recordServiceDetokenize(String vaultId) { - return this.rawClient.recordServiceDetokenize(vaultId).thenApply(response -> response.body()); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public CompletableFuture recordServiceDetokenize( - String vaultId, V1DetokenizePayload request) { - return this.rawClient.recordServiceDetokenize(vaultId, request).thenApply(response -> response.body()); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public CompletableFuture recordServiceDetokenize( - String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceDetokenize(vaultId, request, requestOptions) - .thenApply(response -> response.body()); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public CompletableFuture recordServiceTokenize(String vaultId) { - return this.rawClient.recordServiceTokenize(vaultId).thenApply(response -> response.body()); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public CompletableFuture recordServiceTokenize(String vaultId, V1TokenizePayload request) { - return this.rawClient.recordServiceTokenize(vaultId, request).thenApply(response -> response.body()); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public CompletableFuture recordServiceTokenize( - String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceTokenize(vaultId, request, requestOptions) - .thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java b/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java deleted file mode 100644 index 5ed17d28..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/tokens/RawTokensClient.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.tokens; - -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.NotFoundError; -import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; -import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.V1DetokenizeResponse; -import com.skyflow.generated.rest.types.V1TokenizeResponse; -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 RawTokensClient { - protected final ClientOptions clientOptions; - - public RawTokensClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns records that correspond to the specified tokens. - */ - public ApiClientHttpResponse recordServiceDetokenize(String vaultId) { - return recordServiceDetokenize(vaultId, V1DetokenizePayload.builder().build()); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public ApiClientHttpResponse recordServiceDetokenize( - String vaultId, V1DetokenizePayload request) { - return recordServiceDetokenize(vaultId, request, null); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public ApiClientHttpResponse recordServiceDetokenize( - String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegments("detokenize") - .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(), V1DetokenizeResponse.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); - } - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public ApiClientHttpResponse recordServiceTokenize(String vaultId) { - return recordServiceTokenize(vaultId, V1TokenizePayload.builder().build()); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public ApiClientHttpResponse recordServiceTokenize(String vaultId, V1TokenizePayload request) { - return recordServiceTokenize(vaultId, request, null); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public ApiClientHttpResponse recordServiceTokenize( - String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("v1/vaults") - .addPathSegment(vaultId) - .addPathSegments("tokenize") - .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(), V1TokenizeResponse.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/tokens/TokensClient.java b/src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java deleted file mode 100644 index 8b0e7e40..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/tokens/TokensClient.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.tokens; - -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; -import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.V1DetokenizeResponse; -import com.skyflow.generated.rest.types.V1TokenizeResponse; - -public class TokensClient { - protected final ClientOptions clientOptions; - - private final RawTokensClient rawClient; - - public TokensClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawTokensClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawTokensClient withRawResponse() { - return this.rawClient; - } - - /** - * Returns records that correspond to the specified tokens. - */ - public V1DetokenizeResponse recordServiceDetokenize(String vaultId) { - return this.rawClient.recordServiceDetokenize(vaultId).body(); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public V1DetokenizeResponse recordServiceDetokenize(String vaultId, V1DetokenizePayload request) { - return this.rawClient.recordServiceDetokenize(vaultId, request).body(); - } - - /** - * Returns records that correspond to the specified tokens. - */ - public V1DetokenizeResponse recordServiceDetokenize( - String vaultId, V1DetokenizePayload request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceDetokenize(vaultId, request, requestOptions) - .body(); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public V1TokenizeResponse recordServiceTokenize(String vaultId) { - return this.rawClient.recordServiceTokenize(vaultId).body(); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public V1TokenizeResponse recordServiceTokenize(String vaultId, V1TokenizePayload request) { - return this.rawClient.recordServiceTokenize(vaultId, request).body(); - } - - /** - * Returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization.<br /><br /><b>Note:</b> This endpoint doesn't insert records—it returns tokens for existing values. To insert records and tokenize that new record's values, see <a href='#RecordService_InsertRecord'>Insert Record</a> and the tokenization parameter. - */ - public V1TokenizeResponse recordServiceTokenize( - String vaultId, V1TokenizePayload request, RequestOptions requestOptions) { - return this.rawClient - .recordServiceTokenize(vaultId, request, requestOptions) - .body(); - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java b/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java deleted file mode 100644 index 1d3cb407..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1DetokenizePayload.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.tokens.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.V1DetokenizeRecordRequest; -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 = V1DetokenizePayload.Builder.class) -public final class V1DetokenizePayload { - private final Optional> detokenizationParameters; - - private final Optional downloadUrl; - - private final Optional continueOnError; - - private final Map additionalProperties; - - private V1DetokenizePayload( - Optional> detokenizationParameters, - Optional downloadUrl, - Optional continueOnError, - Map additionalProperties) { - this.detokenizationParameters = detokenizationParameters; - this.downloadUrl = downloadUrl; - this.continueOnError = continueOnError; - this.additionalProperties = additionalProperties; - } - - /** - * @return Detokenization details. - */ - @JsonProperty("detokenizationParameters") - public Optional> getDetokenizationParameters() { - return detokenizationParameters; - } - - /** - * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. - */ - @JsonProperty("downloadURL") - public Optional getDownloadUrl() { - return downloadUrl; - } - - /** - * @return If true, the detokenization request continues even if an error occurs. - */ - @JsonProperty("continueOnError") - public Optional getContinueOnError() { - return continueOnError; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetokenizePayload && equalTo((V1DetokenizePayload) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetokenizePayload other) { - return detokenizationParameters.equals(other.detokenizationParameters) - && downloadUrl.equals(other.downloadUrl) - && continueOnError.equals(other.continueOnError); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.detokenizationParameters, this.downloadUrl, this.continueOnError); - } - - @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> detokenizationParameters = Optional.empty(); - - private Optional downloadUrl = Optional.empty(); - - private Optional continueOnError = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetokenizePayload other) { - detokenizationParameters(other.getDetokenizationParameters()); - downloadUrl(other.getDownloadUrl()); - continueOnError(other.getContinueOnError()); - return this; - } - - /** - *

Detokenization details.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

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

If true, the detokenization request continues even if an error occurs.

- */ - @JsonSetter(value = "continueOnError", nulls = Nulls.SKIP) - public Builder continueOnError(Optional continueOnError) { - this.continueOnError = continueOnError; - return this; - } - - public Builder continueOnError(Boolean continueOnError) { - this.continueOnError = Optional.ofNullable(continueOnError); - return this; - } - - public V1DetokenizePayload build() { - return new V1DetokenizePayload( - detokenizationParameters, downloadUrl, continueOnError, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java b/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java deleted file mode 100644 index 30bdde6a..00000000 --- a/src/main/java/com/skyflow/generated/rest/resources/tokens/requests/V1TokenizePayload.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.rest.resources.tokens.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.V1TokenizeRecordRequest; -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 = V1TokenizePayload.Builder.class) -public final class V1TokenizePayload { - private final Optional> tokenizationParameters; - - private final Map additionalProperties; - - private V1TokenizePayload( - Optional> tokenizationParameters, Map additionalProperties) { - this.tokenizationParameters = tokenizationParameters; - this.additionalProperties = additionalProperties; - } - - /** - * @return Tokenization details. - */ - @JsonProperty("tokenizationParameters") - public Optional> getTokenizationParameters() { - return tokenizationParameters; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1TokenizePayload && equalTo((V1TokenizePayload) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1TokenizePayload other) { - return tokenizationParameters.equals(other.tokenizationParameters); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tokenizationParameters); - } - - @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> tokenizationParameters = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1TokenizePayload other) { - tokenizationParameters(other.getTokenizationParameters()); - return this; - } - - /** - *

Tokenization details.

- */ - @JsonSetter(value = "tokenizationParameters", nulls = Nulls.SKIP) - public Builder tokenizationParameters(Optional> tokenizationParameters) { - this.tokenizationParameters = tokenizationParameters; - return this; - } - - public Builder tokenizationParameters(List tokenizationParameters) { - this.tokenizationParameters = Optional.ofNullable(tokenizationParameters); - return this; - } - - public V1TokenizePayload build() { - return new V1TokenizePayload(tokenizationParameters, additionalProperties); - } - } -} 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/AuditEventAuditResourceType.java b/src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java deleted file mode 100644 index 4264996a..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AuditEventAuditResourceType.java +++ /dev/null @@ -1,80 +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 AuditEventAuditResourceType { - NONE_API("NONE_API"), - - ACCOUNT("ACCOUNT"), - - AUDIT("AUDIT"), - - BASE_DATA_TYPE("BASE_DATA_TYPE"), - - FIELD_TEMPLATE("FIELD_TEMPLATE"), - - FILE("FILE"), - - KEY("KEY"), - - POLICY("POLICY"), - - PROTO_PARSE("PROTO_PARSE"), - - RECORD("RECORD"), - - ROLE("ROLE"), - - RULE("RULE"), - - SECRET("SECRET"), - - SERVICE_ACCOUNT("SERVICE_ACCOUNT"), - - TOKEN("TOKEN"), - - USER("USER"), - - VAULT("VAULT"), - - VAULT_TEMPLATE("VAULT_TEMPLATE"), - - WORKSPACE("WORKSPACE"), - - TABLE("TABLE"), - - POLICY_TEMPLATE("POLICY_TEMPLATE"), - - MEMBER("MEMBER"), - - TAG("TAG"), - - CONNECTION("CONNECTION"), - - MIGRATION("MIGRATION"), - - SCHEDULED_JOB("SCHEDULED_JOB"), - - JOB("JOB"), - - COLUMN_NAME("COLUMN_NAME"), - - NETWORK_TOKEN("NETWORK_TOKEN"), - - SUBSCRIPTION("SUBSCRIPTION"); - - private final String value; - - AuditEventAuditResourceType(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/AuditEventContext.java b/src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java deleted file mode 100644 index 2a5c104a..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AuditEventContext.java +++ /dev/null @@ -1,440 +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 = AuditEventContext.Builder.class) -public final class AuditEventContext { - private final Optional changeId; - - private final Optional requestId; - - private final Optional traceId; - - private final Optional sessionId; - - private final Optional actor; - - private final Optional actorType; - - private final Optional accessType; - - private final Optional ipAddress; - - private final Optional origin; - - private final Optional authMode; - - private final Optional jwtId; - - private final Optional bearerTokenContextId; - - private final Map additionalProperties; - - private AuditEventContext( - Optional changeId, - Optional requestId, - Optional traceId, - Optional sessionId, - Optional actor, - Optional actorType, - Optional accessType, - Optional ipAddress, - Optional origin, - Optional authMode, - Optional jwtId, - Optional bearerTokenContextId, - Map additionalProperties) { - this.changeId = changeId; - this.requestId = requestId; - this.traceId = traceId; - this.sessionId = sessionId; - this.actor = actor; - this.actorType = actorType; - this.accessType = accessType; - this.ipAddress = ipAddress; - this.origin = origin; - this.authMode = authMode; - this.jwtId = jwtId; - this.bearerTokenContextId = bearerTokenContextId; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID for the audit event. - */ - @JsonProperty("changeID") - public Optional getChangeId() { - return changeId; - } - - /** - * @return ID for the request that caused the event. - */ - @JsonProperty("requestID") - public Optional getRequestId() { - return requestId; - } - - /** - * @return ID for the request set by the service that received the request. - */ - @JsonProperty("traceID") - public Optional getTraceId() { - return traceId; - } - - /** - * @return ID for the session in which the request was sent. - */ - @JsonProperty("sessionID") - public Optional getSessionId() { - return sessionId; - } - - /** - * @return Member who sent the request. Depending on actorType, this may be a user ID or a service account ID. - */ - @JsonProperty("actor") - public Optional getActor() { - return actor; - } - - @JsonProperty("actorType") - public Optional getActorType() { - return actorType; - } - - @JsonProperty("accessType") - public Optional getAccessType() { - return accessType; - } - - /** - * @return IP Address of the client that made the request. - */ - @JsonProperty("ipAddress") - public Optional getIpAddress() { - return ipAddress; - } - - /** - * @return HTTP Origin request header (including scheme, hostname, and port) of the request. - */ - @JsonProperty("origin") - public Optional getOrigin() { - return origin; - } - - @JsonProperty("authMode") - public Optional getAuthMode() { - return authMode; - } - - /** - * @return ID of the JWT token. - */ - @JsonProperty("jwtID") - public Optional getJwtId() { - return jwtId; - } - - /** - * @return Embedded User Context. - */ - @JsonProperty("bearerTokenContextID") - public Optional getBearerTokenContextId() { - return bearerTokenContextId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditEventContext && equalTo((AuditEventContext) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AuditEventContext other) { - return changeId.equals(other.changeId) - && requestId.equals(other.requestId) - && traceId.equals(other.traceId) - && sessionId.equals(other.sessionId) - && actor.equals(other.actor) - && actorType.equals(other.actorType) - && accessType.equals(other.accessType) - && ipAddress.equals(other.ipAddress) - && origin.equals(other.origin) - && authMode.equals(other.authMode) - && jwtId.equals(other.jwtId) - && bearerTokenContextId.equals(other.bearerTokenContextId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.changeId, - this.requestId, - this.traceId, - this.sessionId, - this.actor, - this.actorType, - this.accessType, - this.ipAddress, - this.origin, - this.authMode, - this.jwtId, - this.bearerTokenContextId); - } - - @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 changeId = Optional.empty(); - - private Optional requestId = Optional.empty(); - - private Optional traceId = Optional.empty(); - - private Optional sessionId = Optional.empty(); - - private Optional actor = Optional.empty(); - - private Optional actorType = Optional.empty(); - - private Optional accessType = Optional.empty(); - - private Optional ipAddress = Optional.empty(); - - private Optional origin = Optional.empty(); - - private Optional authMode = Optional.empty(); - - private Optional jwtId = Optional.empty(); - - private Optional bearerTokenContextId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AuditEventContext other) { - changeId(other.getChangeId()); - requestId(other.getRequestId()); - traceId(other.getTraceId()); - sessionId(other.getSessionId()); - actor(other.getActor()); - actorType(other.getActorType()); - accessType(other.getAccessType()); - ipAddress(other.getIpAddress()); - origin(other.getOrigin()); - authMode(other.getAuthMode()); - jwtId(other.getJwtId()); - bearerTokenContextId(other.getBearerTokenContextId()); - return this; - } - - /** - *

ID for the audit event.

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

ID for the request that caused the event.

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

ID for the request set by the service that received the request.

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

ID for the session in which the request was sent.

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

Member who sent the request. Depending on actorType, this may be a user ID or a service account ID.

- */ - @JsonSetter(value = "actor", nulls = Nulls.SKIP) - public Builder actor(Optional actor) { - this.actor = actor; - return this; - } - - public Builder actor(String actor) { - this.actor = Optional.ofNullable(actor); - return this; - } - - @JsonSetter(value = "actorType", nulls = Nulls.SKIP) - public Builder actorType(Optional actorType) { - this.actorType = actorType; - return this; - } - - public Builder actorType(V1MemberType actorType) { - this.actorType = Optional.ofNullable(actorType); - return this; - } - - @JsonSetter(value = "accessType", nulls = Nulls.SKIP) - public Builder accessType(Optional accessType) { - this.accessType = accessType; - return this; - } - - public Builder accessType(ContextAccessType accessType) { - this.accessType = Optional.ofNullable(accessType); - return this; - } - - /** - *

IP Address of the client that made the request.

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

HTTP Origin request header (including scheme, hostname, and port) of the request.

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

ID of the JWT token.

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

Embedded User Context.

- */ - @JsonSetter(value = "bearerTokenContextID", nulls = Nulls.SKIP) - public Builder bearerTokenContextId(Optional bearerTokenContextId) { - this.bearerTokenContextId = bearerTokenContextId; - return this; - } - - public Builder bearerTokenContextId(String bearerTokenContextId) { - this.bearerTokenContextId = Optional.ofNullable(bearerTokenContextId); - return this; - } - - public AuditEventContext build() { - return new AuditEventContext( - changeId, - requestId, - traceId, - sessionId, - actor, - actorType, - accessType, - ipAddress, - origin, - authMode, - jwtId, - bearerTokenContextId, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/AuditEventData.java b/src/main/java/com/skyflow/generated/rest/types/AuditEventData.java deleted file mode 100644 index 45d15be1..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AuditEventData.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 = AuditEventData.Builder.class) -public final class AuditEventData { - private final Optional content; - - private final Map additionalProperties; - - private AuditEventData(Optional content, Map additionalProperties) { - this.content = content; - this.additionalProperties = additionalProperties; - } - - /** - * @return The entire body of the data requested or the query fired. - */ - @JsonProperty("content") - public Optional getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditEventData && equalTo((AuditEventData) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AuditEventData other) { - return content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.content); - } - - @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 content = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AuditEventData other) { - content(other.getContent()); - return this; - } - - /** - *

The entire body of the data requested or the query fired.

- */ - @JsonSetter(value = "content", nulls = Nulls.SKIP) - public Builder content(Optional content) { - this.content = content; - return this; - } - - public Builder content(String content) { - this.content = Optional.ofNullable(content); - return this; - } - - public AuditEventData build() { - return new AuditEventData(content, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java b/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.java deleted file mode 100644 index 91126cc0..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/AuditEventHttpInfo.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 = AuditEventHttpInfo.Builder.class) -public final class AuditEventHttpInfo { - private final Optional uri; - - private final Optional method; - - private final Map additionalProperties; - - private AuditEventHttpInfo( - Optional uri, Optional method, Map additionalProperties) { - this.uri = uri; - this.method = method; - this.additionalProperties = additionalProperties; - } - - /** - * @return The http URI that is used. - */ - @JsonProperty("URI") - public Optional getUri() { - return uri; - } - - /** - * @return http method used. - */ - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditEventHttpInfo && equalTo((AuditEventHttpInfo) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AuditEventHttpInfo other) { - return uri.equals(other.uri) && method.equals(other.method); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.uri, this.method); - } - - @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 uri = Optional.empty(); - - private Optional method = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AuditEventHttpInfo other) { - uri(other.getUri()); - method(other.getMethod()); - return this; - } - - /** - *

The http URI that is used.

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

http method used.

- */ - @JsonSetter(value = "method", nulls = Nulls.SKIP) - public Builder method(Optional method) { - this.method = method; - return this; - } - - public Builder method(String method) { - this.method = Optional.ofNullable(method); - return this; - } - - public AuditEventHttpInfo build() { - return new AuditEventHttpInfo(uri, method, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java b/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java deleted file mode 100644 index c50f618d..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/BatchRecordMethod.java +++ /dev/null @@ -1,30 +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 BatchRecordMethod { - NONE("NONE"), - - POST("POST"), - - PUT("PUT"), - - GET("GET"), - - DELETE("DELETE"); - - private final String value; - - BatchRecordMethod(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/ContextAccessType.java b/src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java deleted file mode 100644 index b1b6072c..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/ContextAccessType.java +++ /dev/null @@ -1,26 +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 ContextAccessType { - ACCESS_NONE("ACCESS_NONE"), - - API("API"), - - SQL("SQL"); - - private final String value; - - ContextAccessType(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/ContextAuthMode.java b/src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java deleted file mode 100644 index 349ca23a..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/ContextAuthMode.java +++ /dev/null @@ -1,28 +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 ContextAuthMode { - AUTH_NONE("AUTH_NONE"), - - OKTA_JWT("OKTA_JWT"), - - SERVICE_ACCOUNT_JWT("SERVICE_ACCOUNT_JWT"), - - PAT_JWT("PAT_JWT"); - - private final String value; - - ContextAuthMode(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/DeidentifyFileOutput.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java deleted file mode 100644 index 59839994..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutput.java +++ /dev/null @@ -1,164 +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 = DeidentifyFileOutput.Builder.class) -public final class DeidentifyFileOutput { - private final Optional processedFile; - - private final Optional processedFileType; - - private final Optional processedFileExtension; - - private final Map additionalProperties; - - private DeidentifyFileOutput( - Optional processedFile, - Optional processedFileType, - Optional processedFileExtension, - Map additionalProperties) { - this.processedFile = processedFile; - this.processedFileType = processedFileType; - this.processedFileExtension = processedFileExtension; - this.additionalProperties = additionalProperties; - } - - /** - * @return URL or base64-encoded data of the output. - */ - @JsonProperty("processed_file") - public Optional getProcessedFile() { - return processedFile; - } - - /** - * @return Type of the processed file. - */ - @JsonProperty("processed_file_type") - public Optional getProcessedFileType() { - return processedFileType; - } - - /** - * @return Extension of the processed file. - */ - @JsonProperty("processed_file_extension") - public Optional getProcessedFileExtension() { - return processedFileExtension; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyFileOutput && equalTo((DeidentifyFileOutput) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyFileOutput other) { - return processedFile.equals(other.processedFile) - && processedFileType.equals(other.processedFileType) - && processedFileExtension.equals(other.processedFileExtension); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.processedFile, this.processedFileType, this.processedFileExtension); - } - - @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 processedFile = Optional.empty(); - - private Optional processedFileType = Optional.empty(); - - private Optional processedFileExtension = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DeidentifyFileOutput other) { - processedFile(other.getProcessedFile()); - processedFileType(other.getProcessedFileType()); - processedFileExtension(other.getProcessedFileExtension()); - 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; - } - - /** - *

Type of the processed file.

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

Extension of the processed file.

- */ - @JsonSetter(value = "processed_file_extension", nulls = Nulls.SKIP) - public Builder processedFileExtension(Optional processedFileExtension) { - this.processedFileExtension = processedFileExtension; - return this; - } - - public Builder processedFileExtension(String processedFileExtension) { - this.processedFileExtension = Optional.ofNullable(processedFileExtension); - return this; - } - - public DeidentifyFileOutput build() { - return new DeidentifyFileOutput( - processedFile, processedFileType, processedFileExtension, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.java deleted file mode 100644 index c560dc9e..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileOutputProcessedFileType.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 DeidentifyFileOutputProcessedFileType { - ENTITIES("entities"), - - PLAINTEXT_TRANSCRIPTION("plaintext_transcription"), - - REDACTED_AUDIO("redacted_audio"), - - REDACTED_DIARIZED_TRANSCRIPTION("redacted_diarized_transcription"), - - REDACTED_FILE("redacted_file"), - - REDACTED_IMAGE("redacted_image"), - - REDACTED_MEDICAL_DIARIZED_TRANSCRIPTION("redacted_medical_diarized_transcription"), - - REDACTED_MEDICAL_TRANSCRIPTION("redacted_medical_transcription"), - - REDACTED_TEXT("redacted_text"), - - REDACTED_TRANSCRIPTION("redacted_transcription"); - - private final String value; - - DeidentifyFileOutputProcessedFileType(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/DeidentifyFileResponse.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java deleted file mode 100644 index 460058dc..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyFileResponse.java +++ /dev/null @@ -1,112 +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 = DeidentifyFileResponse.Builder.class) -public final class DeidentifyFileResponse { - private final String runId; - - private final Map additionalProperties; - - private DeidentifyFileResponse(String runId, Map additionalProperties) { - this.runId = runId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Status URL for the detect run. - */ - @JsonProperty("run_id") - public String getRunId() { - return runId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyFileResponse && equalTo((DeidentifyFileResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyFileResponse other) { - return runId.equals(other.runId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.runId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RunIdStage builder() { - return new Builder(); - } - - public interface RunIdStage { - /** - * Status URL for the detect run. - */ - _FinalStage runId(@NotNull String runId); - - Builder from(DeidentifyFileResponse other); - } - - public interface _FinalStage { - DeidentifyFileResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RunIdStage, _FinalStage { - private String runId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyFileResponse other) { - runId(other.getRunId()); - return this; - } - - /** - * Status URL for the detect run.

Status URL for the detect run.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("run_id") - public _FinalStage runId(@NotNull String runId) { - this.runId = Objects.requireNonNull(runId, "runId must not be null"); - return this; - } - - @java.lang.Override - public DeidentifyFileResponse build() { - return new DeidentifyFileResponse(runId, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java deleted file mode 100644 index 9f73e9ad..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponse.java +++ /dev/null @@ -1,521 +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.ArrayList; -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 = DeidentifyStatusResponse.Builder.class) -public final class DeidentifyStatusResponse { - private final DeidentifyStatusResponseStatus status; - - private final List output; - - private final DeidentifyStatusResponseOutputType outputType; - - private final String message; - - private final Optional wordCount; - - private final Optional characterCount; - - private final Optional size; - - private final Optional duration; - - private final Optional pages; - - private final Optional slides; - - private final Map additionalProperties; - - private DeidentifyStatusResponse( - DeidentifyStatusResponseStatus status, - List output, - DeidentifyStatusResponseOutputType outputType, - String message, - Optional wordCount, - Optional characterCount, - Optional size, - Optional duration, - Optional pages, - Optional slides, - Map additionalProperties) { - this.status = status; - this.output = output; - this.outputType = outputType; - this.message = message; - this.wordCount = wordCount; - this.characterCount = characterCount; - this.size = size; - this.duration = duration; - this.pages = pages; - this.slides = slides; - this.additionalProperties = additionalProperties; - } - - /** - * @return Status of the detect run. - */ - @JsonProperty("status") - public DeidentifyStatusResponseStatus getStatus() { - return status; - } - - /** - * @return How the input file was specified. - */ - @JsonProperty("output") - public List getOutput() { - return output; - } - - /** - * @return How the output file is specified. - */ - @JsonProperty("output_type") - public DeidentifyStatusResponseOutputType getOutputType() { - return outputType; - } - - /** - * @return Status details about the detect run. - */ - @JsonProperty("message") - public String getMessage() { - return message; - } - - /** - * @return Number of words in the processed text. - */ - @JsonProperty("word_count") - public Optional getWordCount() { - return wordCount; - } - - /** - * @return Number of characters in the processed text. - */ - @JsonProperty("character_count") - public Optional getCharacterCount() { - return characterCount; - } - - /** - * @return Size of the processed text in kilobytes (KB). - */ - @JsonProperty("size") - public Optional getSize() { - return size; - } - - /** - * @return Duration of the processed audio in seconds. - */ - @JsonProperty("duration") - public Optional getDuration() { - return duration; - } - - /** - * @return Number of pages in the processed PDF. - */ - @JsonProperty("pages") - public Optional getPages() { - return pages; - } - - /** - * @return Number of slides in the processed presentation. - */ - @JsonProperty("slides") - public Optional getSlides() { - return slides; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyStatusResponse && equalTo((DeidentifyStatusResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyStatusResponse other) { - return status.equals(other.status) - && output.equals(other.output) - && outputType.equals(other.outputType) - && message.equals(other.message) - && wordCount.equals(other.wordCount) - && characterCount.equals(other.characterCount) - && size.equals(other.size) - && duration.equals(other.duration) - && pages.equals(other.pages) - && slides.equals(other.slides); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.status, - this.output, - this.outputType, - this.message, - this.wordCount, - this.characterCount, - this.size, - this.duration, - this.pages, - this.slides); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - /** - * Status of the detect run. - */ - OutputTypeStage status(@NotNull DeidentifyStatusResponseStatus status); - - Builder from(DeidentifyStatusResponse other); - } - - public interface OutputTypeStage { - /** - * How the output file is specified. - */ - MessageStage outputType(@NotNull DeidentifyStatusResponseOutputType outputType); - } - - public interface MessageStage { - /** - * Status details about the detect run. - */ - _FinalStage message(@NotNull String message); - } - - public interface _FinalStage { - DeidentifyStatusResponse build(); - - /** - *

How the input file was specified.

- */ - _FinalStage output(List output); - - _FinalStage addOutput(DeidentifyFileOutput output); - - _FinalStage addAllOutput(List output); - - /** - *

Number of words in the processed text.

- */ - _FinalStage wordCount(Optional wordCount); - - _FinalStage wordCount(Integer wordCount); - - /** - *

Number of characters in the processed text.

- */ - _FinalStage characterCount(Optional characterCount); - - _FinalStage characterCount(Integer characterCount); - - /** - *

Size of the processed text in kilobytes (KB).

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

Duration of the processed audio in seconds.

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

Number of pages in the processed PDF.

- */ - _FinalStage pages(Optional pages); - - _FinalStage pages(Integer pages); - - /** - *

Number of slides in the processed presentation.

- */ - _FinalStage slides(Optional slides); - - _FinalStage slides(Integer slides); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, OutputTypeStage, MessageStage, _FinalStage { - private DeidentifyStatusResponseStatus status; - - private DeidentifyStatusResponseOutputType outputType; - - private String message; - - private Optional slides = Optional.empty(); - - private Optional pages = Optional.empty(); - - private Optional duration = Optional.empty(); - - private Optional size = Optional.empty(); - - private Optional characterCount = Optional.empty(); - - private Optional wordCount = Optional.empty(); - - private List output = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyStatusResponse other) { - status(other.getStatus()); - output(other.getOutput()); - outputType(other.getOutputType()); - message(other.getMessage()); - wordCount(other.getWordCount()); - characterCount(other.getCharacterCount()); - size(other.getSize()); - duration(other.getDuration()); - pages(other.getPages()); - slides(other.getSlides()); - return this; - } - - /** - * Status of the detect run.

Status of the detect run.

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

How the output file is specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("output_type") - public MessageStage outputType(@NotNull DeidentifyStatusResponseOutputType outputType) { - this.outputType = Objects.requireNonNull(outputType, "outputType must not be null"); - return this; - } - - /** - * Status details about the detect run.

Status details about the detect run.

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

Number of slides in the processed presentation.

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

Number of slides in the processed presentation.

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

Number of pages in the processed PDF.

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

Number of pages in the processed PDF.

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

Duration of the processed audio in seconds.

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

Duration of the processed audio in seconds.

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

Size of the processed text in kilobytes (KB).

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

Size of the processed text in kilobytes (KB).

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

Number of characters in the processed text.

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

Number of characters in the processed text.

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

Number of words in the processed text.

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

Number of words in the processed text.

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

How the input file was specified.

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

How the input file was specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addOutput(DeidentifyFileOutput output) { - this.output.add(output); - return this; - } - - /** - *

How the input file was specified.

- */ - @java.lang.Override - @JsonSetter(value = "output", nulls = Nulls.SKIP) - public _FinalStage output(List output) { - this.output.clear(); - this.output.addAll(output); - return this; - } - - @java.lang.Override - public DeidentifyStatusResponse build() { - return new DeidentifyStatusResponse( - status, - output, - outputType, - message, - wordCount, - characterCount, - size, - duration, - pages, - slides, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java deleted file mode 100644 index 547bf414..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseOutputType.java +++ /dev/null @@ -1,26 +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 DeidentifyStatusResponseOutputType { - BASE_64("BASE64"), - - EFS_PATH("EFS_PATH"), - - UNKNOWN("UNKNOWN"); - - private final String value; - - DeidentifyStatusResponseOutputType(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/DeidentifyStatusResponseStatus.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java deleted file mode 100644 index 4e51e5cf..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStatusResponseStatus.java +++ /dev/null @@ -1,26 +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 DeidentifyStatusResponseStatus { - FAILED("FAILED"), - - IN_PROGRESS("IN_PROGRESS"), - - SUCCESS("SUCCESS"); - - private final String value; - - DeidentifyStatusResponseStatus(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/DeidentifyStringResponse.java b/src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java deleted file mode 100644 index 5b768610..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DeidentifyStringResponse.java +++ /dev/null @@ -1,242 +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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DeidentifyStringResponse.Builder.class) -public final class DeidentifyStringResponse { - private final String processedText; - - private final List entities; - - private final int wordCount; - - private final int characterCount; - - private final Map additionalProperties; - - private DeidentifyStringResponse( - String processedText, - List entities, - int wordCount, - int characterCount, - Map additionalProperties) { - this.processedText = processedText; - this.entities = entities; - this.wordCount = wordCount; - this.characterCount = characterCount; - this.additionalProperties = additionalProperties; - } - - /** - * @return De-identified text. - */ - @JsonProperty("processed_text") - public String getProcessedText() { - return processedText; - } - - /** - * @return Detected entities. - */ - @JsonProperty("entities") - public List getEntities() { - return entities; - } - - /** - * @return Number of words from the input text. - */ - @JsonProperty("word_count") - public int getWordCount() { - return wordCount; - } - - /** - * @return Number of characters from the input text. - */ - @JsonProperty("character_count") - public int getCharacterCount() { - return characterCount; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeidentifyStringResponse && equalTo((DeidentifyStringResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeidentifyStringResponse other) { - return processedText.equals(other.processedText) - && entities.equals(other.entities) - && wordCount == other.wordCount - && characterCount == other.characterCount; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.processedText, this.entities, this.wordCount, this.characterCount); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ProcessedTextStage builder() { - return new Builder(); - } - - public interface ProcessedTextStage { - /** - * De-identified text. - */ - WordCountStage processedText(@NotNull String processedText); - - Builder from(DeidentifyStringResponse other); - } - - public interface WordCountStage { - /** - * Number of words from the input text. - */ - CharacterCountStage wordCount(int wordCount); - } - - public interface CharacterCountStage { - /** - * Number of characters from the input text. - */ - _FinalStage characterCount(int characterCount); - } - - public interface _FinalStage { - DeidentifyStringResponse build(); - - /** - *

Detected entities.

- */ - _FinalStage entities(List entities); - - _FinalStage addEntities(DetectedEntity entities); - - _FinalStage addAllEntities(List entities); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ProcessedTextStage, WordCountStage, CharacterCountStage, _FinalStage { - private String processedText; - - private int wordCount; - - private int characterCount; - - private List entities = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeidentifyStringResponse other) { - processedText(other.getProcessedText()); - entities(other.getEntities()); - wordCount(other.getWordCount()); - characterCount(other.getCharacterCount()); - return this; - } - - /** - * De-identified text.

De-identified text.

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

Number of words from the input text.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("word_count") - public CharacterCountStage wordCount(int wordCount) { - this.wordCount = wordCount; - return this; - } - - /** - * Number of characters from the input text.

Number of characters from the input text.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("character_count") - public _FinalStage characterCount(int characterCount) { - this.characterCount = characterCount; - return this; - } - - /** - *

Detected entities.

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

Detected entities.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addEntities(DetectedEntity entities) { - this.entities.add(entities); - return this; - } - - /** - *

Detected entities.

- */ - @java.lang.Override - @JsonSetter(value = "entities", nulls = Nulls.SKIP) - public _FinalStage entities(List entities) { - this.entities.clear(); - this.entities.addAll(entities); - return this; - } - - @java.lang.Override - public DeidentifyStringResponse build() { - return new DeidentifyStringResponse( - processedText, entities, wordCount, characterCount, additionalProperties); - } - } -} 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/DetectFileRequestDataType.java b/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java deleted file mode 100644 index e039bc86..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DetectFileRequestDataType.java +++ /dev/null @@ -1,24 +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 DetectFileRequestDataType { - UNKNOWN("UNKNOWN"), - - BASE_64("BASE64"); - - private final String value; - - DetectFileRequestDataType(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/DetectRequestDeidentifyOption.java b/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java deleted file mode 100644 index bdc82ccf..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DetectRequestDeidentifyOption.java +++ /dev/null @@ -1,26 +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 DetectRequestDeidentifyOption { - UNKNOWN("UNKNOWN"), - - ENTITY_UNQ_COUNTER("ENTITY_UNQ_COUNTER"), - - ENTITY_ONLY("ENTITY_ONLY"); - - private final String value; - - DetectRequestDeidentifyOption(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/DetectedEntity.java b/src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java deleted file mode 100644 index 6de2200a..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DetectedEntity.java +++ /dev/null @@ -1,217 +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 = DetectedEntity.Builder.class) -public final class DetectedEntity { - private final Optional token; - - private final Optional value; - - private final Optional location; - - private final Optional entityType; - - private final Optional> entityScores; - - private final Map additionalProperties; - - private DetectedEntity( - Optional token, - Optional value, - Optional location, - Optional entityType, - Optional> entityScores, - Map additionalProperties) { - this.token = token; - this.value = value; - this.location = location; - this.entityType = entityType; - this.entityScores = entityScores; - this.additionalProperties = additionalProperties; - } - - /** - * @return Processed text of the entity. - */ - @JsonProperty("token") - public Optional getToken() { - return token; - } - - /** - * @return Original text of the entity. - */ - @JsonProperty("value") - public Optional getValue() { - return value; - } - - @JsonProperty("location") - public Optional getLocation() { - return location; - } - - /** - * @return Highest-rated label. - */ - @JsonProperty("entity_type") - public Optional getEntityType() { - return entityType; - } - - /** - * @return entity_scores and their scores. - */ - @JsonProperty("entity_scores") - public Optional> getEntityScores() { - return entityScores; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DetectedEntity && equalTo((DetectedEntity) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DetectedEntity other) { - return token.equals(other.token) - && value.equals(other.value) - && location.equals(other.location) - && entityType.equals(other.entityType) - && entityScores.equals(other.entityScores); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token, this.value, this.location, this.entityType, this.entityScores); - } - - @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 token = Optional.empty(); - - private Optional value = Optional.empty(); - - private Optional location = Optional.empty(); - - private Optional entityType = Optional.empty(); - - private Optional> entityScores = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DetectedEntity other) { - token(other.getToken()); - value(other.getValue()); - location(other.getLocation()); - entityType(other.getEntityType()); - entityScores(other.getEntityScores()); - return this; - } - - /** - *

Processed text of the entity.

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

Original text of the entity.

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

Highest-rated label.

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

entity_scores and their scores.

- */ - @JsonSetter(value = "entity_scores", nulls = Nulls.SKIP) - public Builder entityScores(Optional> entityScores) { - this.entityScores = entityScores; - return this; - } - - public Builder entityScores(Map entityScores) { - this.entityScores = Optional.ofNullable(entityScores); - return this; - } - - public DetectedEntity build() { - return new DetectedEntity(token, value, location, entityType, entityScores, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java b/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java deleted file mode 100644 index f192c14f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/DetokenizeRecordResponseValueType.java +++ /dev/null @@ -1,38 +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 DetokenizeRecordResponseValueType { - NONE("NONE"), - - STRING("STRING"), - - INTEGER("INTEGER"), - - FLOAT("FLOAT"), - - BOOL("BOOL"), - - DATETIME("DATETIME"), - - JSON("JSON"), - - ARRAY("ARRAY"), - - DATE("DATE"); - - private final String value; - - DetokenizeRecordResponseValueType(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/EntityLocation.java b/src/main/java/com/skyflow/generated/rest/types/EntityLocation.java deleted file mode 100644 index 6e711422..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/EntityLocation.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.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = EntityLocation.Builder.class) -public final class EntityLocation { - private final Optional startIndex; - - private final Optional endIndex; - - private final Optional startIndexProcessed; - - private final Optional endIndexProcessed; - - private final Map additionalProperties; - - private EntityLocation( - 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 EntityLocation && equalTo((EntityLocation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(EntityLocation 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(EntityLocation 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 EntityLocation build() { - return new EntityLocation( - startIndex, endIndex, startIndexProcessed, endIndexProcessed, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/EntityType.java b/src/main/java/com/skyflow/generated/rest/types/EntityType.java deleted file mode 100644 index 605282ed..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/EntityType.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 EntityType { - ACCOUNT_NUMBER("account_number"), - - AGE("age"), - - ALL("all"), - - BANK_ACCOUNT("bank_account"), - - BLOOD_TYPE("blood_type"), - - CONDITION("condition"), - - CORPORATE_ACTION("corporate_action"), - - CREDIT_CARD("credit_card"), - - CREDIT_CARD_EXPIRATION("credit_card_expiration"), - - CVV("cvv"), - - DATE("date"), - - DATE_INTERVAL("date_interval"), - - DOB("dob"), - - DOSE("dose"), - - DRIVER_LICENSE("driver_license"), - - DRUG("drug"), - - DURATION("duration"), - - EMAIL_ADDRESS("email_address"), - - EVENT("event"), - - FILENAME("filename"), - - FINANCIAL_METRIC("financial_metric"), - - GENDER_SEXUALITY("gender_sexuality"), - - HEALTHCARE_NUMBER("healthcare_number"), - - INJURY("injury"), - - IP_ADDRESS("ip_address"), - - LANGUAGE("language"), - - LOCATION("location"), - - LOCATION_ADDRESS("location_address"), - - LOCATION_ADDRESS_STREET("location_address_street"), - - LOCATION_CITY("location_city"), - - LOCATION_COORDINATE("location_coordinate"), - - LOCATION_COUNTRY("location_country"), - - LOCATION_STATE("location_state"), - - LOCATION_ZIP("location_zip"), - - MARITAL_STATUS("marital_status"), - - MEDICAL_CODE("medical_code"), - - MEDICAL_PROCESS("medical_process"), - - MONEY("money"), - - NAME("name"), - - NAME_FAMILY("name_family"), - - NAME_GIVEN("name_given"), - - NAME_MEDICAL_PROFESSIONAL("name_medical_professional"), - - NUMERICAL_PII("numerical_pii"), - - OCCUPATION("occupation"), - - ORGANIZATION("organization"), - - ORGANIZATION_MEDICAL_FACILITY("organization_medical_facility"), - - ORIGIN("origin"), - - PASSPORT_NUMBER("passport_number"), - - PASSWORD("password"), - - PHONE_NUMBER("phone_number"), - - PHYSICAL_ATTRIBUTE("physical_attribute"), - - POLITICAL_AFFILIATION("political_affiliation"), - - PRODUCT("product"), - - RELIGION("religion"), - - ROUTING_NUMBER("routing_number"), - - SSN("ssn"), - - STATISTICS("statistics"), - - TIME("time"), - - TREND("trend"), - - URL("url"), - - USERNAME("username"), - - VEHICLE_ID("vehicle_id"), - - ZODIAC_SIGN("zodiac_sign"); - - private final String value; - - EntityType(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/ErrorResponse.java b/src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java deleted file mode 100644 index 68778cb1..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/ErrorResponse.java +++ /dev/null @@ -1,102 +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 = ErrorResponse.Builder.class) -public final class ErrorResponse { - private final ErrorResponseError error; - - private final Map additionalProperties; - - private ErrorResponse(ErrorResponseError error, Map additionalProperties) { - this.error = error; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("error") - public ErrorResponseError getError() { - return error; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ErrorResponse && equalTo((ErrorResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ErrorResponse other) { - return error.equals(other.error); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.error); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ErrorStage builder() { - return new Builder(); - } - - public interface ErrorStage { - _FinalStage error(@NotNull ErrorResponseError error); - - Builder from(ErrorResponse other); - } - - public interface _FinalStage { - ErrorResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ErrorStage, _FinalStage { - private ErrorResponseError error; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ErrorResponse other) { - error(other.getError()); - return this; - } - - @java.lang.Override - @JsonSetter("error") - public _FinalStage error(@NotNull ErrorResponseError error) { - this.error = Objects.requireNonNull(error, "error must not be null"); - return this; - } - - @java.lang.Override - public ErrorResponse build() { - return new ErrorResponse(error, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java b/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java deleted file mode 100644 index 5d0ee57d..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/ErrorResponseError.java +++ /dev/null @@ -1,240 +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 = ErrorResponseError.Builder.class) -public final class ErrorResponseError { - private final int grpcCode; - - private final int httpCode; - - private final String httpStatus; - - private final String message; - - private final Optional>> details; - - private final Map additionalProperties; - - private ErrorResponseError( - int grpcCode, - int httpCode, - String httpStatus, - String message, - Optional>> details, - Map additionalProperties) { - this.grpcCode = grpcCode; - this.httpCode = httpCode; - this.httpStatus = httpStatus; - this.message = message; - this.details = details; - this.additionalProperties = additionalProperties; - } - - /** - * @return gRPC status codes. See https://grpc.io/docs/guides/status-codes. - */ - @JsonProperty("grpc_code") - public int getGrpcCode() { - return grpcCode; - } - - /** - * @return HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status. - */ - @JsonProperty("http_code") - public int getHttpCode() { - return httpCode; - } - - /** - * @return HTTP status message. - */ - @JsonProperty("http_status") - public String getHttpStatus() { - return httpStatus; - } - - @JsonProperty("message") - public String getMessage() { - return message; - } - - @JsonProperty("details") - public Optional>> getDetails() { - return details; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ErrorResponseError && equalTo((ErrorResponseError) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ErrorResponseError other) { - return grpcCode == other.grpcCode - && httpCode == other.httpCode - && httpStatus.equals(other.httpStatus) - && message.equals(other.message) - && details.equals(other.details); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.grpcCode, this.httpCode, this.httpStatus, this.message, this.details); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static GrpcCodeStage builder() { - return new Builder(); - } - - public interface GrpcCodeStage { - /** - * gRPC status codes. See https://grpc.io/docs/guides/status-codes. - */ - HttpCodeStage grpcCode(int grpcCode); - - Builder from(ErrorResponseError other); - } - - public interface HttpCodeStage { - /** - * HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status. - */ - HttpStatusStage httpCode(int httpCode); - } - - public interface HttpStatusStage { - /** - * HTTP status message. - */ - MessageStage httpStatus(@NotNull String httpStatus); - } - - public interface MessageStage { - _FinalStage message(@NotNull String message); - } - - public interface _FinalStage { - ErrorResponseError build(); - - _FinalStage details(Optional>> details); - - _FinalStage details(List> details); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements GrpcCodeStage, HttpCodeStage, HttpStatusStage, MessageStage, _FinalStage { - private int grpcCode; - - private int httpCode; - - private String httpStatus; - - private String message; - - private Optional>> details = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ErrorResponseError other) { - grpcCode(other.getGrpcCode()); - httpCode(other.getHttpCode()); - httpStatus(other.getHttpStatus()); - message(other.getMessage()); - details(other.getDetails()); - return this; - } - - /** - * gRPC status codes. See https://grpc.io/docs/guides/status-codes.

gRPC status codes. See https://grpc.io/docs/guides/status-codes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("grpc_code") - public HttpCodeStage grpcCode(int grpcCode) { - this.grpcCode = grpcCode; - return this; - } - - /** - * HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.

HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("http_code") - public HttpStatusStage httpCode(int httpCode) { - this.httpCode = httpCode; - return this; - } - - /** - * HTTP status message.

HTTP status message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("http_status") - public MessageStage httpStatus(@NotNull String httpStatus) { - this.httpStatus = Objects.requireNonNull(httpStatus, "httpStatus must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(@NotNull String message) { - this.message = Objects.requireNonNull(message, "message must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage details(List> details) { - this.details = Optional.ofNullable(details); - return this; - } - - @java.lang.Override - @JsonSetter(value = "details", nulls = Nulls.SKIP) - public _FinalStage details(Optional>> details) { - this.details = details; - return this; - } - - @java.lang.Override - public ErrorResponseError build() { - return new ErrorResponseError(grpcCode, httpCode, httpStatus, message, details, additionalProperties); - } - } -} 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/RedactionEnumRedaction.java b/src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java deleted file mode 100644 index 3e83052b..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/RedactionEnumRedaction.java +++ /dev/null @@ -1,28 +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 RedactionEnumRedaction { - DEFAULT("DEFAULT"), - - REDACTED("REDACTED"), - - MASKED("MASKED"), - - PLAIN_TEXT("PLAIN_TEXT"); - - private final String value; - - RedactionEnumRedaction(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/ReidentifyStringResponse.java b/src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.java deleted file mode 100644 index ba305e63..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/ReidentifyStringResponse.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 = ReidentifyStringResponse.Builder.class) -public final class ReidentifyStringResponse { - private final Optional text; - - private final Map additionalProperties; - - private ReidentifyStringResponse(Optional text, Map additionalProperties) { - this.text = text; - this.additionalProperties = additionalProperties; - } - - /** - * @return Re-identified text. - */ - @JsonProperty("text") - public Optional getText() { - return text; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ReidentifyStringResponse && equalTo((ReidentifyStringResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ReidentifyStringResponse other) { - return text.equals(other.text); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.text); - } - - @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(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ReidentifyStringResponse other) { - text(other.getText()); - return this; - } - - /** - *

Re-identified text.

- */ - @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; - } - - public ReidentifyStringResponse build() { - return new ReidentifyStringResponse(text, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java b/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java deleted file mode 100644 index 436a1de8..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/RequestActionType.java +++ /dev/null @@ -1,56 +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 RequestActionType { - NONE("NONE"), - - ASSIGN("ASSIGN"), - - CREATE("CREATE"), - - DELETE("DELETE"), - - EXECUTE("EXECUTE"), - - LIST("LIST"), - - READ("READ"), - - UNASSIGN("UNASSIGN"), - - UPDATE("UPDATE"), - - VALIDATE("VALIDATE"), - - LOGIN("LOGIN"), - - ROTATE("ROTATE"), - - SCHEDULEROTATION("SCHEDULEROTATION"), - - SCHEDULEROTATIONALERT("SCHEDULEROTATIONALERT"), - - IMPORT("IMPORT"), - - GETIMPORTPARAMETERS("GETIMPORTPARAMETERS"), - - PING("PING"), - - GETCLOUDPROVIDER("GETCLOUDPROVIDER"); - - private final String value; - - RequestActionType(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/TokenType.java b/src/main/java/com/skyflow/generated/rest/types/TokenType.java deleted file mode 100644 index a50e861b..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/TokenType.java +++ /dev/null @@ -1,188 +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 = TokenType.Builder.class) -public final class TokenType { - private final Optional default_; - - private final Optional> vaultToken; - - private final Optional> entityUnqCounter; - - private final Optional> entityOnly; - - private final Map additionalProperties; - - private TokenType( - Optional default_, - Optional> vaultToken, - Optional> entityUnqCounter, - Optional> entityOnly, - Map additionalProperties) { - this.default_ = default_; - this.vaultToken = vaultToken; - this.entityUnqCounter = entityUnqCounter; - this.entityOnly = entityOnly; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("default") - public Optional getDefault() { - return default_; - } - - /** - * @return Entity types to replace with vault tokens. - */ - @JsonProperty("vault_token") - public Optional> getVaultToken() { - return vaultToken; - } - - /** - * @return Entity types to replace with entity tokens with unique counters. - */ - @JsonProperty("entity_unq_counter") - public Optional> getEntityUnqCounter() { - return entityUnqCounter; - } - - /** - * @return Entity types to replace with entity tokens. - */ - @JsonProperty("entity_only") - public Optional> getEntityOnly() { - return entityOnly; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TokenType && equalTo((TokenType) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TokenType other) { - return default_.equals(other.default_) - && vaultToken.equals(other.vaultToken) - && entityUnqCounter.equals(other.entityUnqCounter) - && entityOnly.equals(other.entityOnly); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.default_, this.vaultToken, this.entityUnqCounter, this.entityOnly); - } - - @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 default_ = Optional.empty(); - - private Optional> vaultToken = Optional.empty(); - - private Optional> entityUnqCounter = Optional.empty(); - - private Optional> entityOnly = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(TokenType other) { - default_(other.getDefault()); - vaultToken(other.getVaultToken()); - entityUnqCounter(other.getEntityUnqCounter()); - entityOnly(other.getEntityOnly()); - return this; - } - - @JsonSetter(value = "default", nulls = Nulls.SKIP) - public Builder default_(Optional default_) { - this.default_ = default_; - return this; - } - - public Builder default_(TokenTypeDefault default_) { - this.default_ = Optional.ofNullable(default_); - return this; - } - - /** - *

Entity types to replace with vault tokens.

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

Entity types to replace with entity tokens with unique counters.

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

Entity types to replace with entity tokens.

- */ - @JsonSetter(value = "entity_only", nulls = Nulls.SKIP) - public Builder entityOnly(Optional> entityOnly) { - this.entityOnly = entityOnly; - return this; - } - - public Builder entityOnly(List entityOnly) { - this.entityOnly = Optional.ofNullable(entityOnly); - return this; - } - - public TokenType build() { - return new TokenType(default_, vaultToken, entityUnqCounter, entityOnly, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java b/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java deleted file mode 100644 index 14ab8f0f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/TokenTypeDefault.java +++ /dev/null @@ -1,26 +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 TokenTypeDefault { - ENTITY_ONLY("entity_only"), - - ENTITY_UNQ_COUNTER("entity_unq_counter"), - - VAULT_TOKEN("vault_token"); - - private final String value; - - TokenTypeDefault(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/TokenTypeWithoutVault.java b/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java deleted file mode 100644 index 5f5938a0..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVault.java +++ /dev/null @@ -1,158 +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 = TokenTypeWithoutVault.Builder.class) -public final class TokenTypeWithoutVault { - private final Optional default_; - - private final Optional> entityUnqCounter; - - private final Optional> entityOnly; - - private final Map additionalProperties; - - private TokenTypeWithoutVault( - Optional default_, - Optional> entityUnqCounter, - Optional> entityOnly, - Map additionalProperties) { - this.default_ = default_; - this.entityUnqCounter = entityUnqCounter; - this.entityOnly = entityOnly; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("default") - public Optional getDefault() { - return default_; - } - - /** - * @return Entity types to replace with entity tokens with unique counters. - */ - @JsonProperty("entity_unq_counter") - public Optional> getEntityUnqCounter() { - return entityUnqCounter; - } - - /** - * @return Entity types to replace with entity tokens. - */ - @JsonProperty("entity_only") - public Optional> getEntityOnly() { - return entityOnly; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TokenTypeWithoutVault && equalTo((TokenTypeWithoutVault) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TokenTypeWithoutVault other) { - return default_.equals(other.default_) - && entityUnqCounter.equals(other.entityUnqCounter) - && entityOnly.equals(other.entityOnly); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.default_, this.entityUnqCounter, this.entityOnly); - } - - @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 default_ = Optional.empty(); - - private Optional> entityUnqCounter = Optional.empty(); - - private Optional> entityOnly = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(TokenTypeWithoutVault other) { - default_(other.getDefault()); - entityUnqCounter(other.getEntityUnqCounter()); - entityOnly(other.getEntityOnly()); - return this; - } - - @JsonSetter(value = "default", nulls = Nulls.SKIP) - public Builder default_(Optional default_) { - this.default_ = default_; - return this; - } - - public Builder default_(TokenTypeWithoutVaultDefault default_) { - this.default_ = Optional.ofNullable(default_); - return this; - } - - /** - *

Entity types to replace with entity tokens with unique counters.

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

Entity types to replace with entity tokens.

- */ - @JsonSetter(value = "entity_only", nulls = Nulls.SKIP) - public Builder entityOnly(Optional> entityOnly) { - this.entityOnly = entityOnly; - return this; - } - - public Builder entityOnly(List entityOnly) { - this.entityOnly = Optional.ofNullable(entityOnly); - return this; - } - - public TokenTypeWithoutVault build() { - return new TokenTypeWithoutVault(default_, entityUnqCounter, entityOnly, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java b/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java deleted file mode 100644 index 45dba579..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/TokenTypeWithoutVaultDefault.java +++ /dev/null @@ -1,24 +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 TokenTypeWithoutVaultDefault { - ENTITY_ONLY("entity_only"), - - ENTITY_UNQ_COUNTER("entity_unq_counter"); - - private final String value; - - TokenTypeWithoutVaultDefault(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/Transformations.java b/src/main/java/com/skyflow/generated/rest/types/Transformations.java deleted file mode 100644 index 46022faa..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/Transformations.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 = Transformations.Builder.class) -public final class Transformations { - private final Optional shiftDates; - - private final Map additionalProperties; - - private Transformations(Optional shiftDates, Map additionalProperties) { - this.shiftDates = shiftDates; - this.additionalProperties = additionalProperties; - } - - /** - * @return Shift dates by a specified number of days. - */ - @JsonProperty("shift_dates") - public Optional getShiftDates() { - return shiftDates; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Transformations && equalTo((Transformations) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Transformations other) { - return shiftDates.equals(other.shiftDates); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.shiftDates); - } - - @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 shiftDates = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Transformations other) { - shiftDates(other.getShiftDates()); - return this; - } - - /** - *

Shift dates by a specified number of days.

- */ - @JsonSetter(value = "shift_dates", nulls = Nulls.SKIP) - public Builder shiftDates(Optional shiftDates) { - this.shiftDates = shiftDates; - return this; - } - - public Builder shiftDates(TransformationsShiftDates shiftDates) { - this.shiftDates = Optional.ofNullable(shiftDates); - return this; - } - - public Transformations build() { - return new Transformations(shiftDates, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java b/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java deleted file mode 100644 index 1e11938b..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDates.java +++ /dev/null @@ -1,162 +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 = TransformationsShiftDates.Builder.class) -public final class TransformationsShiftDates { - private final Optional maxDays; - - private final Optional minDays; - - private final Optional> entityTypes; - - private final Map additionalProperties; - - private TransformationsShiftDates( - Optional maxDays, - Optional minDays, - Optional> entityTypes, - Map additionalProperties) { - this.maxDays = maxDays; - this.minDays = minDays; - this.entityTypes = entityTypes; - this.additionalProperties = additionalProperties; - } - - /** - * @return Maximum number of days to shift the date by. - */ - @JsonProperty("max_days") - public Optional getMaxDays() { - return maxDays; - } - - /** - * @return Minimum number of days to shift the date by. - */ - @JsonProperty("min_days") - public Optional getMinDays() { - return minDays; - } - - /** - * @return Entity types to shift dates for. - */ - @JsonProperty("entity_types") - public Optional> getEntityTypes() { - return entityTypes; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TransformationsShiftDates && equalTo((TransformationsShiftDates) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TransformationsShiftDates other) { - return maxDays.equals(other.maxDays) && minDays.equals(other.minDays) && entityTypes.equals(other.entityTypes); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.maxDays, this.minDays, this.entityTypes); - } - - @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 maxDays = Optional.empty(); - - private Optional minDays = Optional.empty(); - - private Optional> entityTypes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(TransformationsShiftDates other) { - maxDays(other.getMaxDays()); - minDays(other.getMinDays()); - entityTypes(other.getEntityTypes()); - return this; - } - - /** - *

Maximum number of days to shift the date by.

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

Minimum number of days to shift the date by.

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

Entity types to shift dates for.

- */ - @JsonSetter(value = "entity_types", nulls = Nulls.SKIP) - public Builder entityTypes(Optional> entityTypes) { - this.entityTypes = entityTypes; - return this; - } - - public Builder entityTypes(List entityTypes) { - this.entityTypes = Optional.ofNullable(entityTypes); - return this; - } - - public TransformationsShiftDates build() { - return new TransformationsShiftDates(maxDays, minDays, entityTypes, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java b/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java deleted file mode 100644 index 148cea23..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/TransformationsShiftDatesEntityTypesItem.java +++ /dev/null @@ -1,26 +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 TransformationsShiftDatesEntityTypesItem { - DATE("date"), - - DATE_INTERVAL("date_interval"), - - DOB("dob"); - - private final String value; - - TransformationsShiftDatesEntityTypesItem(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/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/V1AuditAfterOptions.java b/src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.java deleted file mode 100644 index 1453dd99..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AuditAfterOptions.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 = V1AuditAfterOptions.Builder.class) -public final class V1AuditAfterOptions { - private final Optional timestamp; - - private final Optional changeId; - - private final Map additionalProperties; - - private V1AuditAfterOptions( - Optional timestamp, Optional changeId, Map additionalProperties) { - this.timestamp = timestamp; - this.changeId = changeId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. - */ - @JsonProperty("timestamp") - public Optional getTimestamp() { - return timestamp; - } - - /** - * @return Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank. - */ - @JsonProperty("changeID") - public Optional getChangeId() { - return changeId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AuditAfterOptions && equalTo((V1AuditAfterOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AuditAfterOptions other) { - return timestamp.equals(other.timestamp) && changeId.equals(other.changeId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.timestamp, this.changeId); - } - - @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 timestamp = Optional.empty(); - - private Optional changeId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AuditAfterOptions other) { - timestamp(other.getTimestamp()); - changeId(other.getChangeId()); - return this; - } - - /** - *

Timestamp provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

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

Change ID provided in the previous audit response's nextOps attribute. An alternate way to manage response pagination. Can't be used with sortOps or offset. For the first request in a series of audit requests, leave blank.

- */ - @JsonSetter(value = "changeID", nulls = Nulls.SKIP) - public Builder changeId(Optional changeId) { - this.changeId = changeId; - return this; - } - - public Builder changeId(String changeId) { - this.changeId = Optional.ofNullable(changeId); - return this; - } - - public V1AuditAfterOptions build() { - return new V1AuditAfterOptions(timestamp, changeId, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java deleted file mode 100644 index 2dd2ca4e..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AuditEventResponse.java +++ /dev/null @@ -1,187 +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 = V1AuditEventResponse.Builder.class) -public final class V1AuditEventResponse { - private final Optional code; - - private final Optional message; - - private final Optional data; - - private final Optional timestamp; - - private final Map additionalProperties; - - private V1AuditEventResponse( - Optional code, - Optional message, - Optional data, - Optional timestamp, - Map additionalProperties) { - this.code = code; - this.message = message; - this.data = data; - this.timestamp = timestamp; - this.additionalProperties = additionalProperties; - } - - /** - * @return The status of the overall operation. - */ - @JsonProperty("code") - public Optional getCode() { - return code; - } - - /** - * @return The status message for the overall operation. - */ - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @JsonProperty("data") - public Optional getData() { - return data; - } - - /** - * @return time when this response is generated, use extention method to set it. - */ - @JsonProperty("timestamp") - public Optional getTimestamp() { - return timestamp; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AuditEventResponse && equalTo((V1AuditEventResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AuditEventResponse other) { - return code.equals(other.code) - && message.equals(other.message) - && data.equals(other.data) - && timestamp.equals(other.timestamp); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.code, this.message, this.data, this.timestamp); - } - - @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 code = Optional.empty(); - - private Optional message = Optional.empty(); - - private Optional data = Optional.empty(); - - private Optional timestamp = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AuditEventResponse other) { - code(other.getCode()); - message(other.getMessage()); - data(other.getData()); - timestamp(other.getTimestamp()); - return this; - } - - /** - *

The status of the overall operation.

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

The status message for the overall operation.

- */ - @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; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional data) { - this.data = data; - return this; - } - - public Builder data(AuditEventData data) { - this.data = Optional.ofNullable(data); - return this; - } - - /** - *

time when this response is generated, use extention method to set it.

- */ - @JsonSetter(value = "timestamp", nulls = Nulls.SKIP) - public Builder timestamp(Optional timestamp) { - this.timestamp = timestamp; - return this; - } - - public Builder timestamp(String timestamp) { - this.timestamp = Optional.ofNullable(timestamp); - return this; - } - - public V1AuditEventResponse build() { - return new V1AuditEventResponse(code, message, data, timestamp, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java deleted file mode 100644 index 88496f03..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AuditResponse.java +++ /dev/null @@ -1,127 +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 = V1AuditResponse.Builder.class) -public final class V1AuditResponse { - private final Optional> event; - - private final Optional nextOps; - - private final Map additionalProperties; - - private V1AuditResponse( - Optional> event, - Optional nextOps, - Map additionalProperties) { - this.event = event; - this.nextOps = nextOps; - this.additionalProperties = additionalProperties; - } - - /** - * @return Events matching the query. - */ - @JsonProperty("event") - public Optional> getEvent() { - return event; - } - - @JsonProperty("nextOps") - public Optional getNextOps() { - return nextOps; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AuditResponse && equalTo((V1AuditResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AuditResponse other) { - return event.equals(other.event) && nextOps.equals(other.nextOps); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.event, this.nextOps); - } - - @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> event = Optional.empty(); - - private Optional nextOps = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AuditResponse other) { - event(other.getEvent()); - nextOps(other.getNextOps()); - return this; - } - - /** - *

Events matching the query.

- */ - @JsonSetter(value = "event", nulls = Nulls.SKIP) - public Builder event(Optional> event) { - this.event = event; - return this; - } - - public Builder event(List event) { - this.event = Optional.ofNullable(event); - return this; - } - - @JsonSetter(value = "nextOps", nulls = Nulls.SKIP) - public Builder nextOps(Optional nextOps) { - this.nextOps = nextOps; - return this; - } - - public Builder nextOps(V1AuditAfterOptions nextOps) { - this.nextOps = Optional.ofNullable(nextOps); - return this; - } - - public V1AuditResponse build() { - return new V1AuditResponse(event, nextOps, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java b/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java deleted file mode 100644 index 595b724c..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEvent.java +++ /dev/null @@ -1,238 +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 = V1AuditResponseEvent.Builder.class) -public final class V1AuditResponseEvent { - private final Optional context; - - private final Optional request; - - private final Optional response; - - private final Optional parentAccountId; - - private final Optional accountId; - - private final Optional> resourceIDs; - - private final Map additionalProperties; - - private V1AuditResponseEvent( - Optional context, - Optional request, - Optional response, - Optional parentAccountId, - Optional accountId, - Optional> resourceIDs, - Map additionalProperties) { - this.context = context; - this.request = request; - this.response = response; - this.parentAccountId = parentAccountId; - this.accountId = accountId; - this.resourceIDs = resourceIDs; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("context") - public Optional getContext() { - return context; - } - - @JsonProperty("request") - public Optional getRequest() { - return request; - } - - @JsonProperty("response") - public Optional getResponse() { - return response; - } - - /** - * @return Parent account ID of the account that made the request, if any. - */ - @JsonProperty("parentAccountID") - public Optional getParentAccountId() { - return parentAccountId; - } - - /** - * @return ID of the account that made the request. - */ - @JsonProperty("accountID") - public Optional getAccountId() { - return accountId; - } - - /** - * @return IDs for resources involved in the event. Presented in {resourceType}/{resourceID} format. For example, VAULT/cd1d815aa09b4cbfbb803bd20349f202. - */ - @JsonProperty("resourceIDs") - public Optional> getResourceIDs() { - return resourceIDs; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AuditResponseEvent && equalTo((V1AuditResponseEvent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AuditResponseEvent other) { - return context.equals(other.context) - && request.equals(other.request) - && response.equals(other.response) - && parentAccountId.equals(other.parentAccountId) - && accountId.equals(other.accountId) - && resourceIDs.equals(other.resourceIDs); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.context, this.request, this.response, this.parentAccountId, this.accountId, this.resourceIDs); - } - - @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 context = Optional.empty(); - - private Optional request = Optional.empty(); - - private Optional response = Optional.empty(); - - private Optional parentAccountId = Optional.empty(); - - private Optional accountId = Optional.empty(); - - private Optional> resourceIDs = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AuditResponseEvent other) { - context(other.getContext()); - request(other.getRequest()); - response(other.getResponse()); - parentAccountId(other.getParentAccountId()); - accountId(other.getAccountId()); - resourceIDs(other.getResourceIDs()); - return this; - } - - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public Builder context(Optional context) { - this.context = context; - return this; - } - - public Builder context(AuditEventContext context) { - this.context = Optional.ofNullable(context); - return this; - } - - @JsonSetter(value = "request", nulls = Nulls.SKIP) - public Builder request(Optional request) { - this.request = request; - return this; - } - - public Builder request(V1AuditResponseEventRequest request) { - this.request = Optional.ofNullable(request); - return this; - } - - @JsonSetter(value = "response", nulls = Nulls.SKIP) - public Builder response(Optional response) { - this.response = response; - return this; - } - - public Builder response(V1AuditEventResponse response) { - this.response = Optional.ofNullable(response); - return this; - } - - /** - *

Parent account ID of the account that made the request, if any.

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

ID of the account that made the request.

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

IDs for resources involved in the event. Presented in {resourceType}/{resourceID} format. For example, VAULT/cd1d815aa09b4cbfbb803bd20349f202.

- */ - @JsonSetter(value = "resourceIDs", nulls = Nulls.SKIP) - public Builder resourceIDs(Optional> resourceIDs) { - this.resourceIDs = resourceIDs; - return this; - } - - public Builder resourceIDs(List resourceIDs) { - this.resourceIDs = Optional.ofNullable(resourceIDs); - return this; - } - - public V1AuditResponseEvent build() { - return new V1AuditResponseEvent( - context, request, response, parentAccountId, accountId, resourceIDs, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java b/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java deleted file mode 100644 index c77bc31f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1AuditResponseEventRequest.java +++ /dev/null @@ -1,339 +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 = V1AuditResponseEventRequest.Builder.class) -public final class V1AuditResponseEventRequest { - private final Optional data; - - private final Optional apiName; - - private final Optional workspaceId; - - private final Optional vaultId; - - private final Optional> tags; - - private final Optional timestamp; - - private final Optional actionType; - - private final Optional resourceType; - - private final Optional httpInfo; - - private final Map additionalProperties; - - private V1AuditResponseEventRequest( - Optional data, - Optional apiName, - Optional workspaceId, - Optional vaultId, - Optional> tags, - Optional timestamp, - Optional actionType, - Optional resourceType, - Optional httpInfo, - Map additionalProperties) { - this.data = data; - this.apiName = apiName; - this.workspaceId = workspaceId; - this.vaultId = vaultId; - this.tags = tags; - this.timestamp = timestamp; - this.actionType = actionType; - this.resourceType = resourceType; - this.httpInfo = httpInfo; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("data") - public Optional getData() { - return data; - } - - /** - * @return API name. - */ - @JsonProperty("apiName") - public Optional getApiName() { - return apiName; - } - - /** - * @return The workspaceID (if any) of the request. - */ - @JsonProperty("workspaceID") - public Optional getWorkspaceId() { - return workspaceId; - } - - /** - * @return The vaultID (if any) of the request. - */ - @JsonProperty("vaultID") - public Optional getVaultId() { - return vaultId; - } - - /** - * @return Tags associated with the event. To provide better search capabilities. Like login. - */ - @JsonProperty("tags") - public Optional> getTags() { - return tags; - } - - /** - * @return time when this request is generated, use extention method to set it. - */ - @JsonProperty("timestamp") - public Optional getTimestamp() { - return timestamp; - } - - @JsonProperty("actionType") - public Optional getActionType() { - return actionType; - } - - @JsonProperty("resourceType") - public Optional getResourceType() { - return resourceType; - } - - @JsonProperty("httpInfo") - public Optional getHttpInfo() { - return httpInfo; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1AuditResponseEventRequest && equalTo((V1AuditResponseEventRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1AuditResponseEventRequest other) { - return data.equals(other.data) - && apiName.equals(other.apiName) - && workspaceId.equals(other.workspaceId) - && vaultId.equals(other.vaultId) - && tags.equals(other.tags) - && timestamp.equals(other.timestamp) - && actionType.equals(other.actionType) - && resourceType.equals(other.resourceType) - && httpInfo.equals(other.httpInfo); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.data, - this.apiName, - this.workspaceId, - this.vaultId, - this.tags, - this.timestamp, - this.actionType, - this.resourceType, - this.httpInfo); - } - - @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 data = Optional.empty(); - - private Optional apiName = Optional.empty(); - - private Optional workspaceId = Optional.empty(); - - private Optional vaultId = Optional.empty(); - - private Optional> tags = Optional.empty(); - - private Optional timestamp = Optional.empty(); - - private Optional actionType = Optional.empty(); - - private Optional resourceType = Optional.empty(); - - private Optional httpInfo = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1AuditResponseEventRequest other) { - data(other.getData()); - apiName(other.getApiName()); - workspaceId(other.getWorkspaceId()); - vaultId(other.getVaultId()); - tags(other.getTags()); - timestamp(other.getTimestamp()); - actionType(other.getActionType()); - resourceType(other.getResourceType()); - httpInfo(other.getHttpInfo()); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional data) { - this.data = data; - return this; - } - - public Builder data(AuditEventData data) { - this.data = Optional.ofNullable(data); - return this; - } - - /** - *

API name.

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

The workspaceID (if any) of the request.

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

The vaultID (if any) of the request.

- */ - @JsonSetter(value = "vaultID", 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; - } - - /** - *

Tags associated with the event. To provide better search capabilities. Like login.

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

time when this request is generated, use extention method to set it.

- */ - @JsonSetter(value = "timestamp", nulls = Nulls.SKIP) - public Builder timestamp(Optional timestamp) { - this.timestamp = timestamp; - return this; - } - - public Builder timestamp(String timestamp) { - this.timestamp = Optional.ofNullable(timestamp); - return this; - } - - @JsonSetter(value = "actionType", nulls = Nulls.SKIP) - public Builder actionType(Optional actionType) { - this.actionType = actionType; - return this; - } - - public Builder actionType(RequestActionType actionType) { - this.actionType = Optional.ofNullable(actionType); - return this; - } - - @JsonSetter(value = "resourceType", nulls = Nulls.SKIP) - public Builder resourceType(Optional resourceType) { - this.resourceType = resourceType; - return this; - } - - public Builder resourceType(AuditEventAuditResourceType resourceType) { - this.resourceType = Optional.ofNullable(resourceType); - return this; - } - - @JsonSetter(value = "httpInfo", nulls = Nulls.SKIP) - public Builder httpInfo(Optional httpInfo) { - this.httpInfo = httpInfo; - return this; - } - - public Builder httpInfo(AuditEventHttpInfo httpInfo) { - this.httpInfo = Optional.ofNullable(httpInfo); - return this; - } - - public V1AuditResponseEventRequest build() { - return new V1AuditResponseEventRequest( - data, - apiName, - workspaceId, - vaultId, - tags, - timestamp, - actionType, - resourceType, - httpInfo, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.java deleted file mode 100644 index 03d752d9..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1BatchOperationResponse.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 = V1BatchOperationResponse.Builder.class) -public final class V1BatchOperationResponse { - private final Optional vaultId; - - private final Optional>> responses; - - private final Map additionalProperties; - - private V1BatchOperationResponse( - Optional vaultId, - Optional>> responses, - Map additionalProperties) { - this.vaultId = vaultId; - this.responses = responses; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the vault. - */ - @JsonProperty("vaultID") - public Optional getVaultId() { - return vaultId; - } - - /** - * @return Responses in the same order as in the request. Responses have the same payload structure as their corresponding APIs: <br/><ul><li>POST returns an Insert Records response.</li><li>PUT returns an Update Record response.</li><li>GET returns a Get Record response.</li><li>DELETE returns a Delete Record response.</li></ul> - */ - @JsonProperty("responses") - public Optional>> getResponses() { - return responses; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1BatchOperationResponse && equalTo((V1BatchOperationResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1BatchOperationResponse other) { - return vaultId.equals(other.vaultId) && responses.equals(other.responses); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.vaultId, this.responses); - } - - @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(); - - private Optional>> responses = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1BatchOperationResponse other) { - vaultId(other.getVaultId()); - responses(other.getResponses()); - return this; - } - - /** - *

ID of the vault.

- */ - @JsonSetter(value = "vaultID", 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; - } - - /** - *

Responses in the same order as in the request. Responses have the same payload structure as their corresponding APIs: <br/><ul><li>POST returns an Insert Records response.</li><li>PUT returns an Update Record response.</li><li>GET returns a Get Record response.</li><li>DELETE returns a Delete Record response.</li></ul>

- */ - @JsonSetter(value = "responses", nulls = Nulls.SKIP) - public Builder responses(Optional>> responses) { - this.responses = responses; - return this; - } - - public Builder responses(List> responses) { - this.responses = Optional.ofNullable(responses); - return this; - } - - public V1BatchOperationResponse build() { - return new V1BatchOperationResponse(vaultId, responses, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java b/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java deleted file mode 100644 index 39eb2e68..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1BatchRecord.java +++ /dev/null @@ -1,382 +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 = V1BatchRecord.Builder.class) -public final class V1BatchRecord { - private final Optional> fields; - - private final Optional tableName; - - private final Optional method; - - private final Optional batchId; - - private final Optional redaction; - - private final Optional tokenization; - - private final Optional id; - - private final Optional downloadUrl; - - private final Optional upsert; - - private final Optional> tokens; - - private final Map additionalProperties; - - private V1BatchRecord( - Optional> fields, - Optional tableName, - Optional method, - Optional batchId, - Optional redaction, - Optional tokenization, - Optional id, - Optional downloadUrl, - Optional upsert, - Optional> tokens, - Map additionalProperties) { - this.fields = fields; - this.tableName = tableName; - this.method = method; - this.batchId = batchId; - this.redaction = redaction; - this.tokenization = tokenization; - this.id = id; - this.downloadUrl = downloadUrl; - this.upsert = upsert; - this.tokens = tokens; - this.additionalProperties = additionalProperties; - } - - /** - * @return Field and value key pairs. For example, {'field_1':'value_1', 'field_2':'value_2'}. Only valid when method is POST or PUT. - */ - @JsonProperty("fields") - public Optional> getFields() { - return fields; - } - - /** - * @return Name of the table to perform the operation on. - */ - @JsonProperty("tableName") - public Optional getTableName() { - return tableName; - } - - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - /** - * @return ID to group operations by. Operations in the same group are executed sequentially. - */ - @JsonProperty("batchID") - public Optional getBatchId() { - return batchId; - } - - @JsonProperty("redaction") - public Optional getRedaction() { - return redaction; - } - - /** - * @return If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified. - */ - @JsonProperty("tokenization") - public Optional getTokenization() { - return tokenization; - } - - /** - * @return skyflow_id for the record. Only valid when method is GET, DELETE, or PUT. - */ - @JsonProperty("ID") - public Optional getId() { - return id; - } - - /** - * @return If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean. - */ - @JsonProperty("downloadURL") - public Optional getDownloadUrl() { - return downloadUrl; - } - - /** - * @return Column that stores primary keys for upsert operations. The column must be marked as unique in the vault schema. Only valid when method is POST. - */ - @JsonProperty("upsert") - public Optional getUpsert() { - return upsert; - } - - /** - * @return Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}. - */ - @JsonProperty("tokens") - public Optional> getTokens() { - return tokens; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1BatchRecord && equalTo((V1BatchRecord) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1BatchRecord other) { - return fields.equals(other.fields) - && tableName.equals(other.tableName) - && method.equals(other.method) - && batchId.equals(other.batchId) - && redaction.equals(other.redaction) - && tokenization.equals(other.tokenization) - && id.equals(other.id) - && downloadUrl.equals(other.downloadUrl) - && upsert.equals(other.upsert) - && tokens.equals(other.tokens); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.fields, - this.tableName, - this.method, - this.batchId, - this.redaction, - this.tokenization, - this.id, - this.downloadUrl, - this.upsert, - this.tokens); - } - - @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> fields = Optional.empty(); - - private Optional tableName = Optional.empty(); - - private Optional method = Optional.empty(); - - private Optional batchId = Optional.empty(); - - private Optional redaction = Optional.empty(); - - private Optional tokenization = Optional.empty(); - - private Optional id = Optional.empty(); - - private Optional downloadUrl = Optional.empty(); - - private Optional upsert = Optional.empty(); - - private Optional> tokens = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1BatchRecord other) { - fields(other.getFields()); - tableName(other.getTableName()); - method(other.getMethod()); - batchId(other.getBatchId()); - redaction(other.getRedaction()); - tokenization(other.getTokenization()); - id(other.getId()); - downloadUrl(other.getDownloadUrl()); - upsert(other.getUpsert()); - tokens(other.getTokens()); - return this; - } - - /** - *

Field and value key pairs. For example, {'field_1':'value_1', 'field_2':'value_2'}. Only valid when method is POST or PUT.

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

Name of the table to perform the operation on.

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

ID to group operations by. Operations in the same group are executed sequentially.

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

If true, this operation returns tokens for fields with tokenization enabled. Only applicable if skyflow_id values are specified.

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

skyflow_id for the record. Only valid when method is GET, DELETE, or PUT.

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

If true, returns download URLs for fields with a file data type. URLs are valid for 15 minutes. If virus scanning is enabled, only returns if the file is clean.

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

Column that stores primary keys for upsert operations. The column must be marked as unique in the vault schema. Only valid when method is POST.

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

Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}.

- */ - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public Builder tokens(Optional> tokens) { - this.tokens = tokens; - return this; - } - - public Builder tokens(Map tokens) { - this.tokens = Optional.ofNullable(tokens); - return this; - } - - public V1BatchRecord build() { - return new V1BatchRecord( - fields, - tableName, - method, - batchId, - redaction, - tokenization, - id, - downloadUrl, - upsert, - tokens, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java deleted file mode 100644 index cf3a3326..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1BinListResponse.java +++ /dev/null @@ -1,102 +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 = V1BinListResponse.Builder.class) -public final class V1BinListResponse { - private final Optional> cardsData; - - private final Map additionalProperties; - - private V1BinListResponse(Optional> cardsData, Map additionalProperties) { - this.cardsData = cardsData; - this.additionalProperties = additionalProperties; - } - - /** - * @return Card metadata associated with the specified BIN. - */ - @JsonProperty("cards_data") - public Optional> getCardsData() { - return cardsData; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1BinListResponse && equalTo((V1BinListResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1BinListResponse other) { - return cardsData.equals(other.cardsData); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cardsData); - } - - @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> cardsData = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1BinListResponse other) { - cardsData(other.getCardsData()); - return this; - } - - /** - *

Card metadata associated with the specified BIN.

- */ - @JsonSetter(value = "cards_data", nulls = Nulls.SKIP) - public Builder cardsData(Optional> cardsData) { - this.cardsData = cardsData; - return this; - } - - public Builder cardsData(List cardsData) { - this.cardsData = Optional.ofNullable(cardsData); - return this; - } - - public V1BinListResponse build() { - return new V1BinListResponse(cardsData, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java deleted file mode 100644 index 5f781686..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1BulkDeleteRecordResponse.java +++ /dev/null @@ -1,103 +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 = V1BulkDeleteRecordResponse.Builder.class) -public final class V1BulkDeleteRecordResponse { - private final Optional> recordIdResponse; - - private final Map additionalProperties; - - private V1BulkDeleteRecordResponse( - Optional> recordIdResponse, Map additionalProperties) { - this.recordIdResponse = recordIdResponse; - this.additionalProperties = additionalProperties; - } - - /** - * @return IDs for the deleted records, or * if all records were deleted. - */ - @JsonProperty("RecordIDResponse") - public Optional> getRecordIdResponse() { - return recordIdResponse; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1BulkDeleteRecordResponse && equalTo((V1BulkDeleteRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1BulkDeleteRecordResponse other) { - return recordIdResponse.equals(other.recordIdResponse); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recordIdResponse); - } - - @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> recordIdResponse = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1BulkDeleteRecordResponse other) { - recordIdResponse(other.getRecordIdResponse()); - return this; - } - - /** - *

IDs for the deleted records, or * if all records were deleted.

- */ - @JsonSetter(value = "RecordIDResponse", nulls = Nulls.SKIP) - public Builder recordIdResponse(Optional> recordIdResponse) { - this.recordIdResponse = recordIdResponse; - return this; - } - - public Builder recordIdResponse(List recordIdResponse) { - this.recordIdResponse = Optional.ofNullable(recordIdResponse); - return this; - } - - public V1BulkDeleteRecordResponse build() { - return new V1BulkDeleteRecordResponse(recordIdResponse, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java deleted file mode 100644 index 70d31034..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1BulkGetRecordResponse.java +++ /dev/null @@ -1,102 +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 = V1BulkGetRecordResponse.Builder.class) -public final class V1BulkGetRecordResponse { - private final Optional> records; - - private final Map additionalProperties; - - private V1BulkGetRecordResponse(Optional> records, Map additionalProperties) { - this.records = records; - this.additionalProperties = additionalProperties; - } - - /** - * @return The specified records. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1BulkGetRecordResponse && equalTo((V1BulkGetRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1BulkGetRecordResponse other) { - return records.equals(other.records); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records); - } - - @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> records = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1BulkGetRecordResponse other) { - records(other.getRecords()); - return this; - } - - /** - *

The specified records.

- */ - @JsonSetter(value = "records", nulls = Nulls.SKIP) - public Builder records(Optional> records) { - this.records = records; - return this; - } - - public Builder records(List records) { - this.records = Optional.ofNullable(records); - return this; - } - - public V1BulkGetRecordResponse build() { - return new V1BulkGetRecordResponse(records, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1Byot.java b/src/main/java/com/skyflow/generated/rest/types/V1Byot.java deleted file mode 100644 index 819fdb42..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1Byot.java +++ /dev/null @@ -1,26 +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 V1Byot { - DISABLE("DISABLE"), - - ENABLE("ENABLE"), - - ENABLE_STRICT("ENABLE_STRICT"); - - private final String value; - - V1Byot(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/V1Card.java b/src/main/java/com/skyflow/generated/rest/types/V1Card.java deleted file mode 100644 index d19d3099..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1Card.java +++ /dev/null @@ -1,362 +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 = V1Card.Builder.class) -public final class V1Card { - private final Optional bin; - - private final Optional issuerName; - - private final Optional countryCode; - - private final Optional currency; - - private final Optional cardType; - - private final Optional cardCategory; - - private final Optional cardScheme; - - private final Optional cardLastFourDigits; - - private final Optional cardExpiry; - - private final Map additionalProperties; - - private V1Card( - Optional bin, - Optional issuerName, - Optional countryCode, - Optional currency, - Optional cardType, - Optional cardCategory, - Optional cardScheme, - Optional cardLastFourDigits, - Optional cardExpiry, - Map additionalProperties) { - this.bin = bin; - this.issuerName = issuerName; - this.countryCode = countryCode; - this.currency = currency; - this.cardType = cardType; - this.cardCategory = cardCategory; - this.cardScheme = cardScheme; - this.cardLastFourDigits = cardLastFourDigits; - this.cardExpiry = cardExpiry; - this.additionalProperties = additionalProperties; - } - - /** - * @return BIN of the card. - */ - @JsonProperty("BIN") - public Optional getBin() { - return bin; - } - - /** - * @return Name of the card issuer bank. - */ - @JsonProperty("issuer_name") - public Optional getIssuerName() { - return issuerName; - } - - /** - * @return Country code of the card. - */ - @JsonProperty("country_code") - public Optional getCountryCode() { - return countryCode; - } - - /** - * @return Currency of the card. - */ - @JsonProperty("currency") - public Optional getCurrency() { - return currency; - } - - /** - * @return Type of the card. - */ - @JsonProperty("card_type") - public Optional getCardType() { - return cardType; - } - - /** - * @return Category of the card. - */ - @JsonProperty("card_category") - public Optional getCardCategory() { - return cardCategory; - } - - /** - * @return Scheme of the card. - */ - @JsonProperty("card_scheme") - public Optional getCardScheme() { - return cardScheme; - } - - /** - * @return Last four digits of the card number. - */ - @JsonProperty("card_last_four_digits") - public Optional getCardLastFourDigits() { - return cardLastFourDigits; - } - - /** - * @return Expiry date of the card. - */ - @JsonProperty("card_expiry") - public Optional getCardExpiry() { - return cardExpiry; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Card && equalTo((V1Card) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1Card other) { - return bin.equals(other.bin) - && issuerName.equals(other.issuerName) - && countryCode.equals(other.countryCode) - && currency.equals(other.currency) - && cardType.equals(other.cardType) - && cardCategory.equals(other.cardCategory) - && cardScheme.equals(other.cardScheme) - && cardLastFourDigits.equals(other.cardLastFourDigits) - && cardExpiry.equals(other.cardExpiry); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.bin, - this.issuerName, - this.countryCode, - this.currency, - this.cardType, - this.cardCategory, - this.cardScheme, - this.cardLastFourDigits, - this.cardExpiry); - } - - @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 bin = Optional.empty(); - - private Optional issuerName = Optional.empty(); - - private Optional countryCode = Optional.empty(); - - private Optional currency = Optional.empty(); - - private Optional cardType = Optional.empty(); - - private Optional cardCategory = Optional.empty(); - - private Optional cardScheme = Optional.empty(); - - private Optional cardLastFourDigits = Optional.empty(); - - private Optional cardExpiry = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1Card other) { - bin(other.getBin()); - issuerName(other.getIssuerName()); - countryCode(other.getCountryCode()); - currency(other.getCurrency()); - cardType(other.getCardType()); - cardCategory(other.getCardCategory()); - cardScheme(other.getCardScheme()); - cardLastFourDigits(other.getCardLastFourDigits()); - cardExpiry(other.getCardExpiry()); - return this; - } - - /** - *

BIN of the card.

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

Name of the card issuer bank.

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

Country code of the card.

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

Currency of the card.

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

Type of the card.

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

Category of the card.

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

Scheme of the card.

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

Last four digits of the card number.

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

Expiry date of the card.

- */ - @JsonSetter(value = "card_expiry", nulls = Nulls.SKIP) - public Builder cardExpiry(Optional cardExpiry) { - this.cardExpiry = cardExpiry; - return this; - } - - public Builder cardExpiry(String cardExpiry) { - this.cardExpiry = Optional.ofNullable(cardExpiry); - return this; - } - - public V1Card build() { - return new V1Card( - bin, - issuerName, - countryCode, - currency, - cardType, - cardCategory, - cardScheme, - cardLastFourDigits, - cardExpiry, - additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.java deleted file mode 100644 index efdb8e42..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DeleteFileResponse.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 = V1DeleteFileResponse.Builder.class) -public final class V1DeleteFileResponse { - private final Optional skyflowId; - - private final Optional deleted; - - private final Map additionalProperties; - - private V1DeleteFileResponse( - Optional skyflowId, Optional deleted, Map additionalProperties) { - this.skyflowId = skyflowId; - this.deleted = deleted; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the record. - */ - @JsonProperty("skyflow_id") - public Optional getSkyflowId() { - return skyflowId; - } - - /** - * @return If true, the file was deleted. - */ - @JsonProperty("deleted") - public Optional getDeleted() { - return deleted; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DeleteFileResponse && equalTo((V1DeleteFileResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DeleteFileResponse other) { - return skyflowId.equals(other.skyflowId) && deleted.equals(other.deleted); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.skyflowId, this.deleted); - } - - @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 deleted = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DeleteFileResponse other) { - skyflowId(other.getSkyflowId()); - deleted(other.getDeleted()); - return this; - } - - /** - *

ID of the record.

- */ - @JsonSetter(value = "skyflow_id", 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; - } - - /** - *

If true, the file was deleted.

- */ - @JsonSetter(value = "deleted", nulls = Nulls.SKIP) - public Builder deleted(Optional deleted) { - this.deleted = deleted; - return this; - } - - public Builder deleted(Boolean deleted) { - this.deleted = Optional.ofNullable(deleted); - return this; - } - - public V1DeleteFileResponse build() { - return new V1DeleteFileResponse(skyflowId, deleted, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.java deleted file mode 100644 index 700bfe2f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DeleteRecordResponse.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 = V1DeleteRecordResponse.Builder.class) -public final class V1DeleteRecordResponse { - private final Optional skyflowId; - - private final Optional deleted; - - private final Map additionalProperties; - - private V1DeleteRecordResponse( - Optional skyflowId, Optional deleted, Map additionalProperties) { - this.skyflowId = skyflowId; - this.deleted = deleted; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the deleted record. - */ - @JsonProperty("skyflow_id") - public Optional getSkyflowId() { - return skyflowId; - } - - /** - * @return If true, the record was deleted. - */ - @JsonProperty("deleted") - public Optional getDeleted() { - return deleted; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DeleteRecordResponse && equalTo((V1DeleteRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DeleteRecordResponse other) { - return skyflowId.equals(other.skyflowId) && deleted.equals(other.deleted); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.skyflowId, this.deleted); - } - - @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 deleted = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DeleteRecordResponse other) { - skyflowId(other.getSkyflowId()); - deleted(other.getDeleted()); - return this; - } - - /** - *

ID of the deleted record.

- */ - @JsonSetter(value = "skyflow_id", 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; - } - - /** - *

If true, the record was deleted.

- */ - @JsonSetter(value = "deleted", nulls = Nulls.SKIP) - public Builder deleted(Optional deleted) { - this.deleted = deleted; - return this; - } - - public Builder deleted(Boolean deleted) { - this.deleted = Optional.ofNullable(deleted); - return this; - } - - public V1DeleteRecordResponse build() { - return new V1DeleteRecordResponse(skyflowId, deleted, 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/V1DetectStatusResponseStatus.java b/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java deleted file mode 100644 index c819b167..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetectStatusResponseStatus.java +++ /dev/null @@ -1,28 +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 V1DetectStatusResponseStatus { - UNKNOWN("UNKNOWN"), - - FAILED("FAILED"), - - SUCCESS("SUCCESS"), - - IN_PROGRESS("IN_PROGRESS"); - - private final String value; - - V1DetectStatusResponseStatus(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/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/V1DetokenizeRecordRequest.java b/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.java deleted file mode 100644 index 5b6927d1..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordRequest.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 = V1DetokenizeRecordRequest.Builder.class) -public final class V1DetokenizeRecordRequest { - private final Optional token; - - private final Optional redaction; - - private final Map additionalProperties; - - private V1DetokenizeRecordRequest( - Optional token, - Optional redaction, - Map additionalProperties) { - this.token = token; - this.redaction = redaction; - this.additionalProperties = additionalProperties; - } - - /** - * @return Token that identifies the record to detokenize. - */ - @JsonProperty("token") - public Optional getToken() { - return token; - } - - @JsonProperty("redaction") - public Optional getRedaction() { - return redaction; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetokenizeRecordRequest && equalTo((V1DetokenizeRecordRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetokenizeRecordRequest other) { - return token.equals(other.token) && redaction.equals(other.redaction); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token, this.redaction); - } - - @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 token = Optional.empty(); - - private Optional redaction = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetokenizeRecordRequest other) { - token(other.getToken()); - redaction(other.getRedaction()); - return this; - } - - /** - *

Token that identifies the record to detokenize.

- */ - @JsonSetter(value = "token", nulls = Nulls.SKIP) - public Builder token(Optional token) { - this.token = token; - return this; - } - - public Builder token(String token) { - this.token = Optional.ofNullable(token); - return this; - } - - @JsonSetter(value = "redaction", nulls = Nulls.SKIP) - public Builder redaction(Optional redaction) { - this.redaction = redaction; - return this; - } - - public Builder redaction(RedactionEnumRedaction redaction) { - this.redaction = Optional.ofNullable(redaction); - return this; - } - - public V1DetokenizeRecordRequest build() { - return new V1DetokenizeRecordRequest(token, redaction, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java deleted file mode 100644 index 423abfe8..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeRecordResponse.java +++ /dev/null @@ -1,187 +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 = V1DetokenizeRecordResponse.Builder.class) -public final class V1DetokenizeRecordResponse { - private final Optional token; - - private final Optional valueType; - - private final Optional value; - - private final Optional error; - - private final Map additionalProperties; - - private V1DetokenizeRecordResponse( - Optional token, - Optional valueType, - Optional value, - Optional error, - Map additionalProperties) { - this.token = token; - this.valueType = valueType; - this.value = value; - this.error = error; - this.additionalProperties = additionalProperties; - } - - /** - * @return Token of the record. - */ - @JsonProperty("token") - public Optional getToken() { - return token; - } - - @JsonProperty("valueType") - public Optional getValueType() { - return valueType; - } - - /** - * @return Data corresponding to the token. - */ - @JsonProperty("value") - public Optional getValue() { - return value; - } - - /** - * @return Error if token isn't found. - */ - @JsonProperty("error") - public Optional getError() { - return error; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetokenizeRecordResponse && equalTo((V1DetokenizeRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetokenizeRecordResponse other) { - return token.equals(other.token) - && valueType.equals(other.valueType) - && value.equals(other.value) - && error.equals(other.error); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token, this.valueType, this.value, this.error); - } - - @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 token = Optional.empty(); - - private Optional valueType = Optional.empty(); - - private Optional value = Optional.empty(); - - private Optional error = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetokenizeRecordResponse other) { - token(other.getToken()); - valueType(other.getValueType()); - value(other.getValue()); - error(other.getError()); - return this; - } - - /** - *

Token of the record.

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

Data corresponding to the token.

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

Error if token isn't found.

- */ - @JsonSetter(value = "error", nulls = Nulls.SKIP) - public Builder error(Optional error) { - this.error = error; - return this; - } - - public Builder error(String error) { - this.error = Optional.ofNullable(error); - return this; - } - - public V1DetokenizeRecordResponse build() { - return new V1DetokenizeRecordResponse(token, valueType, value, error, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java deleted file mode 100644 index 20d7d8e4..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1DetokenizeResponse.java +++ /dev/null @@ -1,103 +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 = V1DetokenizeResponse.Builder.class) -public final class V1DetokenizeResponse { - private final Optional> records; - - private final Map additionalProperties; - - private V1DetokenizeResponse( - Optional> records, Map additionalProperties) { - this.records = records; - this.additionalProperties = additionalProperties; - } - - /** - * @return Records corresponding to the specified tokens. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1DetokenizeResponse && equalTo((V1DetokenizeResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1DetokenizeResponse other) { - return records.equals(other.records); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records); - } - - @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> records = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1DetokenizeResponse other) { - records(other.getRecords()); - return this; - } - - /** - *

Records corresponding to the specified tokens.

- */ - @JsonSetter(value = "records", nulls = Nulls.SKIP) - public Builder records(Optional> records) { - this.records = records; - return this; - } - - public Builder records(List records) { - this.records = Optional.ofNullable(records); - return this; - } - - public V1DetokenizeResponse build() { - return new V1DetokenizeResponse(records, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java b/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.java deleted file mode 100644 index 8d520d3b..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1FieldRecords.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 = V1FieldRecords.Builder.class) -public final class V1FieldRecords { - private final Optional> fields; - - private final Optional> tokens; - - private final Map additionalProperties; - - private V1FieldRecords( - Optional> fields, - Optional> tokens, - Map additionalProperties) { - this.fields = fields; - this.tokens = tokens; - this.additionalProperties = additionalProperties; - } - - /** - * @return Fields and values for the record. For example, {'field_1':'value_1', 'field_2':'value_2'}. - */ - @JsonProperty("fields") - public Optional> getFields() { - return fields; - } - - /** - * @return Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}. - */ - @JsonProperty("tokens") - public Optional> getTokens() { - return tokens; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1FieldRecords && equalTo((V1FieldRecords) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1FieldRecords other) { - return fields.equals(other.fields) && tokens.equals(other.tokens); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.fields, this.tokens); - } - - @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> fields = Optional.empty(); - - private Optional> tokens = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1FieldRecords other) { - fields(other.getFields()); - tokens(other.getTokens()); - return this; - } - - /** - *

Fields and values for the record. For example, {'field_1':'value_1', 'field_2':'value_2'}.

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

Fields and tokens for the record. For example, {'field_1':'token_1', 'field_2':'token_2'}.

- */ - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public Builder tokens(Optional> tokens) { - this.tokens = tokens; - return this; - } - - public Builder tokens(Map tokens) { - this.tokens = Optional.ofNullable(tokens); - return this; - } - - public V1FieldRecords build() { - return new V1FieldRecords(fields, tokens, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java b/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java deleted file mode 100644 index afe545fe..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1FileAvScanStatus.java +++ /dev/null @@ -1,38 +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 V1FileAvScanStatus { - SCAN_NONE("SCAN_NONE"), - - SCAN_CLEAN("SCAN_CLEAN"), - - SCAN_INFECTED("SCAN_INFECTED"), - - SCAN_DELETED("SCAN_DELETED"), - - SCAN_ERROR("SCAN_ERROR"), - - SCAN_PENDING("SCAN_PENDING"), - - SCAN_UNSCANNABLE("SCAN_UNSCANNABLE"), - - SCAN_FILE_NOT_FOUND("SCAN_FILE_NOT_FOUND"), - - SCAN_INVALID("SCAN_INVALID"); - - private final String value; - - V1FileAvScanStatus(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/V1FileDataFormat.java b/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java deleted file mode 100644 index a384af7f..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1FileDataFormat.java +++ /dev/null @@ -1,58 +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 V1FileDataFormat { - BMP("bmp"), - - 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"); - - private final String value; - - V1FileDataFormat(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/V1GetFileScanStatusResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java deleted file mode 100644 index 27100e6d..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1GetFileScanStatusResponse.java +++ /dev/null @@ -1,96 +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 = V1GetFileScanStatusResponse.Builder.class) -public final class V1GetFileScanStatusResponse { - private final Optional avScanStatus; - - private final Map additionalProperties; - - private V1GetFileScanStatusResponse( - Optional avScanStatus, Map additionalProperties) { - this.avScanStatus = avScanStatus; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("av_scan_status") - public Optional getAvScanStatus() { - return avScanStatus; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1GetFileScanStatusResponse && equalTo((V1GetFileScanStatusResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1GetFileScanStatusResponse other) { - return avScanStatus.equals(other.avScanStatus); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.avScanStatus); - } - - @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 avScanStatus = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1GetFileScanStatusResponse other) { - avScanStatus(other.getAvScanStatus()); - return this; - } - - @JsonSetter(value = "av_scan_status", nulls = Nulls.SKIP) - public Builder avScanStatus(Optional avScanStatus) { - this.avScanStatus = avScanStatus; - return this; - } - - public Builder avScanStatus(V1FileAvScanStatus avScanStatus) { - this.avScanStatus = Optional.ofNullable(avScanStatus); - return this; - } - - public V1GetFileScanStatusResponse build() { - return new V1GetFileScanStatusResponse(avScanStatus, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java deleted file mode 100644 index 6a8689ae..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1GetQueryResponse.java +++ /dev/null @@ -1,102 +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 = V1GetQueryResponse.Builder.class) -public final class V1GetQueryResponse { - private final Optional> records; - - private final Map additionalProperties; - - private V1GetQueryResponse(Optional> records, Map additionalProperties) { - this.records = records; - this.additionalProperties = additionalProperties; - } - - /** - * @return Records returned by the query. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1GetQueryResponse && equalTo((V1GetQueryResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1GetQueryResponse other) { - return records.equals(other.records); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records); - } - - @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> records = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1GetQueryResponse other) { - records(other.getRecords()); - return this; - } - - /** - *

Records returned by the query.

- */ - @JsonSetter(value = "records", nulls = Nulls.SKIP) - public Builder records(Optional> records) { - this.records = records; - return this; - } - - public Builder records(List records) { - this.records = Optional.ofNullable(records); - return this; - } - - public V1GetQueryResponse build() { - return new V1GetQueryResponse(records, 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/V1InsertRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java deleted file mode 100644 index 724bee91..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1InsertRecordResponse.java +++ /dev/null @@ -1,103 +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 = V1InsertRecordResponse.Builder.class) -public final class V1InsertRecordResponse { - private final Optional> records; - - private final Map additionalProperties; - - private V1InsertRecordResponse( - Optional> records, Map additionalProperties) { - this.records = records; - this.additionalProperties = additionalProperties; - } - - /** - * @return Identifiers for the inserted records. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1InsertRecordResponse && equalTo((V1InsertRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1InsertRecordResponse other) { - return records.equals(other.records); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records); - } - - @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> records = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1InsertRecordResponse other) { - records(other.getRecords()); - return this; - } - - /** - *

Identifiers for the inserted records.

- */ - @JsonSetter(value = "records", nulls = Nulls.SKIP) - public Builder records(Optional> records) { - this.records = records; - return this; - } - - public Builder records(List records) { - this.records = Optional.ofNullable(records); - return this; - } - - public V1InsertRecordResponse build() { - return new V1InsertRecordResponse(records, 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/V1MemberType.java b/src/main/java/com/skyflow/generated/rest/types/V1MemberType.java deleted file mode 100644 index dacca1b9..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1MemberType.java +++ /dev/null @@ -1,26 +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 V1MemberType { - NONE("NONE"), - - USER("USER"), - - SERVICE_ACCOUNT("SERVICE_ACCOUNT"); - - private final String value; - - V1MemberType(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/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/V1RecordMetaProperties.java b/src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.java deleted file mode 100644 index 419b8e16..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1RecordMetaProperties.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 = V1RecordMetaProperties.Builder.class) -public final class V1RecordMetaProperties { - private final Optional skyflowId; - - private final Optional> tokens; - - private final Map additionalProperties; - - private V1RecordMetaProperties( - Optional skyflowId, - Optional> tokens, - Map additionalProperties) { - this.skyflowId = skyflowId; - this.tokens = tokens; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the inserted record. - */ - @JsonProperty("skyflow_id") - public Optional getSkyflowId() { - return skyflowId; - } - - /** - * @return Tokens for the record. - */ - @JsonProperty("tokens") - public Optional> getTokens() { - return tokens; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1RecordMetaProperties && equalTo((V1RecordMetaProperties) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1RecordMetaProperties other) { - return skyflowId.equals(other.skyflowId) && tokens.equals(other.tokens); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.skyflowId, this.tokens); - } - - @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> tokens = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1RecordMetaProperties other) { - skyflowId(other.getSkyflowId()); - tokens(other.getTokens()); - return this; - } - - /** - *

ID of the inserted record.

- */ - @JsonSetter(value = "skyflow_id", 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; - } - - /** - *

Tokens for the record.

- */ - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public Builder tokens(Optional> tokens) { - this.tokens = tokens; - return this; - } - - public Builder tokens(Map tokens) { - this.tokens = Optional.ofNullable(tokens); - return this; - } - - public V1RecordMetaProperties build() { - return new V1RecordMetaProperties(skyflowId, tokens, 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/generated/rest/types/V1TokenizeRecordRequest.java b/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.java deleted file mode 100644 index 03c5ef89..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordRequest.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 = V1TokenizeRecordRequest.Builder.class) -public final class V1TokenizeRecordRequest { - private final Optional value; - - private final Optional columnGroup; - - private final Map additionalProperties; - - private V1TokenizeRecordRequest( - Optional value, Optional columnGroup, Map additionalProperties) { - this.value = value; - this.columnGroup = columnGroup; - this.additionalProperties = additionalProperties; - } - - /** - * @return Existing value to return a token for. - */ - @JsonProperty("value") - public Optional getValue() { - return value; - } - - /** - * @return Name of the column group that the value belongs to. - */ - @JsonProperty("columnGroup") - public Optional getColumnGroup() { - return columnGroup; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1TokenizeRecordRequest && equalTo((V1TokenizeRecordRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1TokenizeRecordRequest other) { - return value.equals(other.value) && columnGroup.equals(other.columnGroup); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value, this.columnGroup); - } - - @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 value = Optional.empty(); - - private Optional columnGroup = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1TokenizeRecordRequest other) { - value(other.getValue()); - columnGroup(other.getColumnGroup()); - return this; - } - - /** - *

Existing value to return a token for.

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

Name of the column group that the value belongs to.

- */ - @JsonSetter(value = "columnGroup", nulls = Nulls.SKIP) - public Builder columnGroup(Optional columnGroup) { - this.columnGroup = columnGroup; - return this; - } - - public Builder columnGroup(String columnGroup) { - this.columnGroup = Optional.ofNullable(columnGroup); - return this; - } - - public V1TokenizeRecordRequest build() { - return new V1TokenizeRecordRequest(value, columnGroup, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.java deleted file mode 100644 index 4cd41dd0..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1TokenizeRecordResponse.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 = V1TokenizeRecordResponse.Builder.class) -public final class V1TokenizeRecordResponse { - private final Optional token; - - private final Map additionalProperties; - - private V1TokenizeRecordResponse(Optional token, Map additionalProperties) { - this.token = token; - this.additionalProperties = additionalProperties; - } - - /** - * @return Token corresponding to a value. - */ - @JsonProperty("token") - public Optional getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1TokenizeRecordResponse && equalTo((V1TokenizeRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1TokenizeRecordResponse other) { - return token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token); - } - - @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 token = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1TokenizeRecordResponse other) { - token(other.getToken()); - return this; - } - - /** - *

Token corresponding to a value.

- */ - @JsonSetter(value = "token", nulls = Nulls.SKIP) - public Builder token(Optional token) { - this.token = token; - return this; - } - - public Builder token(String token) { - this.token = Optional.ofNullable(token); - return this; - } - - public V1TokenizeRecordResponse build() { - return new V1TokenizeRecordResponse(token, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java deleted file mode 100644 index 38159283..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1TokenizeResponse.java +++ /dev/null @@ -1,103 +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 = V1TokenizeResponse.Builder.class) -public final class V1TokenizeResponse { - private final Optional> records; - - private final Map additionalProperties; - - private V1TokenizeResponse( - Optional> records, Map additionalProperties) { - this.records = records; - this.additionalProperties = additionalProperties; - } - - /** - * @return Tokens corresponding to the specified values. - */ - @JsonProperty("records") - public Optional> getRecords() { - return records; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1TokenizeResponse && equalTo((V1TokenizeResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1TokenizeResponse other) { - return records.equals(other.records); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.records); - } - - @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> records = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1TokenizeResponse other) { - records(other.getRecords()); - return this; - } - - /** - *

Tokens corresponding to the specified values.

- */ - @JsonSetter(value = "records", nulls = Nulls.SKIP) - public Builder records(Optional> records) { - this.records = records; - return this; - } - - public Builder records(List records) { - this.records = Optional.ofNullable(records); - return this; - } - - public V1TokenizeResponse build() { - return new V1TokenizeResponse(records, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java b/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.java deleted file mode 100644 index 658926b9..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1UpdateRecordResponse.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 = V1UpdateRecordResponse.Builder.class) -public final class V1UpdateRecordResponse { - private final Optional skyflowId; - - private final Optional> tokens; - - private final Map additionalProperties; - - private V1UpdateRecordResponse( - Optional skyflowId, - Optional> tokens, - Map additionalProperties) { - this.skyflowId = skyflowId; - this.tokens = tokens; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the updated record. - */ - @JsonProperty("skyflow_id") - public Optional getSkyflowId() { - return skyflowId; - } - - /** - * @return Tokens for the record. - */ - @JsonProperty("tokens") - public Optional> getTokens() { - return tokens; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1UpdateRecordResponse && equalTo((V1UpdateRecordResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1UpdateRecordResponse other) { - return skyflowId.equals(other.skyflowId) && tokens.equals(other.tokens); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.skyflowId, this.tokens); - } - - @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> tokens = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1UpdateRecordResponse other) { - skyflowId(other.getSkyflowId()); - tokens(other.getTokens()); - return this; - } - - /** - *

ID of the updated record.

- */ - @JsonSetter(value = "skyflow_id", 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; - } - - /** - *

Tokens for the record.

- */ - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public Builder tokens(Optional> tokens) { - this.tokens = tokens; - return this; - } - - public Builder tokens(Map tokens) { - this.tokens = Optional.ofNullable(tokens); - return this; - } - - public V1UpdateRecordResponse build() { - return new V1UpdateRecordResponse(skyflowId, tokens, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java b/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java deleted file mode 100644 index bad4474a..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1VaultFieldMapping.java +++ /dev/null @@ -1,163 +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 = V1VaultFieldMapping.Builder.class) -public final class V1VaultFieldMapping { - private final Optional cardNumber; - - private final Optional cardLastFourDigits; - - private final Optional cardExpiry; - - private final Map additionalProperties; - - private V1VaultFieldMapping( - Optional cardNumber, - Optional cardLastFourDigits, - Optional cardExpiry, - Map additionalProperties) { - this.cardNumber = cardNumber; - this.cardLastFourDigits = cardLastFourDigits; - this.cardExpiry = cardExpiry; - this.additionalProperties = additionalProperties; - } - - /** - * @return Name of the column that stores the card number. - */ - @JsonProperty("card_number") - public Optional getCardNumber() { - return cardNumber; - } - - /** - * @return Name of the column that stores the card number suffix. - */ - @JsonProperty("card_last_four_digits") - public Optional getCardLastFourDigits() { - return cardLastFourDigits; - } - - /** - * @return Name of the column that stores the expiry date. - */ - @JsonProperty("card_expiry") - public Optional getCardExpiry() { - return cardExpiry; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1VaultFieldMapping && equalTo((V1VaultFieldMapping) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1VaultFieldMapping other) { - return cardNumber.equals(other.cardNumber) - && cardLastFourDigits.equals(other.cardLastFourDigits) - && cardExpiry.equals(other.cardExpiry); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cardNumber, this.cardLastFourDigits, this.cardExpiry); - } - - @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 cardNumber = Optional.empty(); - - private Optional cardLastFourDigits = Optional.empty(); - - private Optional cardExpiry = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1VaultFieldMapping other) { - cardNumber(other.getCardNumber()); - cardLastFourDigits(other.getCardLastFourDigits()); - cardExpiry(other.getCardExpiry()); - return this; - } - - /** - *

Name of the column that stores the card number.

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

Name of the column that stores the card number suffix.

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

Name of the column that stores the expiry date.

- */ - @JsonSetter(value = "card_expiry", nulls = Nulls.SKIP) - public Builder cardExpiry(Optional cardExpiry) { - this.cardExpiry = cardExpiry; - return this; - } - - public Builder cardExpiry(String cardExpiry) { - this.cardExpiry = Optional.ofNullable(cardExpiry); - return this; - } - - public V1VaultFieldMapping build() { - return new V1VaultFieldMapping(cardNumber, cardLastFourDigits, cardExpiry, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java b/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java deleted file mode 100644 index 28a609b6..00000000 --- a/src/main/java/com/skyflow/generated/rest/types/V1VaultSchemaConfig.java +++ /dev/null @@ -1,155 +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 = V1VaultSchemaConfig.Builder.class) -public final class V1VaultSchemaConfig { - private final Optional id; - - private final Optional tableName; - - private final Optional mapping; - - private final Map additionalProperties; - - private V1VaultSchemaConfig( - Optional id, - Optional tableName, - Optional mapping, - Map additionalProperties) { - this.id = id; - this.tableName = tableName; - this.mapping = mapping; - this.additionalProperties = additionalProperties; - } - - /** - * @return ID of the vault that stores card details. - */ - @JsonProperty("id") - public Optional getId() { - return id; - } - - /** - * @return Name of the table that stores card details. - */ - @JsonProperty("table_name") - public Optional getTableName() { - return tableName; - } - - @JsonProperty("mapping") - public Optional getMapping() { - return mapping; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1VaultSchemaConfig && equalTo((V1VaultSchemaConfig) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1VaultSchemaConfig other) { - return id.equals(other.id) && tableName.equals(other.tableName) && mapping.equals(other.mapping); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.tableName, this.mapping); - } - - @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 id = Optional.empty(); - - private Optional tableName = Optional.empty(); - - private Optional mapping = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(V1VaultSchemaConfig other) { - id(other.getId()); - tableName(other.getTableName()); - mapping(other.getMapping()); - return this; - } - - /** - *

ID of the vault that stores card details.

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

Name of the table that stores card details.

- */ - @JsonSetter(value = "table_name", nulls = Nulls.SKIP) - public Builder tableName(Optional tableName) { - this.tableName = tableName; - return this; - } - - public Builder tableName(String tableName) { - this.tableName = Optional.ofNullable(tableName); - return this; - } - - @JsonSetter(value = "mapping", nulls = Nulls.SKIP) - public Builder mapping(Optional mapping) { - this.mapping = mapping; - return this; - } - - public Builder mapping(V1VaultFieldMapping mapping) { - this.mapping = Optional.ofNullable(mapping); - return this; - } - - public V1VaultSchemaConfig build() { - return new V1VaultSchemaConfig(id, tableName, mapping, additionalProperties); - } - } -} diff --git a/src/main/java/com/skyflow/utils/HttpUtility.java b/src/main/java/com/skyflow/utils/HttpUtility.java deleted file mode 100644 index b8e9283b..00000000 --- a/src/main/java/com/skyflow/utils/HttpUtility.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.skyflow.utils; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.skyflow.errors.SkyflowException; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -public final class HttpUtility { - - private static final String LINE_FEED = "\r\n"; - private static String requestID; - - public static String getRequestID() { - return requestID; - } - - public static String sendRequest(String method, URL url, JsonObject params, Map headers) throws IOException, SkyflowException { - - HttpURLConnection connection = null; - BufferedReader in = null; - StringBuffer response = null; - String boundary = String.valueOf(System.currentTimeMillis()); - - try { - connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod(method); - connection.setRequestProperty("content-type", "application/json"); - connection.setRequestProperty("Accept", "*/*"); - - if (headers != null && !headers.isEmpty()) { - for (Map.Entry entry : headers.entrySet()) - connection.setRequestProperty(entry.getKey(), entry.getValue()); - - // append dynamic boundary if content-type is multipart/form-data - if (headers.containsKey("content-type")) { - if (Objects.equals(headers.get("content-type"), "multipart/form-data")) { - connection.setRequestProperty("content-type", "multipart/form-data; boundary=" + boundary); - } - } - } - if (params != null && !params.isEmpty()) { - connection.setDoOutput(true); - try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { - byte[] input = null; - String requestContentType = connection.getRequestProperty("content-type"); - - if (requestContentType.contains("application/x-www-form-urlencoded")) { - input = formatJsonToFormEncodedString(params).getBytes(StandardCharsets.UTF_8); - } else if (requestContentType.contains("multipart/form-data")) { - input = formatJsonToMultiPartFormDataString(params, boundary).getBytes(StandardCharsets.UTF_8); - } else { - input = params.toString().getBytes(StandardCharsets.UTF_8); - } - - wr.write(input, 0, input.length); - wr.flush(); - } - } - - int httpCode = connection.getResponseCode(); - String requestID = connection.getHeaderField("x-request-id"); - HttpUtility.requestID = requestID.split(",")[0]; - Map> responseHeaders = connection.getHeaderFields(); - Reader streamReader; - if (httpCode > 299) { - if (connection.getErrorStream() != null) - streamReader = new InputStreamReader(connection.getErrorStream()); - else { - String description = appendRequestId("replace with description", requestID); - throw new SkyflowException(description); - } - } else { - streamReader = new InputStreamReader(connection.getInputStream()); - } - - response = new StringBuffer(); - in = new BufferedReader(streamReader); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - - if (httpCode > 299) { - throw new SkyflowException(httpCode, new Throwable(), responseHeaders, response.toString()); - } - } finally { - if (in != null) { - in.close(); - } - if (connection != null) { - connection.disconnect(); - } - } - return response.toString(); - - } - - public static String formatJsonToFormEncodedString(JsonObject requestBody) { - StringBuilder formEncodeString = new StringBuilder(); - HashMap jsonMap = convertJsonToMap(requestBody, ""); - - for (Map.Entry currentEntry : jsonMap.entrySet()) - formEncodeString.append(makeFormEncodeKeyValuePair(currentEntry.getKey(), currentEntry.getValue())); - - return formEncodeString.substring(0, formEncodeString.length() - 1); - } - - public static String formatJsonToMultiPartFormDataString(JsonObject requestBody, String boundary) { - StringBuilder formEncodeString = new StringBuilder(); - HashMap jsonMap = convertJsonToMap(requestBody, ""); - - for (Map.Entry currentEntry : jsonMap.entrySet()) - formEncodeString.append(makeFormDataKeyValuePair(currentEntry.getKey(), currentEntry.getValue(), boundary)); - - formEncodeString.append(LINE_FEED); - formEncodeString.append("--").append(boundary).append("--").append(LINE_FEED); - - return formEncodeString.toString(); - } - - private static HashMap convertJsonToMap(JsonObject json, String rootKey) { - HashMap currentMap = new HashMap<>(); - Map jsonMap = json.asMap(); - for (String key : jsonMap.keySet()) { - JsonElement currentValue = jsonMap.get(key); - String currentKey = !rootKey.isEmpty() ? rootKey + '[' + key + ']' : rootKey + key; - if (currentValue.isJsonObject()) { - currentMap.putAll(convertJsonToMap((JsonObject) currentValue, currentKey)); - } else { - currentMap.put(currentKey, currentValue.getAsString()); - } - } - return currentMap; - } - - private static String makeFormDataKeyValuePair(String key, String value, String boundary) { - StringBuilder formDataTextField = new StringBuilder(); - formDataTextField.append("--").append(boundary).append(LINE_FEED); - formDataTextField.append("Content-Disposition: form-data; name=\"").append(key).append("\"").append(LINE_FEED); - formDataTextField.append(LINE_FEED); - formDataTextField.append(value).append(LINE_FEED); - - return formDataTextField.toString(); - } - - public static String appendRequestId(String message, String requestId) { - if (requestId != null && !requestId.isEmpty()) { - message = message + " - requestId: " + requestId; - } - return message; - } - - private static String makeFormEncodeKeyValuePair(String key, String value) { - return key + "=" + value + "&"; - } - -} diff --git a/src/main/java/com/skyflow/utils/Utils.java b/src/main/java/com/skyflow/utils/Utils.java deleted file mode 100644 index cc8d572a..00000000 --- a/src/main/java/com/skyflow/utils/Utils.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.skyflow.utils; - -import com.google.gson.JsonObject; -import com.skyflow.config.ConnectionConfig; -import com.skyflow.config.Credentials; -import com.skyflow.enums.Env; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.logs.ErrorLogs; -import com.skyflow.logs.InfoLogs; -import com.skyflow.serviceaccount.util.BearerToken; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.vault.connection.InvokeConnectionRequest; -import org.apache.commons.codec.binary.Base64; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.HashMap; -import java.util.Map; - -public final class Utils { - public static String getVaultURL(String clusterId, Env env) { - StringBuilder sb = new StringBuilder(Constants.SECURE_PROTOCOL); - sb.append(clusterId); - switch (env) { - case DEV: - sb.append(Constants.DEV_DOMAIN); - break; - case STAGE: - sb.append(Constants.STAGE_DOMAIN); - break; - case SANDBOX: - sb.append(Constants.SANDBOX_DOMAIN); - break; - case PROD: - default: - sb.append(Constants.PROD_DOMAIN); - break; - } - return sb.toString(); - } - - public static String generateBearerToken(Credentials credentials) throws SkyflowException { - if (credentials.getPath() != null) { - return BearerToken.builder() - .setCredentials(new File(credentials.getPath())) - .setRoles(credentials.getRoles()) - .setCtx(credentials.getContext()) - .build() - .getBearerToken(); - } else if (credentials.getCredentialsString() != null) { - return BearerToken.builder() - .setCredentials(credentials.getCredentialsString()) - .setRoles(credentials.getRoles()) - .setCtx(credentials.getContext()) - .build() - .getBearerToken(); - } else { - return credentials.getToken(); - } - } - - public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException { - String PKCS8PrivateHeader = Constants.PKCS8_PRIVATE_HEADER; - String PKCS8PrivateFooter = Constants.PKCS8_PRIVATE_FOOTER; - - String privateKeyContent = pemKey; - PrivateKey privateKey = null; - - if (pemKey.contains(PKCS8PrivateHeader)) { - privateKeyContent = privateKeyContent.replace(PKCS8PrivateHeader, ""); - privateKeyContent = privateKeyContent.replace(PKCS8PrivateFooter, ""); - privateKeyContent = privateKeyContent.replace("\n", ""); - privateKeyContent = privateKeyContent.replace("\r\n", ""); - privateKey = parsePkcs8PrivateKey(Base64.decodeBase64(privateKeyContent)); - } else { - LogUtil.printErrorLog(ErrorLogs.JWT_INVALID_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.JwtInvalidFormat.getMessage()); - } - return privateKey; - } - - public static String getBaseURL(String url) throws MalformedURLException { - URL parsedUrl = new URL(url); - String protocol = parsedUrl.getProtocol(); - String host = parsedUrl.getHost(); - return String.format("%s://%s", protocol, host); - } - - public static String parameterizedString(String base, String... args) { - for (int index = 0; index < args.length; index++) { - base = base.replace("%s" + (index + 1), args[index]); - } - return base; - } - - public static String constructConnectionURL(ConnectionConfig config, InvokeConnectionRequest invokeConnectionRequest) { - StringBuilder filledURL = new StringBuilder(config.getConnectionUrl()); - - if (invokeConnectionRequest.getPathParams() != null && !invokeConnectionRequest.getPathParams().isEmpty()) { - for (Map.Entry entry : invokeConnectionRequest.getPathParams().entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - filledURL = new StringBuilder(filledURL.toString().replace(String.format("{%s}", key), value)); - } - } - - if (invokeConnectionRequest.getQueryParams() != null && !invokeConnectionRequest.getQueryParams().isEmpty()) { - filledURL.append("?"); - for (Map.Entry entry : invokeConnectionRequest.getQueryParams().entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - filledURL.append(key).append("=").append(value).append("&"); - } - filledURL = new StringBuilder(filledURL.substring(0, filledURL.length() - 1)); - } - - return filledURL.toString(); - } - - public static Map constructConnectionHeadersMap(Map requestHeaders) { - Map headersMap = new HashMap<>(); - for (Map.Entry entry : requestHeaders.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - headersMap.put(key.toLowerCase(), value); - } - return headersMap; - } - - public static JsonObject getMetrics() { - JsonObject details = new JsonObject(); - String sdkVersion = Constants.SDK_VERSION; - String deviceModel; - String osDetails; - String javaVersion; - // Retrieve device model - try { - deviceModel = System.getProperty("os.name"); - if (deviceModel == null) throw new Exception(); - } catch (Exception e) { - LogUtil.printInfoLog(parameterizedString( - InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), - Constants.SDK_METRIC_CLIENT_DEVICE_MODEL - )); - deviceModel = ""; - } - - // Retrieve OS details - try { - osDetails = System.getProperty("os.version"); - if (osDetails == null) throw new Exception(); - } catch (Exception e) { - LogUtil.printInfoLog(parameterizedString( - InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), - Constants.SDK_METRIC_CLIENT_OS_DETAILS - )); - osDetails = ""; - } - - // Retrieve Java version details - try { - javaVersion = System.getProperty("java.version"); - if (javaVersion == null) throw new Exception(); - } catch (Exception e) { - LogUtil.printInfoLog(parameterizedString( - InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), - Constants.SDK_METRIC_RUNTIME_DETAILS - )); - javaVersion = ""; - } - details.addProperty(Constants.SDK_METRIC_NAME_VERSION, Constants.SDK_METRIC_NAME_VERSION_PREFIX + sdkVersion); - details.addProperty(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL, deviceModel); - details.addProperty(Constants.SDK_METRIC_RUNTIME_DETAILS, Constants.SDK_METRIC_RUNTIME_DETAILS_PREFIX + javaVersion); - details.addProperty(Constants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); - return details; - } - - private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws SkyflowException { - KeyFactory keyFactory; - PrivateKey privateKey = null; - try { - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8Bytes); - keyFactory = KeyFactory.getInstance("RSA"); - privateKey = keyFactory.generatePrivate(keySpec); - } catch (NoSuchAlgorithmException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_ALGORITHM.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidAlgorithm.getMessage()); - } catch (InvalidKeySpecException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_KEY_SPEC.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidKeySpec.getMessage()); - } - return privateKey; - } -} diff --git a/src/main/java/com/skyflow/utils/validations/Validations.java b/src/main/java/com/skyflow/utils/validations/Validations.java deleted file mode 100644 index 841c03b6..00000000 --- a/src/main/java/com/skyflow/utils/validations/Validations.java +++ /dev/null @@ -1,892 +0,0 @@ -package com.skyflow.utils.validations; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.skyflow.config.ConnectionConfig; -import com.skyflow.config.Credentials; -import com.skyflow.config.VaultConfig; -import com.skyflow.enums.InterfaceName; -import com.skyflow.enums.RedactionType; -import com.skyflow.enums.TokenMode; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.logs.ErrorLogs; -import com.skyflow.utils.Constants; -import com.skyflow.utils.Utils; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.vault.connection.InvokeConnectionRequest; -import com.skyflow.vault.data.*; -import com.skyflow.vault.detect.*; -import com.skyflow.vault.tokens.ColumnValue; -import com.skyflow.vault.tokens.DetokenizeData; -import com.skyflow.vault.tokens.DetokenizeRequest; -import com.skyflow.vault.tokens.TokenizeRequest; - -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class Validations { - private Validations() { - } - - public static void validateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - String vaultId = vaultConfig.getVaultId(); - String clusterId = vaultConfig.getClusterId(); - Credentials credentials = vaultConfig.getCredentials(); - if (vaultId == null) { - LogUtil.printErrorLog(ErrorLogs.VAULT_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidVaultId.getMessage()); - } else if (vaultId.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_VAULT_ID.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyVaultId.getMessage()); - } else if (clusterId == null) { - LogUtil.printErrorLog(ErrorLogs.CLUSTER_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidClusterId.getMessage()); - } else if (clusterId.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CLUSTER_ID.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyClusterId.getMessage()); - } else if (credentials != null) { - validateCredentials(credentials); - } - } - - public static void validateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { - String connectionId = connectionConfig.getConnectionId(); - String connectionUrl = connectionConfig.getConnectionUrl(); - - if (connectionId == null) { - LogUtil.printErrorLog(ErrorLogs.CONNECTION_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidConnectionId.getMessage()); - } else if (connectionId.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CONNECTION_ID.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyConnectionId.getMessage()); - } else if (connectionUrl == null) { - LogUtil.printErrorLog(ErrorLogs.CONNECTION_URL_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidConnectionUrl.getMessage()); - } else if (connectionUrl.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CONNECTION_URL.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyConnectionUrl.getMessage()); - } else if (isInvalidURL(connectionUrl)) { - LogUtil.printErrorLog(ErrorLogs.INVALID_CONNECTION_URL.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidConnectionUrlFormat.getMessage()); - } - } - - public static void validateInvokeConnectionRequest(InvokeConnectionRequest invokeConnectionRequest) throws SkyflowException { - Map requestHeaders = invokeConnectionRequest.getRequestHeaders(); - Map pathParams = invokeConnectionRequest.getPathParams(); - Map queryParams = invokeConnectionRequest.getQueryParams(); - Object requestBody = invokeConnectionRequest.getRequestBody(); - - if (requestHeaders != null) { - if (requestHeaders.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_REQUEST_HEADERS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestHeaders.getMessage()); - } else { - for (String header : requestHeaders.keySet()) { - String headerValue = requestHeaders.get(header); - if (header == null || header.trim().isEmpty() || headerValue == null || headerValue.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_REQUEST_HEADERS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestHeaders.getMessage()); - } - } - } - } - - if (pathParams != null) { - if (pathParams.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_PATH_PARAMS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyPathParams.getMessage()); - } else { - for (String param : pathParams.keySet()) { - String paramValue = pathParams.get(param); - if (param == null || param.trim().isEmpty() || paramValue == null || paramValue.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_PATH_PARAM.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPathParams.getMessage()); - } - } - } - } - - if (queryParams != null) { - if (queryParams.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_QUERY_PARAMS.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyQueryParams.getMessage()); - } else { - for (String param : queryParams.keySet()) { - String paramValue = queryParams.get(param); - if (param == null || param.trim().isEmpty() || paramValue == null || paramValue.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_QUERY_PARAM.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidQueryParams.getMessage()); - } - } - } - } - - if (requestBody != null) { - Gson gson = new Gson(); - JsonObject bodyObject = gson.toJsonTree(requestBody).getAsJsonObject(); - if (bodyObject.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_REQUEST_BODY.getLog(), InterfaceName.INVOKE_CONNECTION.getName())); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); - } - } - } - - public static void validateCredentials(Credentials credentials) throws SkyflowException { - int nonNullMembers = 0; - String path = credentials.getPath(); - String credentialsString = credentials.getCredentialsString(); - String token = credentials.getToken(); - String apiKey = credentials.getApiKey(); - String context = credentials.getContext(); - ArrayList roles = credentials.getRoles(); - - if (path != null) nonNullMembers++; - if (credentialsString != null) nonNullMembers++; - if (token != null) nonNullMembers++; - if (apiKey != null) nonNullMembers++; - - if (nonNullMembers > 1) { - LogUtil.printErrorLog(ErrorLogs.MULTIPLE_TOKEN_GENERATION_MEANS_PASSED.getLog()); - throw new SkyflowException( - ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MultipleTokenGenerationMeansPassed.getMessage() - ); - } else if (nonNullMembers < 1) { - LogUtil.printErrorLog(ErrorLogs.NO_TOKEN_GENERATION_MEANS_PASSED.getLog()); - throw new SkyflowException( - ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NoTokenGenerationMeansPassed.getMessage() - ); - } else if (path != null && path.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_PATH.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialFilePath.getMessage()); - } else if (credentialsString != null && credentialsString.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_STRING.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialsString.getMessage()); - } else if (token != null && token.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_TOKEN_VALUE.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyToken.getMessage()); - } else if (apiKey != null) { - if (apiKey.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_API_KEY_VALUE.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyApikey.getMessage()); - } else { - Pattern pattern = Pattern.compile(Constants.API_KEY_REGEX); - Matcher matcher = pattern.matcher(apiKey); - if (!matcher.matches()) { - LogUtil.printErrorLog(ErrorLogs.INVALID_API_KEY.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidApikey.getMessage()); - } - } - } else if (roles != null) { - if (roles.isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_ROLES.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoles.getMessage()); - } else { - for (int index = 0; index < roles.size(); index++) { - String role = roles.get(index); - if (role == null || role.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_ROLE_IN_ROLES.getLog(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoleInRoles.getMessage()); - } - } - } - } - if (context != null && context.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_OR_NULL_CONTEXT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyContext.getMessage()); - } - } - - public static void validateDetokenizeRequest(DetokenizeRequest detokenizeRequest) throws SkyflowException { - ArrayList detokenizeData = detokenizeRequest.getDetokenizeData(); - if (detokenizeData == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.DETOKENIZE_DATA_REQUIRED.getLog(), InterfaceName.DETOKENIZE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidDetokenizeData.getMessage()); - } else if (detokenizeData.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDetokenizeData.getMessage()); - } else { - for (int index = 0; index < detokenizeData.size(); index++) { - String token = detokenizeData.get(index).getToken(); - if (token == null || token.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA.getLog(), - InterfaceName.DETOKENIZE.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenInDetokenizeData.getMessage()); - } - } - } - } - - public static void validateInsertRequest(InsertRequest insertRequest) throws SkyflowException { - String table = insertRequest.getTable(); - ArrayList> values = insertRequest.getValues(); - ArrayList> tokens = insertRequest.getTokens(); - String upsert = insertRequest.getUpsert(); - Boolean homogeneous = insertRequest.getHomogeneous(); - TokenMode tokenMode = insertRequest.getTokenMode(); - - if (table == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.INSERT.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.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); - } else if (values == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.VALUES_IS_REQUIRED.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ValuesKeyError.getMessage()); - } else if (values.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_VALUES.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValues.getMessage()); - } else if (upsert != null) { - if (upsert.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_UPSERT.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyUpsert.getMessage()); - } else if (homogeneous != null && homogeneous) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.HOMOGENOUS_NOT_SUPPORTED_WITH_UPSERT.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException( - ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.HomogenousNotSupportedWithUpsert.getMessage() - ); - } - } - - for (HashMap valuesMap : values) { - for (String key : valuesMap.keySet()) { - if (key == null || key.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_KEY_IN_VALUES.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInValues.getMessage()); - } else { - Object value = valuesMap.get(key); - if (value == null || value.toString().trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_VALUE_IN_VALUES.getLog(), - InterfaceName.INSERT.getName(), key - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInValues.getMessage()); - } - } - } - } - - switch (tokenMode) { - case DISABLE: - if (tokens != null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TokensPassedForTokenModeDisable.getMessage()); - } - break; - case ENABLE: - if (tokens == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), - InterfaceName.INSERT.getName(), TokenMode.ENABLE.toString() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - Utils.parameterizedString(ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE.toString()) - ); - } - validateTokensForInsertRequest(tokens, values, tokenMode); - break; - case ENABLE_STRICT: - if (tokens == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), - InterfaceName.INSERT.getName(), TokenMode.ENABLE_STRICT.toString() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - Utils.parameterizedString(ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE_STRICT.toString()) - ); - } else if (tokens.size() != values.size()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT.getLog(), - InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.InsufficientTokensPassedForTokenModeEnableStrict.getMessage() - ); - } - validateTokensForInsertRequest(tokens, values, tokenMode); - break; - } - } - - public static void validateGetRequest(GetRequest getRequest) throws SkyflowException { - String table = getRequest.getTable(); - ArrayList ids = getRequest.getIds(); - RedactionType redactionType = getRequest.getRedactionType(); - Boolean tokenization = getRequest.getReturnTokens(); - ArrayList fields = getRequest.getFields(); - String offset = getRequest.getOffset(); - String limit = getRequest.getLimit(); - String columnName = getRequest.getColumnName(); - ArrayList columnValues = getRequest.getColumnValues(); - String orderBy = getRequest.getOrderBy(); - - if (table == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.GET.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.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); - } else if (ids != null) { - if (ids.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_IDS.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIds.getMessage()); - } else { - for (int index = 0; index < ids.size(); index++) { - String id = ids.get(index); - if (id == null || id.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_ID_IN_IDS.getLog(), - InterfaceName.GET.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIdInIds.getMessage()); - } - } - } - } - if (fields != null) { - if (fields.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_FIELDS.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyFields.getMessage()); - } else { - for (int index = 0; index < fields.size(); index++) { - String field = fields.get(index); - if (field == null || field.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_FIELD_IN_FIELDS.getLog(), - InterfaceName.GET.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyFieldInFields.getMessage()); - } - } - } - } - 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( - ErrorLogs.TOKENIZATION_NOT_SUPPORTED_WITH_REDACTION.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.RedactionWithTokensNotSupported.getMessage() - ); - } else if (columnName != null || columnValues != null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENIZATION_SUPPORTED_ONLY_WITH_IDS.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.TokensGetColumnNotSupported.getMessage() - ); - } - } - if (offset != null && offset.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OFFSET.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyOffset.getMessage()); - } - if (limit != null && limit.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_LIMIT.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyLimit.getMessage()); - } - if (ids == null && columnName == null && columnValues == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.NEITHER_IDS_NOR_COLUMN_NAME_PASSED.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.UniqueColumnOrIdsKeyError.getMessage()); - } else if (ids != null && (columnName != null || columnValues != null)) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.BOTH_IDS_AND_COLUMN_NAME_PASSED.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.BothIdsAndColumnDetailsSpecified.getMessage()); - } else if (columnName == null && columnValues != null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.COLUMN_NAME_IS_REQUIRED.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnNameKeyError.getMessage()); - } else if (columnName != null && columnValues == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.COLUMN_VALUES_IS_REQUIRED_GET.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnValuesKeyErrorGet.getMessage()); - } else if (columnName != null) { - if (columnName.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_COLUMN_NAME.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnName.getMessage()); - } else if (columnValues.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_COLUMN_VALUES.getLog(), InterfaceName.GET.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnValues.getMessage()); - } else { - for (int index = 0; index < columnValues.size(); index++) { - String columnValue = columnValues.get(index); - if (columnValue == null || columnValue.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES.getLog(), - InterfaceName.GET.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.EmptyValueInColumnValues.getMessage()); - } - } - } - } - } - - public static void validateUpdateRequest(UpdateRequest updateRequest) throws SkyflowException { - String table = updateRequest.getTable(); - HashMap data = updateRequest.getData(); - HashMap tokens = updateRequest.getTokens(); - TokenMode tokenMode = updateRequest.getTokenMode(); - - if (table == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.UPDATE.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.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); - } else if (data == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.DATA_IS_REQUIRED.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.DataKeyError.getMessage()); - } else if (data.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_DATA.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyData.getMessage()); - } else if (!data.containsKey("skyflow_id")) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.SKYFLOW_ID_IS_REQUIRED.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.SkyflowIdKeyError.getMessage()); - } else if (!(data.get("skyflow_id") instanceof String)) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_SKYFLOW_ID_TYPE.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidSkyflowIdType.getMessage()); - } else if (data.get("skyflow_id").toString().trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_SKYFLOW_ID.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptySkyflowId.getMessage()); - } else if (tokens != null && tokens.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_TOKENS.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokens.getMessage()); - } - - for (String key : data.keySet()) { - if (key == null || key.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_KEY_IN_VALUES.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInValues.getMessage()); - } else { - Object value = data.get(key); - if (value == null || value.toString().trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_VALUE_IN_VALUES.getLog(), InterfaceName.UPDATE.getName(), key - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.EmptyValueInValues.getMessage()); - } - } - } - - switch (tokenMode) { - case DISABLE: - if (tokens != null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE.getLog(), InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.TokensPassedForTokenModeDisable.getMessage()); - } - break; - case ENABLE: - if (tokens == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), - InterfaceName.UPDATE.getName(), TokenMode.ENABLE.toString() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( - ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE.toString())); - } - validateTokensMapWithTokenStrict(tokens, data); - break; - case ENABLE_STRICT: - if (tokens == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TOKENS_REQUIRED_WITH_TOKEN_MODE.getLog(), - InterfaceName.UPDATE.getName(), TokenMode.ENABLE_STRICT.toString() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), Utils.parameterizedString( - ErrorMessage.NoTokensWithTokenMode.getMessage(), TokenMode.ENABLE_STRICT.toString())); - } else if (tokens.size() != (data.size() - 1)) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT.getLog(), - InterfaceName.UPDATE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.InsufficientTokensPassedForTokenModeEnableStrict.getMessage()); - } - validateTokensMapWithTokenStrict(tokens, data); - break; - } - } - - public static void validateDeleteRequest(DeleteRequest deleteRequest) throws SkyflowException { - String table = deleteRequest.getTable(); - ArrayList ids = deleteRequest.getIds(); - if (table == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.DELETE.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.DELETE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); - - } else if (ids == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.IDS_IS_REQUIRED.getLog(), InterfaceName.DELETE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.IdsKeyError.getMessage()); - } else if (ids.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_IDS.getLog(), InterfaceName.DELETE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIds.getMessage()); - } else { - for (int index = 0; index < ids.size(); index++) { - String id = ids.get(index); - if (id == null || id.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_ID_IN_IDS.getLog(), - InterfaceName.DELETE.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyIdInIds.getMessage()); - } - } - } - } - - public static void validateQueryRequest(QueryRequest queryRequest) throws SkyflowException { - String query = queryRequest.getQuery(); - if (query == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.QUERY_IS_REQUIRED.getLog(), InterfaceName.QUERY.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.QueryKeyError.getMessage()); - } else if (query.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_QUERY.getLog(), InterfaceName.QUERY.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyQuery.getMessage()); - } - } - - public static void validateTokenizeRequest(TokenizeRequest tokenizeRequest) throws SkyflowException { - List columnValues = tokenizeRequest.getColumnValues(); - - if (columnValues == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.COLUMN_VALUES_IS_REQUIRED_TOKENIZE.getLog(), InterfaceName.TOKENIZE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ColumnValuesKeyErrorTokenize.getMessage()); - } else if (columnValues.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_COLUMN_VALUES.getLog(), InterfaceName.TOKENIZE.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyColumnValues.getMessage()); - } else { - for (int index = 0; index < columnValues.size(); index++) { - ColumnValue value = columnValues.get(index); - if (value.getValue() == null || value.getValue().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES.getLog(), - InterfaceName.TOKENIZE.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInColumnValues.getMessage()); - } else if (value.getColumnGroup() == null || value.getColumnGroup().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_COLUMN_GROUP_IN_COLUMN_VALUES.getLog(), - InterfaceName.TOKENIZE.getName(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.EmptyColumnGroupInColumnValue.getMessage()); - } - } - } - } - - public static void validateDeidentifyTextRequest(DeidentifyTextRequest deidentifyTextRequest) throws SkyflowException { - // Validate required fields - String deidentifyText = deidentifyTextRequest.getText(); - if (deidentifyText == null || deidentifyText.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_TEXT_IN_DEIDENTIFY.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTextInDeIdentify.getMessage()); - } - } - - public static void validateReidentifyTextRequest(ReidentifyTextRequest reidentifyTextRequest) throws SkyflowException { - // Validate required fields - String reidentifyText = reidentifyTextRequest.getText(); - if (reidentifyText == null || reidentifyText.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_TEXT_IN_REIDENTIFY.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidTextInReIdentify.getMessage()); - } - } - - private static boolean isInvalidURL(String configURL) { - try { - URL url = new URL(configURL); - if (!url.getProtocol().equals("https")) throw new Exception(); - } catch (Exception e) { - return true; - } - return false; - } - - private static void validateTokensForInsertRequest( - ArrayList> tokens, - ArrayList> values, - TokenMode tokenStrict - ) throws SkyflowException { - if (tokens.isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_TOKENS.getLog(), InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokens.getMessage()); - } - - for (int index = 0; index < tokens.size(); index++) { - HashMap tokensMap = tokens.get(index); - HashMap valuesMap = values.get(index); - if (tokensMap.size() != valuesMap.size() && tokenStrict == TokenMode.ENABLE_STRICT) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT.getLog(), - InterfaceName.INSERT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), - ErrorMessage.InsufficientTokensPassedForTokenModeEnableStrict.getMessage() - ); - } - validateTokensMapWithTokenStrict(tokensMap, valuesMap, InterfaceName.INSERT.getName()); - } - } - - private static void validateTokensMapWithTokenStrict( - HashMap tokensMap, HashMap valuesMap - ) throws SkyflowException { - validateTokensMapWithTokenStrict(tokensMap, valuesMap, InterfaceName.UPDATE.getName()); - } - - private static void validateTokensMapWithTokenStrict( - HashMap tokensMap, HashMap valuesMap, String interfaceName - ) throws SkyflowException { - for (String key : tokensMap.keySet()) { - if (key == null || key.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_KEY_IN_TOKENS.getLog(), interfaceName - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInTokens.getMessage()); - } else if (!valuesMap.containsKey(key)) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.MISMATCH_OF_FIELDS_AND_TOKENS.getLog(), interfaceName - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MismatchOfFieldsAndTokens.getMessage()); - } else { - Object value = tokensMap.get(key); - if (value == null || value.toString().trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_VALUE_IN_TOKENS.getLog(), - interfaceName, key - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInTokens.getMessage()); - } - } - } - } - - public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) throws SkyflowException { - if (request == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_REQUEST_BODY.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); - } - - File file = request.getFileInput().getFile(); - String filePath = request.getFileInput().getFilePath(); - - if (file == null && filePath == null) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyFileAndFilePathInDeIdentifyFile.getMessage()); - } - - if (filePath != null && file != null) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.BothFileAndFilePathProvided.getMessage()); - } - - if (filePath != null && filePath.trim().isEmpty()){ - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidFilePath.getMessage()); - } - - if (file != null && (!file.exists() || !file.isFile())) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.FILE_NOT_FOUND_TO_DEIDENTIFY.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FileNotFoundToDeidentify.getMessage()); - } - if (file != null && !file.canRead()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.FILE_NOT_READABLE_TO_DEIDENTIFY.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FileNotReadableToDeidentify.getMessage()); - } - - - // Validate pixelDensity and maxResolution - if (request.getPixelDensity() != null && request.getPixelDensity().doubleValue() <= 0) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_PIXEL_DENSITY_TO_DEIDENTIFY_FILE.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPixelDensityToDeidentifyFile.getMessage()); - } - if (request.getMaxResolution() != null && request.getMaxResolution().doubleValue() <= 0) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_MAX_RESOLUTION.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidMaxResolution.getMessage()); - } - - // Validate AudioBleep - if (request.getBleep() != null) { - if (request.getBleep().getFrequency() == null || request.getBleep().getFrequency() <= 0) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_BLEEP_TO_DEIDENTIFY_AUDIO.getLog(), InterfaceName.DETECT.getName() - )); - 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()); - } - if (request.getBleep().getStopPadding() == null || request.getBleep().getStopPadding() < 0) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); - } - } - - // Validate outputDirectory if provided - if (request.getOutputDirectory() != null) { - File outDir = new File(request.getOutputDirectory()); - if (!outDir.exists() || !outDir.isDirectory()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.OUTPUT_DIRECTORY_NOT_FOUND.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.OutputDirectoryNotFound.getMessage()); - } - if (!outDir.canWrite()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY.getLog(), InterfaceName.DETECT.getName() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPermission.getMessage()); - } - } - - // Validate waitTime if provided - if (request.getWaitTime() != null && request.getWaitTime() <= 0) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidWaitTime.getMessage()); - } - if(request.getWaitTime() > 64) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.WaitTimeExceedsLimit.getMessage()); - } - } - - public static void validateGetDetectRunRequest(GetDetectRunRequest request) throws SkyflowException { - if (request == null) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRequestBody.getMessage()); - } - - String runId = request.getRunId(); - if (runId == null || runId.trim().isEmpty()) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidOrEmptyRunId.getMessage()); - } - } -} diff --git a/src/main/java/com/skyflow/vault/audit/ListEventRequest.java b/src/main/java/com/skyflow/vault/audit/ListEventRequest.java deleted file mode 100644 index b6c26b6d..00000000 --- a/src/main/java/com/skyflow/vault/audit/ListEventRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.skyflow.vault.audit; - -public class ListEventRequest { - // members - - // constructor - public ListEventRequest() { - } - - // getters ans setters -} diff --git a/src/main/java/com/skyflow/vault/audit/ListEventResponse.java b/src/main/java/com/skyflow/vault/audit/ListEventResponse.java deleted file mode 100644 index 2647e617..00000000 --- a/src/main/java/com/skyflow/vault/audit/ListEventResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.skyflow.vault.audit; - -public class ListEventResponse { - // members - - public ListEventResponse() { - } - - // getters ans setters -} diff --git a/src/main/java/com/skyflow/vault/bin/GetBinRequest.java b/src/main/java/com/skyflow/vault/bin/GetBinRequest.java deleted file mode 100644 index d059245f..00000000 --- a/src/main/java/com/skyflow/vault/bin/GetBinRequest.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.skyflow.vault.bin; - -public class GetBinRequest { - // members - - public GetBinRequest() { - } - - // getters ans setters -} diff --git a/src/main/java/com/skyflow/vault/bin/GetBinResponse.java b/src/main/java/com/skyflow/vault/bin/GetBinResponse.java deleted file mode 100644 index 86210031..00000000 --- a/src/main/java/com/skyflow/vault/bin/GetBinResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.skyflow.vault.bin; - -public class GetBinResponse { - // members - - public GetBinResponse() { - } - - // getters ans setters -} diff --git a/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java b/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java deleted file mode 100644 index ea71cd0a..00000000 --- a/src/main/java/com/skyflow/vault/connection/InvokeConnectionRequest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.skyflow.vault.connection; - -import com.skyflow.enums.RequestMethod; - -import java.util.Map; - -public class InvokeConnectionRequest { - - private final InvokeConnectionRequestBuilder builder; - - private InvokeConnectionRequest(InvokeConnectionRequestBuilder builder) { - this.builder = builder; - } - - public static InvokeConnectionRequestBuilder builder() { - return new InvokeConnectionRequestBuilder(); - } - - public RequestMethod getMethod() { - return builder.method; - } - - public Map getPathParams() { - return builder.pathParams; - } - - public Map getQueryParams() { - return builder.queryParams; - } - - public Map getRequestHeaders() { - return builder.requestHeaders; - } - - public Object getRequestBody() { - return builder.requestBody; - } - - public static final class InvokeConnectionRequestBuilder { - private RequestMethod method; - private Map pathParams; - private Map queryParams; - private Map requestHeaders; - private Object requestBody; - - private InvokeConnectionRequestBuilder() { - this.method = RequestMethod.POST; - this.requestBody = new Object(); - } - - public InvokeConnectionRequestBuilder method(RequestMethod method) { - this.method = method == null ? RequestMethod.POST : method; - return this; - } - - public InvokeConnectionRequestBuilder pathParams(Map pathParams) { - this.pathParams = pathParams; - return this; - } - - public InvokeConnectionRequestBuilder queryParams(Map queryParams) { - this.queryParams = queryParams; - return this; - } - - public InvokeConnectionRequestBuilder requestHeaders(Map requestHeaders) { - this.requestHeaders = requestHeaders; - return this; - } - - public InvokeConnectionRequestBuilder requestBody(Object requestBody) { - this.requestBody = requestBody; - return this; - } - - public InvokeConnectionRequest build() { - return new InvokeConnectionRequest(this); - } - - } - -} diff --git a/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java b/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java deleted file mode 100644 index a2d44d99..00000000 --- a/src/main/java/com/skyflow/vault/connection/InvokeConnectionResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.skyflow.vault.connection; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import java.util.HashMap; - -public class InvokeConnectionResponse { - private final Object data; - private final HashMap metadata; - - public InvokeConnectionResponse(Object data, HashMap metadata) { - this.data = data; - this.metadata = metadata; - } - - public Object getData() { - return data; - } - - public HashMap getMetadata() { - return metadata; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - return gson.toJson(this); - } -} diff --git a/src/main/java/com/skyflow/vault/controller/AuditController.java b/src/main/java/com/skyflow/vault/controller/AuditController.java deleted file mode 100644 index 2faa04a6..00000000 --- a/src/main/java/com/skyflow/vault/controller/AuditController.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.skyflow.vault.controller; - -import com.skyflow.generated.rest.ApiClient; -import com.skyflow.vault.audit.ListEventRequest; -import com.skyflow.vault.audit.ListEventResponse; - -public class AuditController { - - public AuditController(ApiClient apiClient) { - - } - - // Check for correct return type in python interfaces - public ListEventResponse list(ListEventRequest listEventRequest) { - // return audit events - return null; - } -} diff --git a/src/main/java/com/skyflow/vault/controller/BinLookupController.java b/src/main/java/com/skyflow/vault/controller/BinLookupController.java deleted file mode 100644 index 4eb7a1c8..00000000 --- a/src/main/java/com/skyflow/vault/controller/BinLookupController.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.skyflow.vault.controller; - -import com.skyflow.generated.rest.ApiClient; -import com.skyflow.vault.bin.GetBinRequest; -import com.skyflow.vault.bin.GetBinResponse; - -public class BinLookupController { - - public BinLookupController(ApiClient apiClient) { - } - - public GetBinResponse get(GetBinRequest getBinRequest) { - // return bin lookup response (card metadata associated with BIN) - return null; - } -} diff --git a/src/main/java/com/skyflow/vault/controller/ConnectionController.java b/src/main/java/com/skyflow/vault/controller/ConnectionController.java deleted file mode 100644 index 68a39751..00000000 --- a/src/main/java/com/skyflow/vault/controller/ConnectionController.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.skyflow.vault.controller; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.skyflow.ConnectionClient; -import com.skyflow.config.ConnectionConfig; -import com.skyflow.config.Credentials; -import com.skyflow.enums.RequestMethod; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.logs.ErrorLogs; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Constants; -import com.skyflow.utils.HttpUtility; -import com.skyflow.utils.Utils; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.utils.validations.Validations; -import com.skyflow.vault.connection.InvokeConnectionRequest; -import com.skyflow.vault.connection.InvokeConnectionResponse; - -import java.io.IOException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -public final class ConnectionController extends ConnectionClient { - public ConnectionController(ConnectionConfig connectionConfig, Credentials credentials) { - super(connectionConfig, credentials); - } - - public InvokeConnectionResponse invoke(InvokeConnectionRequest invokeConnectionRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.INVOKE_CONNECTION_TRIGGERED.getLog()); - InvokeConnectionResponse connectionResponse; - try { - LogUtil.printInfoLog(InfoLogs.VALIDATING_INVOKE_CONNECTION_REQUEST.getLog()); - Validations.validateInvokeConnectionRequest(invokeConnectionRequest); - setBearerToken(); - String filledURL = Utils.constructConnectionURL(super.getConnectionConfig(), invokeConnectionRequest); - Map headers = new HashMap<>(); - - Map requestHeaders = invokeConnectionRequest.getRequestHeaders(); - if (requestHeaders != null) { - headers = Utils.constructConnectionHeadersMap(invokeConnectionRequest.getRequestHeaders()); - } - if (!headers.containsKey(Constants.SDK_AUTH_HEADER_KEY)) { - headers.put(Constants.SDK_AUTH_HEADER_KEY, token == null ? apiKey : token); - } - headers.put(Constants.SDK_METRICS_HEADER_KEY, Utils.getMetrics().toString()); - - RequestMethod requestMethod = invokeConnectionRequest.getMethod(); - JsonObject requestBody = null; - Object requestBodyObject = invokeConnectionRequest.getRequestBody(); - - if (requestBodyObject != null) { - try { - requestBody = convertObjectToJson(requestBodyObject); - } catch (Exception e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_REQUEST_HEADERS.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); - } - } - - String response = HttpUtility.sendRequest(requestMethod.name(), new URL(filledURL), requestBody, headers); - JsonObject data = JsonParser.parseString(response).getAsJsonObject(); - HashMap metadata = new HashMap<>(); - metadata.put("requestId", HttpUtility.getRequestID()); - connectionResponse = new InvokeConnectionResponse(data, metadata); - LogUtil.printInfoLog(InfoLogs.INVOKE_CONNECTION_REQUEST_RESOLVED.getLog()); - } catch (IOException e) { - LogUtil.printErrorLog(ErrorLogs.INVOKE_CONNECTION_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.getMessage(), e); - } - return connectionResponse; - } - - private JsonObject convertObjectToJson(Object object) { - Gson gson = new Gson(); - JsonElement jsonElement = gson.toJsonTree(object); - - if (jsonElement.isJsonObject()) { - return jsonElement.getAsJsonObject(); - } else { - JsonObject wrapper = new JsonObject(); - wrapper.add("value", jsonElement); - return wrapper; - } - } -} diff --git a/src/main/java/com/skyflow/vault/controller/DetectController.java b/src/main/java/com/skyflow/vault/controller/DetectController.java deleted file mode 100644 index 411658ae..00000000 --- a/src/main/java/com/skyflow/vault/controller/DetectController.java +++ /dev/null @@ -1,375 +0,0 @@ -package com.skyflow.vault.controller; - -import com.google.gson.*; -import com.skyflow.VaultClient; -import com.skyflow.config.Credentials; -import com.skyflow.config.VaultConfig; -import com.skyflow.enums.DeidentifyFileStatus; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.rest.core.ApiClientApiException; -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.*; -import com.skyflow.logs.ErrorLogs; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Constants; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.utils.validations.Validations; -import com.skyflow.vault.detect.*; -import com.skyflow.vault.detect.DeidentifyFileRequest; -import com.skyflow.vault.detect.DeidentifyFileResponse; -import com.skyflow.vault.detect.DeidentifyTextRequest; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.*; - -public final class DetectController extends VaultClient { - private static final Gson gson = new GsonBuilder().serializeNulls().create(); - - public DetectController(VaultConfig vaultConfig, Credentials credentials) { - super(vaultConfig, credentials); - } - - public DeidentifyTextResponse deidentifyText(DeidentifyTextRequest deidentifyTextRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_TRIGGERED.getLog()); - DeidentifyStringResponse deidentifyStringResponse = null; - DeidentifyTextResponse deidentifyTextResponse = null; - try { - // Validate the request - LogUtil.printInfoLog(InfoLogs.VALIDATE_DEIDENTIFY_TEXT_REQUEST.getLog()); - Validations.validateDeidentifyTextRequest(deidentifyTextRequest); - setBearerToken(); - - // Parse the request to DeidentifyStringRequest - String vaultId = super.getVaultConfig().getVaultId(); - DeidentifyStringRequest request = getDeidentifyStringRequest(deidentifyTextRequest, vaultId); - - // Call the API to de-identify the string - deidentifyStringResponse = super.getDetectTextApi().deidentifyString(request); - - // Parse the response to DeIdentifyTextResponse - deidentifyTextResponse = getDeIdentifyTextResponse(deidentifyStringResponse); - LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_REQUEST_RESOLVED.getLog()); - } catch (ApiClientApiException ex) { - String bodyString = gson.toJson(ex.body()); - LogUtil.printErrorLog(ErrorLogs.DEIDENTIFY_TEXT_REQUEST_REJECTED.getLog()); - throw new SkyflowException(ex.statusCode(), ex, ex.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_TEXT_SUCCESS.getLog()); - return deidentifyTextResponse; - } - - public ReidentifyTextResponse reidentifyText(ReidentifyTextRequest reidentifyTextRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_TRIGGERED.getLog()); - ReidentifyTextResponse reidentifyTextResponse = null; - try { - // Validate the request - LogUtil.printInfoLog(InfoLogs.VALIDATE_REIDENTIFY_TEXT_REQUEST.getLog()); - Validations.validateReidentifyTextRequest(reidentifyTextRequest); - setBearerToken(); - // Parse the request to ReidentifyTextRequest - String vaultId = super.getVaultConfig().getVaultId(); - ReidentifyStringRequest request = getReidentifyStringRequest(reidentifyTextRequest, vaultId); - - // Call the API to re-identify the string - ReidentifyStringResponse reidentifyStringResponse = super.getDetectTextApi().reidentifyString(request); - - // Parse the response to ReidentifyTextResponse - reidentifyTextResponse = new ReidentifyTextResponse(reidentifyStringResponse.getText().orElse(null)); - LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_REQUEST_RESOLVED.getLog()); - } catch (ApiClientApiException ex) { - String bodyString = gson.toJson(ex.body()); - LogUtil.printErrorLog(ErrorLogs.REIDENTIFY_TEXT_REQUEST_REJECTED.getLog()); - throw new SkyflowException(ex.statusCode(), ex, ex.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.REIDENTIFY_TEXT_SUCCESS.getLog()); - return reidentifyTextResponse; - } - - public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) throws SkyflowException { - DeidentifyFileResponse response; - LogUtil.printInfoLog(InfoLogs.DEIDENTIFY_FILE_TRIGGERED.getLog()); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATE_DEIDENTIFY_FILE_REQUEST.getLog()); - Validations.validateDeidentifyFileRequest(request); - setBearerToken(); - - String vaultId = super.getVaultConfig().getVaultId(); - - File file; - if (request.getFileInput().getFilePath() != null) { - file = new File(request.getFileInput().getFilePath()); - } else { - file = request.getFileInput().getFile(); - } - String fileName = file.getName(); - String fileExtension = getFileExtension(fileName); - String base64Content; - - try { - base64Content = encodeFileToBase64(file); - } catch (IOException ioe) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedToEncodeFile.getMessage()); - } - - - com.skyflow.generated.rest.types.DeidentifyFileResponse apiResponse = processFileByType(fileExtension, base64Content, request, vaultId); - try { - response = pollForResults(apiResponse.getRunId(), request.getWaitTime()); - } catch (Exception ex) { - throw new SkyflowException(ErrorCode.SERVER_ERROR.getCode(), ErrorMessage.PollingForResultsFailed.getMessage()); - } - - if (DeidentifyFileStatus.SUCCESS.value().equalsIgnoreCase(response.getStatus())) { - String base64File = response.getFileBase64(); - if (base64File != null) { - byte[] decodedBytes = Base64.getDecoder().decode(base64File); - String outputDir = request.getOutputDirectory(); - String outputFileName = Constants.PROCESSED_FILE_NAME_PREFIX + fileName; - File outputFile; - if (outputDir != null && !outputDir.isEmpty()) { - outputFile = new File(outputDir, outputFileName); - } else { - outputFile = new File(outputFileName); - } - try { - java.nio.file.Files.write(outputFile.toPath(), decodedBytes); - } catch (IOException ioe) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedtoSaveProcessedFile.getMessage()); - } - - } - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.DEIDENTIFY_FILE_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - return response; - } - - private String getFileExtension(String fileName) { - return fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); - } - - private String encodeFileToBase64(File file) throws IOException { - byte[] fileContent = Files.readAllBytes(file.toPath()); - return Base64.getEncoder().encodeToString(fileContent); - } - - private DeidentifyFileResponse pollForResults(String runId, Integer maxWaitTime) throws Exception { - int currentWaitTime = 1; - maxWaitTime = maxWaitTime == null ? 64 : maxWaitTime; - - DeidentifyStatusResponse response = null; - - while (true) { - try { - GetRunRequest getRunRequest = GetRunRequest.builder() - .vaultId(super.getVaultConfig().getVaultId()) - .build(); - response = super.getDetectFileAPi() - .getRun(runId, getRunRequest); - - DeidentifyStatusResponseStatus status = response.getStatus(); - - if (DeidentifyFileStatus.IN_PROGRESS.value().equalsIgnoreCase(String.valueOf(status))) { - if (currentWaitTime >= maxWaitTime) { - return new DeidentifyFileResponse(runId, DeidentifyFileStatus.IN_PROGRESS.value()); - } - - int nextWaitTime = currentWaitTime * 2; - int waitTime; - - if (nextWaitTime >= maxWaitTime) { - waitTime = maxWaitTime - currentWaitTime; - currentWaitTime = maxWaitTime; - } else { - waitTime = nextWaitTime; - currentWaitTime = nextWaitTime; - } - - Thread.sleep(waitTime * 1000); - - } else if (status == DeidentifyStatusResponseStatus.SUCCESS || - status == DeidentifyStatusResponseStatus.FAILED) { - return parseDeidentifyFileResponse(response, runId, status.toString()); - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.GET_DETECT_RUN_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - } - - } - - private static synchronized DeidentifyFileResponse parseDeidentifyFileResponse(DeidentifyStatusResponse response, - String runId, String status) throws SkyflowException { - DeidentifyFileOutput firstOutput = getFirstOutput(response); - - Object wordCharObj = response.getAdditionalProperties().get("word_character_count"); - Integer wordCount = null; - Integer charCount = null; - - if (wordCharObj instanceof Map) { - Map wordCharMap = (Map) wordCharObj; - Object wc = wordCharMap.get("word_count"); - Object cc = wordCharMap.get("character_count"); - if (wc instanceof Number) { - wordCount = ((Number) wc).intValue(); - } - if (cc instanceof Number) { - charCount = ((Number) cc).intValue(); - } - } - - File processedFileObject = null; - FileInfo fileInfo = null; - Optional processedFileBase64 = firstOutput != null ? firstOutput.getProcessedFile() : Optional.empty(); - Optional processedFileExtension = firstOutput != null ? firstOutput.getProcessedFileExtension() : Optional.empty(); - - if (processedFileBase64.isPresent() && processedFileExtension.isPresent()) { - try { - byte[] decodedBytes = Base64.getDecoder().decode(processedFileBase64.get()); - String suffix = "." + processedFileExtension.get(); - String fileName = Constants.DEIDENTIFIED_FILE_PREFIX + suffix; - processedFileObject = new File(System.getProperty("java.io.tmpdir"), fileName); - Files.write(processedFileObject.toPath(), decodedBytes); - fileInfo = new FileInfo(processedFileObject); - processedFileObject.deleteOnExit(); - } catch (IOException ioe) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedToEncodeFile.getMessage()); - } - } - - return new DeidentifyFileResponse( - fileInfo, - firstOutput.getProcessedFile().orElse(null), - firstOutput.getProcessedFileType().get().toString(), - firstOutput.getProcessedFileExtension().get(), - wordCount, - charCount, - response.getSize().map(Double::valueOf).orElse(null), - response.getDuration().map(Double::valueOf).orElse(null), - response.getPages().orElse(null), - response.getSlides().orElse(null), - getEntities(response), - runId, - status, - null - ); - } - - private static synchronized DeidentifyFileOutput getFirstOutput(DeidentifyStatusResponse response) { - List outputs = response.getOutput(); - return outputs != null && !outputs.isEmpty() ? outputs.get(0) : null; - } - - private static synchronized List getEntities(DeidentifyStatusResponse response) { - List entities = new ArrayList<>(); - - List outputs = response.getOutput(); - DeidentifyFileOutput deidentifyFileOutput = outputs != null && !outputs.isEmpty() ? outputs.get(1) : null; - - if (deidentifyFileOutput != null) { - entities.add(new FileEntityInfo( - deidentifyFileOutput.getProcessedFile().orElse(null), - deidentifyFileOutput.getProcessedFileType().orElse(null), - deidentifyFileOutput.getProcessedFileExtension().orElse(null) - )); - } - - return entities; - } - - private com.skyflow.generated.rest.types.DeidentifyFileResponse processFileByType(String fileExtension, String base64Content, DeidentifyFileRequest request, String vaultId) throws SkyflowException { - switch (fileExtension.toLowerCase()) { - case "txt": - com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest textFileRequest = - super.getDeidentifyTextFileRequest(request, vaultId, base64Content); - return super.getDetectFileAPi().deidentifyText(textFileRequest); - - case "mp3": - case "wav": - DeidentifyAudioRequest audioRequest = - super.getDeidentifyAudioRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifyAudio(audioRequest); - - case "pdf": - DeidentifyPdfRequest pdfRequest = - super.getDeidentifyPdfRequest(request, vaultId, base64Content); - - return super.getDetectFileAPi().deidentifyPdf(pdfRequest); - - case "jpg": - case "jpeg": - case "png": - case "bmp": - case "tif": - case "tiff": - DeidentifyImageRequest imageRequest = - super.getDeidentifyImageRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifyImage(imageRequest); - - case "ppt": - case "pptx": - DeidentifyPresentationRequest presentationRequest = - super.getDeidentifyPresentationRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifyPresentation(presentationRequest); - - case "csv": - case "xls": - case "xlsx": - DeidentifySpreadsheetRequest spreadsheetRequest = - super.getDeidentifySpreadsheetRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifySpreadsheet(spreadsheetRequest); - - case "doc": - case "docx": - DeidentifyDocumentRequest documentRequest = - super.getDeidentifyDocumentRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifyDocument(documentRequest); - - case "json": - case "xml": - DeidentifyStructuredTextRequest structuredTextRequest = - super.getDeidentifyStructuredTextRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifyStructuredText(structuredTextRequest); - - default: - com.skyflow.generated.rest.resources.files.requests.DeidentifyFileRequest genericFileRequest = - super.getDeidentifyGenericFileRequest(request, vaultId, base64Content, fileExtension); - return super.getDetectFileAPi().deidentifyFile(genericFileRequest); - } - } - - public DeidentifyFileResponse getDetectRun(GetDetectRunRequest request) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GET_DETECT_RUN_TRIGGERED.getLog()); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATE_GET_DETECT_RUN_REQUEST.getLog()); - Validations.validateGetDetectRunRequest(request); - setBearerToken(); - String runId = request.getRunId(); - String vaultId = super.getVaultConfig().getVaultId(); - - GetRunRequest getRunRequest = - GetRunRequest.builder() - .vaultId(vaultId) - .build(); - - com.skyflow.generated.rest.types.DeidentifyStatusResponse apiResponse = - super.getDetectFileAPi().getRun(runId, getRunRequest); - - return parseDeidentifyFileResponse(apiResponse, runId, apiResponse.getStatus().toString()); - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - 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 deleted file mode 100644 index 84e528b0..00000000 --- a/src/main/java/com/skyflow/vault/controller/VaultController.java +++ /dev/null @@ -1,362 +0,0 @@ -package com.skyflow.vault.controller; - -import com.google.gson.*; -import com.skyflow.VaultClient; -import com.skyflow.config.Credentials; -import com.skyflow.config.VaultConfig; -import com.skyflow.enums.RedactionType; -import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.rest.core.ApiClientApiException; -import com.skyflow.generated.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.rest.resources.query.requests.QueryServiceExecuteQueryBody; -import com.skyflow.generated.rest.resources.records.requests.*; -import com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestOrderBy; -import com.skyflow.generated.rest.resources.records.types.RecordServiceBulkGetRecordRequestRedaction; -import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; -import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.*; -import com.skyflow.logs.ErrorLogs; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.Constants; -import com.skyflow.utils.logger.LogUtil; -import com.skyflow.utils.validations.Validations; -import com.skyflow.vault.data.*; -import com.skyflow.vault.tokens.*; -import java.util.*; - -public final class VaultController extends VaultClient { - private static final Gson gson = new GsonBuilder().serializeNulls().create(); - - public VaultController(VaultConfig vaultConfig, Credentials credentials) { - super(vaultConfig, credentials); - } - - private static synchronized HashMap getFormattedBatchInsertRecord(Object record, int requestIndex) { - HashMap insertRecord = new HashMap<>(); - String jsonString = gson.toJson(record); - JsonObject bodyObject = JsonParser.parseString(jsonString).getAsJsonObject().get("Body").getAsJsonObject(); - JsonArray records = bodyObject.getAsJsonArray("records"); - JsonPrimitive error = bodyObject.getAsJsonPrimitive("error"); - - if (records != null) { - for (JsonElement recordElement : records) { - JsonObject recordObject = recordElement.getAsJsonObject(); - insertRecord.put("skyflowId", recordObject.get("skyflow_id").getAsString()); - JsonElement tokensElement = recordObject.get("tokens"); - if (tokensElement != null) { - insertRecord.putAll(tokensElement.getAsJsonObject().asMap()); - } - } - } - - if (error != null) { - insertRecord.put("error", error.getAsString()); - } - insertRecord.put("requestIndex", requestIndex); - return insertRecord; - } - - private static synchronized HashMap getFormattedBulkInsertRecord(V1RecordMetaProperties record) { - HashMap insertRecord = new HashMap<>(); - if (record.getSkyflowId().isPresent()) { - insertRecord.put("skyflowId", record.getSkyflowId().get()); - } - - if (record.getTokens().isPresent()) { - Map tokensMap = record.getTokens().get(); - insertRecord.putAll(tokensMap); - } - return insertRecord; - } - - private static synchronized HashMap getFormattedGetRecord(V1FieldRecords record) { - HashMap getRecord = new HashMap<>(); - - Optional> fieldsOpt = record.getFields(); - Optional> tokensOpt = record.getTokens(); - - if (fieldsOpt.isPresent()) { - getRecord.putAll(fieldsOpt.get()); - } else if (tokensOpt.isPresent()) { - getRecord.putAll(tokensOpt.get()); - } - return getRecord; - } - - private static synchronized HashMap getFormattedUpdateRecord(V1UpdateRecordResponse record) { - HashMap updateTokens = new HashMap<>(); - - record.getSkyflowId().ifPresent(skyflowId -> updateTokens.put("skyflowId", skyflowId)); - - record.getTokens().ifPresent(tokensMap -> updateTokens.putAll(tokensMap)); - - return updateTokens; - } - - 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()); - } - return queryRecord; - } - - public InsertResponse insert(InsertRequest insertRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); - V1InsertRecordResponse bulkInsertResult = null; - ApiClientHttpResponse batchInsertResult = null; - ArrayList> insertedFields = new ArrayList<>(); - ArrayList> errorFields = new ArrayList<>(); - Boolean continueOnError = insertRequest.getContinueOnError(); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); - Validations.validateInsertRequest(insertRequest); - setBearerToken(); - if (continueOnError) { - RecordServiceBatchOperationBody insertBody = super.getBatchInsertRequestBody(insertRequest); - batchInsertResult = super.getRecordsApi().withRawResponse().recordServiceBatchOperation(super.getVaultConfig().getVaultId(), insertBody); - LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); - Optional>> records = batchInsertResult.body().getResponses(); - - if (records.isPresent()) { - List> recordList = records.get(); - - for (int index = 0; index < recordList.size(); index++) { - Map record = recordList.get(index); - HashMap insertRecord = getFormattedBatchInsertRecord(record, index); - - if (insertRecord.containsKey("skyflowId")) { - insertedFields.add(insertRecord); - } else { - insertRecord.put("requestId", batchInsertResult.headers().get("x-request-id").get(0)); - errorFields.add(insertRecord); - } - } - } - } else { - RecordServiceInsertRecordBody insertBody = super.getBulkInsertRequestBody(insertRequest); - bulkInsertResult = super.getRecordsApi().recordServiceInsertRecord( - super.getVaultConfig().getVaultId(), insertRequest.getTable(), insertBody); - LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); - Optional> records = bulkInsertResult.getRecords(); - if (records.isPresent()) { - for (V1RecordMetaProperties record : records.get()) { - HashMap insertRecord = getFormattedBulkInsertRecord(record); - insertedFields.add(insertRecord); - } - } - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.INSERT_SUCCESS.getLog()); - if (insertedFields.isEmpty()) { - return new InsertResponse(null, errorFields.isEmpty() ? null : errorFields); - } - if (errorFields.isEmpty()) { - return new InsertResponse(insertedFields.isEmpty() ? null : insertedFields, null); - } - return new InsertResponse(insertedFields, errorFields); - } - - public DetokenizeResponse detokenize(DetokenizeRequest detokenizeRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.DETOKENIZE_TRIGGERED.getLog()); - ApiClientHttpResponse result = null; - ArrayList detokenizedFields = new ArrayList<>(); - ArrayList errorRecords = new ArrayList<>(); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATE_DETOKENIZE_REQUEST.getLog()); - Validations.validateDetokenizeRequest(detokenizeRequest); - setBearerToken(); - V1DetokenizePayload payload = super.getDetokenizePayload(detokenizeRequest); - result = super.getTokensApi().withRawResponse().recordServiceDetokenize(super.getVaultConfig().getVaultId(), payload); - LogUtil.printInfoLog(InfoLogs.DETOKENIZE_REQUEST_RESOLVED.getLog()); - Map> responseHeaders = result.headers(); - String requestId = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY).get(0); - Optional> records = result.body().getRecords(); - - if (records.isPresent()) { - List recordList = records.get(); - - for (V1DetokenizeRecordResponse record : recordList) { - if (record.getError().isPresent()) { - DetokenizeRecordResponse recordResponse = new DetokenizeRecordResponse(record, requestId); - errorRecords.add(recordResponse); - } else { - DetokenizeRecordResponse recordResponse = new DetokenizeRecordResponse(record); - detokenizedFields.add(recordResponse); - } - } - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - - if (!errorRecords.isEmpty()) { - LogUtil.printInfoLog(InfoLogs.DETOKENIZE_PARTIAL_SUCCESS.getLog()); - } else { - LogUtil.printInfoLog(InfoLogs.DETOKENIZE_SUCCESS.getLog()); - } - if (detokenizedFields.isEmpty()) { - return new DetokenizeResponse(null, errorRecords.isEmpty() ? null : errorRecords); - } - if (errorRecords.isEmpty()) { - return new DetokenizeResponse(detokenizedFields, null); - } - return new DetokenizeResponse(detokenizedFields, errorRecords); - } - - public GetResponse get(GetRequest getRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.GET_TRIGGERED.getLog()); - V1BulkGetRecordResponse result = null; - ArrayList> data = new ArrayList<>(); - ArrayList> errors = new ArrayList<>(); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATE_GET_REQUEST.getLog()); - Validations.validateGetRequest(getRequest); - setBearerToken(); - RedactionType redactionType = getRequest.getRedactionType(); - RecordServiceBulkGetRecordRequest recordServiceBulkGetRecordRequest = RecordServiceBulkGetRecordRequest.builder() - .skyflowIds(getRequest.getIds()) - .redaction(redactionType != null ? RecordServiceBulkGetRecordRequestRedaction.valueOf(redactionType.toString()) : null) - .tokenization(getRequest.getReturnTokens()) - .offset(getRequest.getOffset()) - .limit(getRequest.getLimit()) - .downloadUrl(getRequest.getDownloadURL()) - .columnName(getRequest.getColumnName()) - .columnValues(getRequest.getColumnValues()) - .orderBy(RecordServiceBulkGetRecordRequestOrderBy.valueOf(getRequest.getOrderBy())) - .build(); - - - result = super.getRecordsApi().recordServiceBulkGetRecord( - super.getVaultConfig().getVaultId(), - getRequest.getTable(), - recordServiceBulkGetRecordRequest - ); - LogUtil.printInfoLog(InfoLogs.GET_REQUEST_RESOLVED.getLog()); - List records = result.getRecords().get(); - if (records != null) { - for (V1FieldRecords record : records) { - data.add(getFormattedGetRecord(record)); - } - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.GET_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.GET_SUCCESS.getLog()); - return new GetResponse(data, null); - } - - public UpdateResponse update(UpdateRequest updateRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.UPDATE_TRIGGERED.getLog()); - V1UpdateRecordResponse result; - String skyflowId; - HashMap tokensMap; - try { - LogUtil.printInfoLog(InfoLogs.VALIDATE_UPDATE_REQUEST.getLog()); - Validations.validateUpdateRequest(updateRequest); - setBearerToken(); - RecordServiceUpdateRecordBody updateBody = super.getUpdateRequestBody(updateRequest); - result = super.getRecordsApi().recordServiceUpdateRecord( - super.getVaultConfig().getVaultId(), - updateRequest.getTable(), - updateRequest.getData().remove("skyflow_id").toString(), - updateBody - ); - LogUtil.printInfoLog(InfoLogs.UPDATE_REQUEST_RESOLVED.getLog()); - skyflowId = String.valueOf(result.getSkyflowId()); - tokensMap = getFormattedUpdateRecord(result); - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.UPDATE_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.UPDATE_SUCCESS.getLog()); - return new UpdateResponse(skyflowId, tokensMap); - } - - public DeleteResponse delete(DeleteRequest deleteRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.DELETE_TRIGGERED.getLog()); - V1BulkDeleteRecordResponse result; - try { - LogUtil.printInfoLog(InfoLogs.VALIDATING_DELETE_REQUEST.getLog()); - Validations.validateDeleteRequest(deleteRequest); - setBearerToken(); - RecordServiceBulkDeleteRecordBody deleteBody = RecordServiceBulkDeleteRecordBody.builder().skyflowIds(deleteRequest.getIds()) - .build(); - - result = super.getRecordsApi().recordServiceBulkDeleteRecord( - super.getVaultConfig().getVaultId(), deleteRequest.getTable(), deleteBody); - LogUtil.printInfoLog(InfoLogs.DELETE_REQUEST_RESOLVED.getLog()); - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.DELETE_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.DELETE_SUCCESS.getLog()); - return new DeleteResponse(result.getRecordIdResponse().get()); - } - - public QueryResponse query(QueryRequest queryRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.QUERY_TRIGGERED.getLog()); - V1GetQueryResponse result; - ArrayList> fields = new ArrayList<>(); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATING_QUERY_REQUEST.getLog()); - Validations.validateQueryRequest(queryRequest); - setBearerToken(); - result = super.getQueryApi().queryServiceExecuteQuery( - super.getVaultConfig().getVaultId(), QueryServiceExecuteQueryBody.builder().query(queryRequest.getQuery()).build()); - LogUtil.printInfoLog(InfoLogs.QUERY_REQUEST_RESOLVED.getLog()); - if (result.getRecords().isPresent()) { - List records = result.getRecords().get(); // Extract the List from Optional - for (V1FieldRecords record : records) { - fields.add(getFormattedQueryRecord(record)); - } - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.QUERY_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.QUERY_SUCCESS.getLog()); - return new QueryResponse(fields); - } - - public TokenizeResponse tokenize(TokenizeRequest tokenizeRequest) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.TOKENIZE_TRIGGERED.getLog()); - V1TokenizeResponse result = null; - List list = new ArrayList<>(); - try { - LogUtil.printInfoLog(InfoLogs.VALIDATING_TOKENIZE_REQUEST.getLog()); - Validations.validateTokenizeRequest(tokenizeRequest); - setBearerToken(); - V1TokenizePayload payload = super.getTokenizePayload(tokenizeRequest); - result = super.getTokensApi().recordServiceTokenize(super.getVaultConfig().getVaultId(), payload); - LogUtil.printInfoLog(InfoLogs.TOKENIZE_REQUEST_RESOLVED.getLog()); - if (result != null && result.getRecords().isPresent() && !result.getRecords().get().isEmpty()) { - for (V1TokenizeRecordResponse response : result.getRecords().get()) { - if (response.getToken().isPresent()) { - list.add(response.getToken().get()); - } - } - } - } catch (ApiClientApiException e) { - String bodyString = gson.toJson(e.body()); - LogUtil.printErrorLog(ErrorLogs.TOKENIZE_REQUEST_REJECTED.getLog()); - throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } - LogUtil.printInfoLog(InfoLogs.TOKENIZE_SUCCESS.getLog()); - return new TokenizeResponse(list); - } -} diff --git a/src/main/java/com/skyflow/vault/data/DeleteRequest.java b/src/main/java/com/skyflow/vault/data/DeleteRequest.java deleted file mode 100644 index d61c996f..00000000 --- a/src/main/java/com/skyflow/vault/data/DeleteRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.skyflow.vault.data; - -import java.util.ArrayList; - -public class DeleteRequest { - private final DeleteRequestBuilder builder; - - private DeleteRequest(DeleteRequestBuilder builder) { - this.builder = builder; - } - - public static DeleteRequestBuilder builder() { - return new DeleteRequestBuilder(); - } - - public String getTable() { - return this.builder.table; - } - - public ArrayList getIds() { - return this.builder.ids; - } - - public static final class DeleteRequestBuilder { - private String table; - private ArrayList ids; - - private DeleteRequestBuilder() { - } - - public DeleteRequestBuilder table(String table) { - this.table = table; - return this; - } - - public DeleteRequestBuilder ids(ArrayList ids) { - this.ids = ids; - return this; - } - - public DeleteRequest build() { - return new DeleteRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/data/DeleteResponse.java b/src/main/java/com/skyflow/vault/data/DeleteResponse.java deleted file mode 100644 index f34d219a..00000000 --- a/src/main/java/com/skyflow/vault/data/DeleteResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.List; - -public class DeleteResponse { - private final List deletedIds; - - public DeleteResponse(List deletedIds) { - this.deletedIds = deletedIds; - } - - public List getDeletedIds() { - return deletedIds; - } - - @Override - public String toString() { - Gson gson = new Gson(); - JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); - responseObject.add("errors", null); - return responseObject.toString(); - } -} diff --git a/src/main/java/com/skyflow/vault/data/GetRequest.java b/src/main/java/com/skyflow/vault/data/GetRequest.java deleted file mode 100644 index 04626e35..00000000 --- a/src/main/java/com/skyflow/vault/data/GetRequest.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.skyflow.vault.data; - -import com.skyflow.enums.RedactionType; -import com.skyflow.utils.Constants; - -import java.util.ArrayList; - -public class GetRequest { - private final GetRequestBuilder builder; - - private GetRequest(GetRequestBuilder builder) { - this.builder = builder; - } - - public static GetRequestBuilder builder() { - return new GetRequestBuilder(); - } - - public String getTable() { - return this.builder.table; - } - - public ArrayList getIds() { - return this.builder.ids; - } - - public RedactionType getRedactionType() { - return this.builder.redactionType; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public ArrayList getFields() { - return this.builder.fields; - } - - public String getOffset() { - return this.builder.offset; - } - - public String getLimit() { - return this.builder.limit; - } - - public Boolean getDownloadURL() { - return this.builder.downloadURL; - } - - public String getColumnName() { - return this.builder.columnName; - } - - public ArrayList getColumnValues() { - return this.builder.columnValues; - } - - public String getOrderBy() { - return this.builder.orderBy; - } - - public static final class GetRequestBuilder { - private String table; - private ArrayList ids; - private RedactionType redactionType; - private Boolean returnTokens; - private ArrayList fields; - private String offset; - private String limit; - private Boolean downloadURL; - private String columnName; - private ArrayList columnValues; - private String orderBy; - - private GetRequestBuilder() { - this.downloadURL = true; - this.orderBy = Constants.ORDER_ASCENDING; - } - - public GetRequestBuilder table(String table) { - this.table = table; - return this; - } - - public GetRequestBuilder ids(ArrayList ids) { - this.ids = ids; - return this; - } - - public GetRequestBuilder redactionType(RedactionType redactionType) { - this.redactionType = redactionType; - return this; - } - - public GetRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens; - return this; - } - - public GetRequestBuilder fields(ArrayList fields) { - this.fields = fields; - return this; - } - - public GetRequestBuilder offset(String offset) { - this.offset = offset; - return this; - } - - public GetRequestBuilder limit(String limit) { - this.limit = limit; - return this; - } - - public GetRequestBuilder downloadURL(Boolean downloadURL) { - this.downloadURL = downloadURL == null || downloadURL; - return this; - } - - public GetRequestBuilder columnName(String columnName) { - this.columnName = columnName; - return this; - } - - public GetRequestBuilder columnValues(ArrayList columnValues) { - this.columnValues = columnValues; - return this; - } - - public GetRequestBuilder orderBy(String orderBy) { - this.orderBy = orderBy == null ? Constants.ORDER_ASCENDING : orderBy; - return this; - } - - public GetRequest build() { - return new GetRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/data/GetResponse.java b/src/main/java/com/skyflow/vault/data/GetResponse.java deleted file mode 100644 index 41821969..00000000 --- a/src/main/java/com/skyflow/vault/data/GetResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; - -import java.util.ArrayList; -import java.util.HashMap; - -public class GetResponse { - private final ArrayList> data; - private final ArrayList> errors; - - public GetResponse(ArrayList> data, ArrayList> errors) { - this.data = data; - this.errors = errors; - } - - public ArrayList> getData() { - return data; - } - - public ArrayList> getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/src/main/java/com/skyflow/vault/data/InsertRequest.java b/src/main/java/com/skyflow/vault/data/InsertRequest.java deleted file mode 100644 index 54093467..00000000 --- a/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.skyflow.vault.data; - -import com.skyflow.enums.TokenMode; - -import java.util.ArrayList; -import java.util.HashMap; - -public class InsertRequest { - private final InsertRequestBuilder builder; - - private InsertRequest(InsertRequestBuilder builder) { - this.builder = builder; - } - - public static InsertRequestBuilder builder() { - return new InsertRequestBuilder(); - } - - public String getTable() { - return this.builder.table; - } - - public ArrayList> getValues() { - return this.builder.values; - } - - public ArrayList> getTokens() { - return this.builder.tokens; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public String getUpsert() { - return this.builder.upsert; - } - - public Boolean getHomogeneous() { - return this.builder.homogeneous; - } - - public Boolean getContinueOnError() { - return this.builder.continueOnError; - } - - public TokenMode getTokenMode() { - return this.builder.tokenMode; - } - - public static final class InsertRequestBuilder { - private String table; - private ArrayList> values; - private ArrayList> tokens; - private Boolean returnTokens; - private String upsert; - private Boolean homogeneous; - private Boolean continueOnError; - private TokenMode tokenMode; - - private InsertRequestBuilder() { - this.returnTokens = false; - this.continueOnError = false; - this.tokenMode = TokenMode.DISABLE; - } - - public InsertRequestBuilder table(String table) { - this.table = table; - return this; - } - - public InsertRequestBuilder values(ArrayList> values) { - this.values = values; - return this; - } - - public InsertRequestBuilder tokens(ArrayList> tokens) { - this.tokens = tokens; - return this; - } - - public InsertRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens != null && returnTokens; - return this; - } - - public InsertRequestBuilder upsert(String upsert) { - this.upsert = upsert; - return this; - } - - public InsertRequestBuilder homogeneous(Boolean homogeneous) { - this.homogeneous = homogeneous; - return this; - } - - public InsertRequestBuilder continueOnError(Boolean continueOnError) { - this.continueOnError = continueOnError != null && continueOnError; - return this; - } - - public InsertRequestBuilder tokenMode(TokenMode tokenMode) { - this.tokenMode = tokenMode == null ? TokenMode.DISABLE : tokenMode; - return this; - } - - public InsertRequest build() { - return new InsertRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/data/InsertResponse.java b/src/main/java/com/skyflow/vault/data/InsertResponse.java deleted file mode 100644 index a4f97967..00000000 --- a/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; - -import java.util.ArrayList; -import java.util.HashMap; - -public class InsertResponse { - private final ArrayList> insertedFields; - private final ArrayList> errors; - - public InsertResponse(ArrayList> insertedFields, ArrayList> errors) { - this.insertedFields = insertedFields; - this.errors = errors; - } - - public ArrayList> getInsertedFields() { - return insertedFields; - } - - public ArrayList> getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/src/main/java/com/skyflow/vault/data/QueryRequest.java b/src/main/java/com/skyflow/vault/data/QueryRequest.java deleted file mode 100644 index 2aaa200d..00000000 --- a/src/main/java/com/skyflow/vault/data/QueryRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.skyflow.vault.data; - -public class QueryRequest { - private final QueryRequestBuilder builder; - - private QueryRequest(QueryRequestBuilder builder) { - this.builder = builder; - } - - public static QueryRequestBuilder builder() { - return new QueryRequestBuilder(); - } - - public String getQuery() { - return this.builder.query; - } - - public static final class QueryRequestBuilder { - private String query; - - private QueryRequestBuilder() { - } - - public QueryRequestBuilder query(String query) { - this.query = query; - return this; - } - - public QueryRequest build() { - return new QueryRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/data/QueryResponse.java b/src/main/java/com/skyflow/vault/data/QueryResponse.java deleted file mode 100644 index 7a1bca51..00000000 --- a/src/main/java/com/skyflow/vault/data/QueryResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.*; - -import java.util.ArrayList; -import java.util.HashMap; - -public class QueryResponse { - private final ArrayList> fields; - private ArrayList> tokenizedData; - - public QueryResponse(ArrayList> fields) { - this.fields = fields; - } - - public ArrayList> getFields() { - return fields; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - JsonObject responseObject = gson.toJsonTree(this).getAsJsonObject(); - JsonArray fieldsArray = responseObject.get("fields").getAsJsonArray(); - for (JsonElement fieldElement : fieldsArray) { - fieldElement.getAsJsonObject().add("tokenizedData", new JsonObject()); - } - responseObject.add("errors", null); - responseObject.remove("tokenizedData"); - return responseObject.toString(); - } -} diff --git a/src/main/java/com/skyflow/vault/data/UpdateRequest.java b/src/main/java/com/skyflow/vault/data/UpdateRequest.java deleted file mode 100644 index 94789121..00000000 --- a/src/main/java/com/skyflow/vault/data/UpdateRequest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.skyflow.vault.data; - -import com.skyflow.enums.TokenMode; - -import java.util.HashMap; - -public class UpdateRequest { - private final UpdateRequestBuilder builder; - - private UpdateRequest(UpdateRequestBuilder builder) { - this.builder = builder; - } - - public static UpdateRequestBuilder builder() { - return new UpdateRequestBuilder(); - } - - public String getTable() { - return this.builder.table; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public HashMap getData() { - return this.builder.data; - } - - public HashMap getTokens() { - return this.builder.tokens; - } - - public TokenMode getTokenMode() { - return this.builder.tokenMode; - } - - public static final class UpdateRequestBuilder { - private String table; - private Boolean returnTokens; - private HashMap data; - private HashMap tokens; - private TokenMode tokenMode; - - private UpdateRequestBuilder() { - this.returnTokens = false; - this.tokenMode = TokenMode.DISABLE; - } - - public UpdateRequestBuilder table(String table) { - this.table = table; - return this; - } - - public UpdateRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens != null && returnTokens; - return this; - } - - public UpdateRequestBuilder data(HashMap data) { - this.data = data; - return this; - } - - public UpdateRequestBuilder tokens(HashMap tokens) { - this.tokens = tokens; - return this; - } - - public UpdateRequestBuilder tokenMode(TokenMode tokenStrict) { - this.tokenMode = tokenStrict == null ? TokenMode.DISABLE : tokenStrict; - return this; - } - - public UpdateRequest build() { - return new UpdateRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/data/UpdateResponse.java b/src/main/java/com/skyflow/vault/data/UpdateResponse.java deleted file mode 100644 index 068b29be..00000000 --- a/src/main/java/com/skyflow/vault/data/UpdateResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.HashMap; - -public class UpdateResponse { - private final String skyflowId; - private final HashMap tokens; - - public UpdateResponse(String skyflowId, HashMap tokens) { - this.skyflowId = skyflowId; - this.tokens = tokens; - } - - public String getSkyflowId() { - return skyflowId; - } - - public HashMap getTokens() { - return tokens; - } - - @Override - public String toString() { - Gson gson = new Gson(); - JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); - JsonObject tokensObject = responseObject.remove("tokens").getAsJsonObject(); - for (String key : tokensObject.keySet()) { - responseObject.add(key, tokensObject.get(key)); - } - JsonObject finalResponseObject = new JsonObject(); - finalResponseObject.add("updatedField", responseObject); - finalResponseObject.add("errors", null); - return finalResponseObject.toString(); - } -} diff --git a/src/main/java/com/skyflow/vault/detect/AudioBleep.java b/src/main/java/com/skyflow/vault/detect/AudioBleep.java deleted file mode 100644 index 1a75f93b..00000000 --- a/src/main/java/com/skyflow/vault/detect/AudioBleep.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.skyflow.vault.detect; - -public class AudioBleep { - private final AudioBleepBuilder builder; - - private AudioBleep(AudioBleepBuilder builder) { - this.builder = builder; - } - - public static AudioBleepBuilder builder() { - return new AudioBleepBuilder(); - } - - public Double getGain() { - return this.builder.gain; - } - - public Double getFrequency() { - return this.builder.frequency; - } - - public Double getStartPadding() { - return this.builder.startPadding; - } - - public Double getStopPadding() { - return this.builder.stopPadding; - } - - public static final class AudioBleepBuilder { - private Double gain; - private Double frequency; - private Double startPadding; - private Double stopPadding; - - private AudioBleepBuilder() { - // Default constructor - } - - public AudioBleepBuilder gain(Double gain) { - this.gain = gain; - return this; - } - - public AudioBleepBuilder frequency(Double frequency) { - this.frequency = frequency; - return this; - } - - public AudioBleepBuilder startPadding(Double startPadding) { - this.startPadding = startPadding; - return this; - } - - public AudioBleepBuilder stopPadding(Double stopPadding) { - this.stopPadding = stopPadding; - return this; - } - - public AudioBleep build() { - return new AudioBleep(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/DateTransformation.java b/src/main/java/com/skyflow/vault/detect/DateTransformation.java deleted file mode 100644 index 819927d2..00000000 --- a/src/main/java/com/skyflow/vault/detect/DateTransformation.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.skyflow.enums.DetectEntities; - -import java.util.List; - -public class DateTransformation { - private final int max; - private final int min; - private final List entities; - - public DateTransformation(int max, int min, List entities) { - this.max = max; - this.min = min; - this.entities = entities; - } - - public int getMax() { - return max; - } - - public int getMin() { - return min; - } - - public List getEntities() { - return entities; - } -} diff --git a/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java b/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java deleted file mode 100644 index 3ebc450e..00000000 --- a/src/main/java/com/skyflow/vault/detect/DeidentifyFileRequest.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.skyflow.vault.detect; - -import com.skyflow.enums.DetectEntities; -import com.skyflow.enums.DetectOutputTranscriptions; -import com.skyflow.enums.MaskingMethod; -import java.util.List; - -public class DeidentifyFileRequest { - private final DeidentifyFileRequestBuilder builder; - - private DeidentifyFileRequest(DeidentifyFileRequestBuilder builder) { - this.builder = builder; - } - - public static DeidentifyFileRequestBuilder builder() { - return new DeidentifyFileRequestBuilder(); - } - - public FileInput getFileInput() { - return this.builder.fileInput; - } - - public List getEntities() { - return this.builder.entities; - } - - public List getAllowRegexList() { - return this.builder.allowRegexList; - } - - public List getRestrictRegexList() { - return this.builder.restrictRegexList; - } - - public TokenFormat getTokenFormat() { - return this.builder.tokenFormat; - } - - public Transformations getTransformations() { - return this.builder.transformations; - } - - public Boolean getOutputProcessedImage() { - return this.builder.outputProcessedImage; - } - - public Boolean getOutputOcrText() { - return this.builder.outputOcrText; - } - - public MaskingMethod getMaskingMethod() { - return this.builder.maskingMethod; - } - - public Number getPixelDensity() { - return this.builder.pixelDensity; - } - - public Number getMaxResolution() { - return this.builder.maxResolution; - } - - public Boolean getOutputProcessedAudio() { - return this.builder.outputProcessedAudio; - } - - public DetectOutputTranscriptions getOutputTranscription() { - return this.builder.outputTranscription; - } - - public AudioBleep getBleep() { - return this.builder.bleep; - } - - public String getOutputDirectory() { - return this.builder.outputDirectory; - } - - public Integer getWaitTime() { - return this.builder.waitTime; - } - - public static final class DeidentifyFileRequestBuilder { - private List entities; - private List allowRegexList; - private List restrictRegexList; - private TokenFormat tokenFormat; - private Transformations transformations; - private Boolean outputProcessedImage; - private Boolean outputOcrText; - private MaskingMethod maskingMethod; - private Number pixelDensity; - private Number maxResolution; - private Boolean outputProcessedAudio; - private DetectOutputTranscriptions outputTranscription; - private AudioBleep bleep; - private FileInput fileInput; - private String outputDirectory; - private Integer waitTime; - - private DeidentifyFileRequestBuilder() { - // Set default values - this.outputProcessedImage = false; - this.outputOcrText = false; - this.outputProcessedAudio = false; - } - - public DeidentifyFileRequestBuilder file(FileInput fileInput) { - this.fileInput = fileInput; - return this; - } - - public DeidentifyFileRequestBuilder entities(List entities) { - this.entities = entities; - return this; - } - - public DeidentifyFileRequestBuilder allowRegexList(List allowRegexList) { - this.allowRegexList = allowRegexList; - return this; - } - - public DeidentifyFileRequestBuilder restrictRegexList(List restrictRegexList) { - this.restrictRegexList = restrictRegexList; - return this; - } - - public DeidentifyFileRequestBuilder tokenFormat(TokenFormat tokenFormat) { - this.tokenFormat = tokenFormat; - return this; - } - - public DeidentifyFileRequestBuilder transformations(Transformations transformations) { - this.transformations = transformations; - return this; - } - - public DeidentifyFileRequestBuilder outputProcessedImage(Boolean outputProcessedImage) { - this.outputProcessedImage = outputProcessedImage != null ? outputProcessedImage : false; - return this; - } - - public DeidentifyFileRequestBuilder outputOcrText(Boolean outputOcrText) { - this.outputOcrText = outputOcrText != null ? outputOcrText : false; - return this; - } - - public DeidentifyFileRequestBuilder maskingMethod(MaskingMethod maskingMethod) { - this.maskingMethod = maskingMethod; - return this; - } - - public DeidentifyFileRequestBuilder pixelDensity(Number pixelDensity) { - this.pixelDensity = pixelDensity; - return this; - } - - public DeidentifyFileRequestBuilder maxResolution(Number maxResolution) { - this.maxResolution = maxResolution; - return this; - } - - public DeidentifyFileRequestBuilder outputProcessedAudio(Boolean outputProcessedAudio) { - this.outputProcessedAudio = outputProcessedAudio != null ? outputProcessedAudio : false; - return this; - } - - public DeidentifyFileRequestBuilder outputTranscription(DetectOutputTranscriptions outputTranscription) { - this.outputTranscription = outputTranscription; - return this; - } - - public DeidentifyFileRequestBuilder bleep(AudioBleep bleep) { - this.bleep = bleep; - return this; - } - - public DeidentifyFileRequestBuilder outputDirectory(String outputDirectory) { - this.outputDirectory = outputDirectory; - return this; - } - - public DeidentifyFileRequestBuilder waitTime(Integer waitTime) { - this.waitTime = waitTime; - return this; - } - - public DeidentifyFileRequest build() { - return new DeidentifyFileRequest(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java b/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java deleted file mode 100644 index 95effea0..00000000 --- a/src/main/java/com/skyflow/vault/detect/DeidentifyFileResponse.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.skyflow.vault.detect; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import java.io.File; -import java.util.List; - -public class DeidentifyFileResponse { - private final FileInfo file; - private final String fileBase64; - private final String type; - private final String extension; - private final Integer wordCount; - private final Integer charCount; - private final Double sizeInKb; - private final Double durationInSeconds; - private final Integer pageCount; - private final Integer slideCount; - 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) { - this.file = file; - this.fileBase64 = fileBase64; - this.type = type; - this.extension = extension; - this.wordCount = wordCount; - this.charCount = charCount; - this.sizeInKb = sizeInKb; - this.durationInSeconds = durationInSeconds; - this.pageCount = pageCount; - this.slideCount = slideCount; - 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); - } - - public FileInfo getFile() { - return file; - } - - public String getFileBase64(){ - return fileBase64; - } - - public String getType() { - return type; - } - - public String getExtension() { - return extension; - } - - public Integer getWordCount() { - return wordCount; - } - - public Integer getCharCount() { - return charCount; - } - - public Double getSizeInKb() { - return sizeInKb; - } - - public Double getDurationInSeconds() { - return durationInSeconds; - } - - public Integer getPageCount() { - return pageCount; - } - - public Integer getSlideCount() { - return slideCount; - } - - public List getEntities() { - return entities; - } - - public String getRunId() { - return runId; - } - - public String getStatus() { - return status; - } - - public List getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - return gson.toJson(this); - } - -} diff --git a/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java b/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java deleted file mode 100644 index 5f57e3a9..00000000 --- a/src/main/java/com/skyflow/vault/detect/DeidentifyTextRequest.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.skyflow.enums.DetectEntities; - -import java.util.List; - -public class DeidentifyTextRequest { - private final DeidentifyTextRequestBuilder builder; - - private DeidentifyTextRequest(DeidentifyTextRequestBuilder builder) { - this.builder = builder; - } - - public static DeidentifyTextRequestBuilder builder() { - return new DeidentifyTextRequestBuilder(); - } - - public String getText() { - return this.builder.text; - } - - public List getEntities() { - return this.builder.entities; - } - - public List getAllowRegexList() { - return this.builder.allowRegexList; - } - - public List getRestrictRegexList() { - return this.builder.restrictRegexList; - } - - public TokenFormat getTokenFormat() { - return this.builder.tokenFormat; - } - - public Transformations getTransformations() { - return this.builder.transformations; - } - - public static final class DeidentifyTextRequestBuilder { - private String text; - private List entities; - private List allowRegexList; - private List restrictRegexList; - private TokenFormat tokenFormat; - private Transformations transformations; - - private DeidentifyTextRequestBuilder() { - } - - public DeidentifyTextRequestBuilder text(String text) { - this.text = text; - return this; - } - - public DeidentifyTextRequestBuilder entities(List entities) { - this.entities = entities; - return this; - } - - public DeidentifyTextRequestBuilder allowRegexList(List allowRegexList) { - this.allowRegexList = allowRegexList; - return this; - } - - public DeidentifyTextRequestBuilder restrictRegexList(List restrictRegexList) { - this.restrictRegexList = restrictRegexList; - return this; - } - - public DeidentifyTextRequestBuilder tokenFormat(TokenFormat tokenFormat) { - this.tokenFormat = tokenFormat; - return this; - } - - public DeidentifyTextRequestBuilder transformations(Transformations transformations) { - this.transformations = transformations; - return this; - } - - public DeidentifyTextRequest build() { - return new DeidentifyTextRequest(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java b/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java deleted file mode 100644 index 6b6118e0..00000000 --- a/src/main/java/com/skyflow/vault/detect/DeidentifyTextResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import java.util.List; - -public class DeidentifyTextResponse { - private final String processedText; - private final List entities; - private final int wordCount; - private final int charCount; - - public DeidentifyTextResponse(String processedText, List entities, int wordCount, int charCount) { - this.processedText = processedText; - this.entities = entities; - this.wordCount = wordCount; - this.charCount = charCount; - } - - public String getProcessedText() { - return processedText; - } - - public List getEntities() { - return entities; - } - - public int getWordCount() { - return wordCount; - } - - public int getCharCount() { - return charCount; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - return gson.toJson(this); - } - -} diff --git a/src/main/java/com/skyflow/vault/detect/EntityInfo.java b/src/main/java/com/skyflow/vault/detect/EntityInfo.java deleted file mode 100644 index 4a84acf9..00000000 --- a/src/main/java/com/skyflow/vault/detect/EntityInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.skyflow.vault.detect; - - -import java.util.Map; - -public class EntityInfo { - private final String token; - private final String value; - private final TextIndex textIndex; - private final TextIndex processedIndex; - private final String entity; - private final Map scores; - - public EntityInfo(String token, String value, TextIndex textIndex, TextIndex processedIndex, String entity, java.util.Map scores) { - this.token = token; - this.value = value; - this.textIndex = textIndex; - this.processedIndex = processedIndex; - this.entity = entity; - this.scores = scores; - } - - public String getToken() { - return token; - } - - public String getValue() { - return value; - } - - public TextIndex getTextIndex() { - return textIndex; - } - - public TextIndex getProcessedIndex() { - return processedIndex; - } - - public String getEntity() { - return entity; - } - - public Map getScores() { - return scores; - } -} diff --git a/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java b/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java deleted file mode 100644 index e177a99a..00000000 --- a/src/main/java/com/skyflow/vault/detect/FileEntityInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.skyflow.vault.detect; - -import com.skyflow.generated.rest.types.DeidentifyFileOutputProcessedFileType; - -public class FileEntityInfo { - private final String file; - private final String type; - private final String extension; - - public FileEntityInfo(String file, DeidentifyFileOutputProcessedFileType type, String extension) { - this.file = file; - this.type = String.valueOf(type); - this.extension = extension; - } - - public String getFile() { return file; } - public String getType() { return type; } - public String getExtension() { return extension; } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/FileInfo.java b/src/main/java/com/skyflow/vault/detect/FileInfo.java deleted file mode 100644 index 2f13c4f2..00000000 --- a/src/main/java/com/skyflow/vault/detect/FileInfo.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.skyflow.vault.detect; - -import java.io.File; - -public class FileInfo { - private String name; - private long size; - private String type; - private long lastModified; - - public FileInfo(File file) { - this.name = file.getName(); - this.size = file.length(); - this.type = ""; - this.lastModified = file.lastModified(); - } - - public String getName() { - return name; - } - - public long getSize() { - return size; - } - - public String getType() { - return type; - } - - public long getLastModified() { - return lastModified; - } -} diff --git a/src/main/java/com/skyflow/vault/detect/FileInput.java b/src/main/java/com/skyflow/vault/detect/FileInput.java deleted file mode 100644 index 3ff1a77e..00000000 --- a/src/main/java/com/skyflow/vault/detect/FileInput.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.skyflow.vault.detect; - -import java.io.File; - -public class FileInput { - private final FileInputBuilder builder; - - private FileInput(FileInputBuilder builder) { - this.builder = builder; - } - - public static FileInputBuilder builder() { - return new FileInputBuilder(); - } - - public File getFile() { - return this.builder.file; - } - - public String getFilePath() { - return this.builder.filePath; - } - - public static final class FileInputBuilder { - private File file; - private String filePath; - - private FileInputBuilder() { - // Default constructor - } - - public FileInputBuilder file(File file) { - this.file = file; - return this; - } - - public FileInputBuilder filePath(String filePath) { - this.filePath = filePath; - return this; - } - - public FileInput build() { - return new FileInput(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java b/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java deleted file mode 100644 index cebec9f2..00000000 --- a/src/main/java/com/skyflow/vault/detect/GetDetectRunRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.skyflow.vault.detect; - -public class GetDetectRunRequest { - private final String runId; - - private GetDetectRunRequest(GetDetectRunRequestBuilder builder) { - this.runId = builder.runId; - } - - public static GetDetectRunRequestBuilder builder() { - return new GetDetectRunRequestBuilder(); - } - - public String getRunId() { - return this.runId; - } - - public static final class GetDetectRunRequestBuilder { - private String runId; - - private GetDetectRunRequestBuilder() { - } - - public GetDetectRunRequestBuilder runId(String runId) { - this.runId = runId; - return this; - } - - public GetDetectRunRequest build() { - return new GetDetectRunRequest(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java b/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java deleted file mode 100644 index cc0e216a..00000000 --- a/src/main/java/com/skyflow/vault/detect/ReidentifyTextRequest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.skyflow.enums.DetectEntities; - -import java.util.List; - -public class ReidentifyTextRequest { - private final ReidentifyTextRequestBuilder builder; - - private ReidentifyTextRequest(ReidentifyTextRequestBuilder builder) { - this.builder = builder; - } - - public static ReidentifyTextRequestBuilder builder() { - return new ReidentifyTextRequestBuilder(); - } - - public String getText() { - return this.builder.text; - } - - public List getRedactedEntities() { - return this.builder.redactedEntities; - } - - public List getMaskedEntities() { - return this.builder.maskedEntities; - } - - public List getPlainTextEntities() { - return this.builder.plainTextEntities; - } - - public static final class ReidentifyTextRequestBuilder { - private String text; - private List redactedEntities; - private List maskedEntities; - private List plainTextEntities; - - private ReidentifyTextRequestBuilder() { - } - - public ReidentifyTextRequestBuilder text(String text) { - this.text = text; - return this; - } - - public ReidentifyTextRequestBuilder redactedEntities(List redactedEntities) { - this.redactedEntities = redactedEntities; - return this; - } - - public ReidentifyTextRequestBuilder maskedEntities(List maskedEntities) { - this.maskedEntities = maskedEntities; - return this; - } - - public ReidentifyTextRequestBuilder plainTextEntities(List plainTextEntities) { - this.plainTextEntities = plainTextEntities; - return this; - } - - public ReidentifyTextRequest build() { - return new ReidentifyTextRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java b/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java deleted file mode 100644 index 3a517968..00000000 --- a/src/main/java/com/skyflow/vault/detect/ReidentifyTextResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public class ReidentifyTextResponse { - private final String processedText; - - public ReidentifyTextResponse(String processedText) { - this.processedText = processedText; - } - - public String getProcessedText() { - return processedText; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - return gson.toJson(this); - } -} diff --git a/src/main/java/com/skyflow/vault/detect/TextIndex.java b/src/main/java/com/skyflow/vault/detect/TextIndex.java deleted file mode 100644 index 6fe99c1d..00000000 --- a/src/main/java/com/skyflow/vault/detect/TextIndex.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public class TextIndex { - private final Integer start; - private final Integer end; - - public TextIndex(Integer start, Integer end) { - this.start = start; - this.end = end; - } - - public int getStart() { - return start; - } - - public int getEnd() { - return end; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - return gson.toJson(this); - } -} diff --git a/src/main/java/com/skyflow/vault/detect/TokenFormat.java b/src/main/java/com/skyflow/vault/detect/TokenFormat.java deleted file mode 100644 index 8809d0a3..00000000 --- a/src/main/java/com/skyflow/vault/detect/TokenFormat.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.skyflow.vault.detect; - - -import com.skyflow.enums.DetectEntities; -import com.skyflow.enums.TokenType; - -import java.util.List; - - -public class TokenFormat { - private final TokenFormatBuilder builder; - - private TokenFormat(TokenFormatBuilder builder) { - this.builder = builder; - } - - public static TokenFormatBuilder builder() { - return new TokenFormatBuilder(); - } - - public TokenType getDefault() { - return this.builder.defaultType; - } - - public List getVaultToken() { - return this.builder.vaultToken; - } - - public List getEntityUniqueCounter() { - return this.builder.entityUniqueCounter; - } - - public List getEntityOnly() { - return this.builder.entityOnly; - } - - public static final class TokenFormatBuilder { - private TokenType defaultType; - private List vaultToken; - private List entityUniqueCounter; - private List entityOnly; - - private TokenFormatBuilder() { - this.defaultType = TokenType.ENTITY_UNIQUE_COUNTER; - } - - public TokenFormatBuilder defaultType(TokenType defaultType) { - this.defaultType = defaultType != null ? defaultType : TokenType.ENTITY_UNIQUE_COUNTER; - return this; - } - - public TokenFormatBuilder vaultToken(List vaultToken) { - this.vaultToken = vaultToken; - return this; - } - - public TokenFormatBuilder entityUniqueCounter(List entityUniqueCounter) { - this.entityUniqueCounter = entityUniqueCounter; - return this; - } - - public TokenFormatBuilder entityOnly(List entityOnly) { - this.entityOnly = entityOnly; - return this; - } - - public TokenFormat build() { - return new TokenFormat(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/detect/Transformations.java b/src/main/java/com/skyflow/vault/detect/Transformations.java deleted file mode 100644 index 2e219101..00000000 --- a/src/main/java/com/skyflow/vault/detect/Transformations.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.skyflow.vault.detect; - - -public class Transformations { - private final DateTransformation shiftDates; - - public Transformations(DateTransformation shiftDates) { - this.shiftDates = shiftDates; - } - - public DateTransformation getShiftDates() { - return shiftDates; - } -} diff --git a/src/main/java/com/skyflow/vault/tokens/ColumnValue.java b/src/main/java/com/skyflow/vault/tokens/ColumnValue.java deleted file mode 100644 index 3fa08b2e..00000000 --- a/src/main/java/com/skyflow/vault/tokens/ColumnValue.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.skyflow.vault.tokens; - -public class ColumnValue { - - private final ColumnValueBuilder builder; - - private ColumnValue(ColumnValueBuilder builder) { - this.builder = builder; - } - - public static ColumnValueBuilder builder() { - return new ColumnValueBuilder(); - } - - public String getValue() { - return this.builder.value; - } - - public String getColumnGroup() { - return this.builder.columnGroup; - } - - public static final class ColumnValueBuilder { - private String value; - private String columnGroup; - - private ColumnValueBuilder() { - } - - public ColumnValueBuilder value(String value) { - this.value = value; - return this; - } - - public ColumnValueBuilder columnGroup(String columnGroup) { - this.columnGroup = columnGroup; - return this; - } - - public ColumnValue build() { - return new ColumnValue(this); - } - } - -} diff --git a/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java b/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java deleted file mode 100644 index 33bba2b9..00000000 --- a/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.skyflow.vault.tokens; - -import com.skyflow.enums.RedactionType; - -public class DetokenizeData { - private final String token; - private final RedactionType redactionType; - - public DetokenizeData(String token) { - this.token = token; - this.redactionType = RedactionType.PLAIN_TEXT; - } - - public DetokenizeData(String token, RedactionType redactionType) { - this.token = token; - this.redactionType = redactionType == null ? RedactionType.PLAIN_TEXT : redactionType; - } - - public String getToken() { - return this.token; - } - - public RedactionType getRedactionType() { - return this.redactionType; - } -} diff --git a/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java b/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java deleted file mode 100644 index 7d2ae73c..00000000 --- a/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.skyflow.vault.tokens; - - -import com.skyflow.generated.rest.types.V1DetokenizeRecordResponse; - -public class DetokenizeRecordResponse { - private final String token; - private final String value; - private final String type; - private final String error; - private final String requestId; - - public DetokenizeRecordResponse(V1DetokenizeRecordResponse record) { - this(record, null); - } - - public DetokenizeRecordResponse(V1DetokenizeRecordResponse record, String requestId) { - this.token = record.getToken().orElse(null); - - this.value = record.getValue() - .filter(val -> val != null && !val.toString().isEmpty()) - .orElse(null); - - this.type = record.getValueType() - .map(Enum::toString) - .filter(val -> !"NONE".equals(val)) - .orElse(null); - - this.error = record.getError().orElse(null); - - this.requestId = requestId; - } - - - public String getError() { - return error; - } - - public String getToken() { - return token; - } - - public String getValue() { - return value; - } - - public String getType() { - return type; - } - - public String getRequestId() { - return requestId; - } -} \ No newline at end of file diff --git a/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java b/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java deleted file mode 100644 index 186a18d2..00000000 --- a/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.skyflow.vault.tokens; - -import java.util.ArrayList; - -public class DetokenizeRequest { - private final DetokenizeRequestBuilder builder; - - private DetokenizeRequest(DetokenizeRequestBuilder builder) { - this.builder = builder; - } - - public static DetokenizeRequestBuilder builder() { - return new DetokenizeRequestBuilder(); - } - - public ArrayList getDetokenizeData() { - return this.builder.detokenizeData; - } - - public Boolean getContinueOnError() { - return this.builder.continueOnError; - } - - public Boolean getDownloadURL() { - return this.builder.downloadURL; - } - - public static final class DetokenizeRequestBuilder { - private ArrayList detokenizeData; - private Boolean continueOnError; - private Boolean downloadURL; - - private DetokenizeRequestBuilder() { - this.continueOnError = false; - this.downloadURL = false; - } - - public DetokenizeRequestBuilder detokenizeData(ArrayList detokenizeData) { - this.detokenizeData = detokenizeData; - return this; - } - - public DetokenizeRequestBuilder continueOnError(Boolean continueOnError) { - this.continueOnError = continueOnError != null && continueOnError; - return this; - } - - public DetokenizeRequestBuilder downloadURL(Boolean downloadURL) { - this.downloadURL = downloadURL; - return this; - } - - public DetokenizeRequest build() { - return new DetokenizeRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java b/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java deleted file mode 100644 index 31ff64b2..00000000 --- a/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.skyflow.vault.tokens; - -import com.google.gson.Gson; - -import java.util.ArrayList; - -public class DetokenizeResponse { - private final ArrayList detokenizedFields; - private final ArrayList errors; - - public DetokenizeResponse(ArrayList detokenizedFields, ArrayList errors) { - this.detokenizedFields = detokenizedFields; - this.errors = errors; - } - - public ArrayList getDetokenizedFields() { - return detokenizedFields; - } - - public ArrayList getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java b/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java deleted file mode 100644 index a1a5ca33..00000000 --- a/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.skyflow.vault.tokens; - -import java.util.List; - -public class TokenizeRequest { - private final TokenizeRequestBuilder builder; - - private TokenizeRequest(TokenizeRequest.TokenizeRequestBuilder builder) { - this.builder = builder; - } - - public static TokenizeRequestBuilder builder() { - return new TokenizeRequestBuilder(); - } - - public List getColumnValues() { - return this.builder.columnValues; - } - - public static final class TokenizeRequestBuilder { - private List columnValues; - - private TokenizeRequestBuilder() { - } - - public TokenizeRequestBuilder values(List columnValues) { - this.columnValues = columnValues; - return this; - } - - public TokenizeRequest build() { - return new TokenizeRequest(this); - } - } -} diff --git a/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java b/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java deleted file mode 100644 index d8d8072b..00000000 --- a/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.skyflow.vault.tokens; - -import com.google.gson.*; - -import java.util.List; - -public class TokenizeResponse { - private final List tokens; - - public TokenizeResponse(List tokens) { - this.tokens = tokens; - } - - public List getTokens() { - return tokens; - } - - @Override - public String toString() { - Gson gson = new Gson(); - JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); - JsonArray tokensArray = responseObject.remove("tokens").getAsJsonArray(); - JsonArray newTokensArray = new JsonArray(); - for (JsonElement token : tokensArray) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("token", token.getAsString()); - newTokensArray.add(jsonObject); - } - responseObject.add("tokens", newTokensArray); - responseObject.add("errors", null); - return responseObject.toString(); - } -} diff --git a/v2/pom.xml b/v2/pom.xml index 8be437f7..788af67f 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -21,35 +21,10 @@ - com.skyflow.common + com.skyflow common 1.0.0 - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - - package - - shade - - - - - com.skyflow.common:common - - - - - - - - \ No newline at end of file diff --git a/v2/src/main/java/com/example/ConcurrentBatchProcessor.java b/v2/src/main/java/com/example/ConcurrentBatchProcessor.java new file mode 100644 index 00000000..1cc46d9f --- /dev/null +++ b/v2/src/main/java/com/example/ConcurrentBatchProcessor.java @@ -0,0 +1,120 @@ +package com.example; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; + +public class ConcurrentBatchProcessor { + + // A static executor to be shared by all methods in the class + private static ExecutorService executor; + + // --- Main Method to demonstrate the functionality --- + public static void main(String[] args) { + // Define the parameters for the batch processing + int totalRecords = 1000; // L: Total number of records to process + int batchSize = 50; // M: Size of each batch + int concurrencyLimit = 5; // N: Maximum number of concurrent calls + + // Create a list of dummy records (e.g., strings) + List allRecords = new ArrayList<>(); + for (int i = 1; i <= totalRecords; i++) { + allRecords.add("Record-" + i); + } + + System.out.println("Starting batch processing for " + allRecords.size() + " records."); + System.out.println("Batch Size (M): " + batchSize); + System.out.println("Concurrency Limit (N): " + concurrencyLimit); + + try { + processRecordsInBatches(allRecords, batchSize, concurrencyLimit); + } catch (InterruptedException | ExecutionException e) { + System.err.println("Processing failed due to an exception: " + e.getMessage()); + e.printStackTrace(); + } + System.out.println("All batches have been processed."); + } + + // --- Core logic for concurrent batch processing --- + + /** + * Chunks a list of records and processes each batch concurrently. + * + * @param records The list of all records (L) to be processed. + * @param batchSize The number of records in each batch (M). + * @param concurrencyLimit The maximum number of concurrent calls (N). + * @throws InterruptedException if the thread is interrupted while waiting. + * @throws ExecutionException if a task failed to complete. + */ + public static void processRecordsInBatches(List records, int batchSize, int concurrencyLimit) + throws InterruptedException, ExecutionException { + + // Initialize the shared fixed-size thread pool + executor = Executors.newFixedThreadPool(concurrencyLimit); + + // List to hold all the futures for each batch + List> futures = new ArrayList<>(); + + // Loop through the records to create batches +// 1st itr -> i=0 bs=10 ei=10 +// 2nd itr -> i=10 bs=10 ei=20 + + int counter = 0; + for (int i = 0; i < records.size(); i += batchSize) { + int endIndex = Math.min(i + batchSize, records.size()); + List batch = records.subList(i, endIndex); + int batchId = counter + 1; + + // Submit the batch processing task using CompletableFuture.supplyAsync() + // This is where we create the CompletableFuture and pass the executor. + + CompletableFuture future = CompletableFuture + .supplyAsync(() -> performApiCall(batch, batchId), executor) + .whenComplete((resp, ex) -> System.out.printf("Batch %d End Time:\t%s for thread %s\n", batchId, System.currentTimeMillis(), Thread.currentThread().getName()) + ); + futures.add(future); + counter++; + } + + // Wait for all submitted tasks to complete. + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + + // Optional: Process the results if needed. + System.out.println("All batches completed. Here are the results:"); + for (CompletableFuture future : futures) { + // get() blocks until the future is complete. + System.out.println(future.get()); + } + + // Shut down the executor gracefully + executor.shutdown(); + if (!executor.awaitTermination(60, TimeUnit.SECONDS)) { + System.err.println("Executor did not terminate in the specified time."); + } + } + + // --- Placeholder method to simulate a synchronous API call --- + + /** + * Simulates a synchronous, blocking API call with a batch of records. + * This method does not return a CompletableFuture and doesn't need to know about the executor. + * + * @param batch The list of records for a single API call. + * @return A success message string. + */ + private static String performApiCall(List batch, int batchId) { + // Simulate a network call delay + try { + System.out.printf("Batch %d Start Time:\t%s for thread %s\n", batchId, System.currentTimeMillis(), Thread.currentThread().getName()); + long processingTime = (long) (Math.random() * 2000) + 500; // 0.5 to 2.5 seconds + Thread.sleep(processingTime); + String result = "Successfully processed batch of " + batch.size() + + " records, starting with " + batch.get(0) + + " (simulated duration: " + processingTime + "ms)"; + return result; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new IllegalStateException("API call was interrupted.", e); + } + } +} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/ConnectionClient.java b/v2/src/main/java/com/skyflow/ConnectionClient.java index 8da10c12..d3b20c3d 100644 --- a/v2/src/main/java/com/skyflow/ConnectionClient.java +++ b/v2/src/main/java/com/skyflow/ConnectionClient.java @@ -1,6 +1,6 @@ package com.skyflow; -import com.skyflow.common.serviceaccount.util.Token; +import com.skyflow.serviceaccount.util.Token; import com.skyflow.config.ConnectionConfig; import com.skyflow.config.Credentials; import com.skyflow.errors.ErrorCode; @@ -40,7 +40,7 @@ protected void updateConnectionConfig(ConnectionConfig connectionConfig) throws prioritiseCredentials(); } - protected void setBearerToken() throws SkyflowException, com.skyflow.common.errors.SkyflowException { + protected void setBearerToken() throws SkyflowException, com.skyflow.errors.SkyflowException { prioritiseCredentials(); Validations.validateCredentials(this.finalCredentials); if (this.finalCredentials.getApiKey() != null) { diff --git a/v2/src/main/java/com/skyflow/VaultClient.java b/v2/src/main/java/com/skyflow/VaultClient.java index 5a4c17b1..7854a81b 100644 --- a/v2/src/main/java/com/skyflow/VaultClient.java +++ b/v2/src/main/java/com/skyflow/VaultClient.java @@ -1,6 +1,5 @@ package com.skyflow; -import com.skyflow.common.serviceaccount.util.Token; import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; import com.skyflow.enums.DetectEntities; @@ -25,18 +24,19 @@ import com.skyflow.generated.rest.resources.tokens.TokensClient; import com.skyflow.generated.rest.resources.tokens.requests.V1DetokenizePayload; import com.skyflow.generated.rest.resources.tokens.requests.V1TokenizePayload; -import com.skyflow.generated.rest.types.*; import com.skyflow.generated.rest.types.Transformations; +import com.skyflow.generated.rest.types.*; import com.skyflow.logs.InfoLogs; +import com.skyflow.serviceaccount.util.Token; import com.skyflow.utils.Constants; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; import com.skyflow.vault.data.InsertRequest; import com.skyflow.vault.data.UpdateRequest; -import com.skyflow.vault.detect.*; import com.skyflow.vault.detect.DeidentifyFileRequest; import com.skyflow.vault.detect.DeidentifyTextRequest; +import com.skyflow.vault.detect.*; import com.skyflow.vault.tokens.ColumnValue; import com.skyflow.vault.tokens.DetokenizeData; import com.skyflow.vault.tokens.DetokenizeRequest; @@ -78,7 +78,7 @@ protected StringsClient getDetectTextApi() { return this.apiClient.strings(); } - protected FilesClient getDetectFileAPi(){ + protected FilesClient getDetectFileAPi() { return this.apiClient.files(); } @@ -214,14 +214,10 @@ protected void setBearerToken() throws SkyflowException { Validations.validateCredentials(this.finalCredentials); if (this.finalCredentials.getApiKey() != null) { LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); - token=this.finalCredentials.getApiKey(); + token = this.finalCredentials.getApiKey(); } else if (Token.isExpired(token)) { LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); - try { - token = Utils.generateBearerToken(this.finalCredentials); - } catch (com.skyflow.common.errors.SkyflowException e) { - throw new RuntimeException(e); - } + token = Utils.generateBearerToken(this.finalCredentials); } else { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); } @@ -391,7 +387,7 @@ private Transformations getTransformations(com.skyflow.vault.detect.Transformati .build(); } - private List getEntityTypes(List entities){ + private List getEntityTypes(List entities) { List mappedEntityTypes = null; if (entities != null) { mappedEntityTypes = entities.stream() @@ -402,7 +398,7 @@ private List getEntityTypes(List entities){ return mappedEntityTypes; } - protected com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest getDeidentifyTextFileRequest(DeidentifyFileRequest request, String vaultId, String base64Content){ + protected com.skyflow.generated.rest.resources.files.requests.DeidentifyTextRequest getDeidentifyTextFileRequest(DeidentifyFileRequest request, String vaultId, String base64Content) { List mappedEntityTypes = getEntityTypes(request.getEntities()); TokenFormat tokenFormat = request.getTokenFormat(); diff --git a/v2/src/main/java/com/skyflow/config/Credentials.java b/v2/src/main/java/com/skyflow/config/Credentials.java deleted file mode 100644 index f1865dc7..00000000 --- a/v2/src/main/java/com/skyflow/config/Credentials.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.skyflow.config; - -import java.util.ArrayList; - -public class Credentials { - private String path; - private ArrayList roles; - private String context; - private String credentialsString; - private String token; - private String apiKey; - - public Credentials() { - this.path = null; - this.context = null; - this.credentialsString = null; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public ArrayList getRoles() { - return roles; - } - - public void setRoles(ArrayList roles) { - this.roles = roles; - } - - public String getContext() { - return context; - } - - public void setContext(String context) { - this.context = context; - } - - public String getCredentialsString() { - return credentialsString; - } - - public void setCredentialsString(String credentialsString) { - this.credentialsString = credentialsString; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } -} diff --git a/v2/src/main/java/com/skyflow/config/ManagementConfig.java b/v2/src/main/java/com/skyflow/config/ManagementConfig.java deleted file mode 100644 index a054c8ea..00000000 --- a/v2/src/main/java/com/skyflow/config/ManagementConfig.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.skyflow.config; - -public class ManagementConfig { - // members - - // constructor - ManagementConfig() { - } - - // getters and setters -} diff --git a/v2/src/main/java/com/skyflow/config/VaultConfig.java b/v2/src/main/java/com/skyflow/config/VaultConfig.java deleted file mode 100644 index 4f61af2a..00000000 --- a/v2/src/main/java/com/skyflow/config/VaultConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.skyflow.config; - -import com.skyflow.enums.Env; - -public class VaultConfig { - private String vaultId; - private String clusterId; - private Env env; - private Credentials credentials; - - public VaultConfig() { - this.vaultId = null; - this.clusterId = null; - this.env = Env.PROD; - this.credentials = null; - } - - public String getVaultId() { - return vaultId; - } - - public void setVaultId(String vaultId) { - this.vaultId = vaultId; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public Env getEnv() { - return env; - } - - public void setEnv(Env env) { - this.env = env == null ? Env.PROD : env; - } - - public Credentials getCredentials() { - return credentials; - } - - public void setCredentials(Credentials credentials) { - this.credentials = credentials; - } -} diff --git a/v2/src/main/java/com/skyflow/enums/Env.java b/v2/src/main/java/com/skyflow/enums/Env.java deleted file mode 100644 index 3d1466e9..00000000 --- a/v2/src/main/java/com/skyflow/enums/Env.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.skyflow.enums; - -public enum Env { - DEV, - STAGE, - SANDBOX, - PROD -} diff --git a/v2/src/main/java/com/skyflow/enums/InterfaceName.java b/v2/src/main/java/com/skyflow/enums/InterfaceName.java deleted file mode 100644 index 98992f21..00000000 --- a/v2/src/main/java/com/skyflow/enums/InterfaceName.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.skyflow.enums; - -public enum InterfaceName { - INSERT("insert"), - DETOKENIZE("detokenize"), - GET("get"), - UPDATE("update"), - DELETE("delete"), - QUERY("query"), - TOKENIZE("tokenize"), - FILE_UPLOAD("file upload"), - DETECT("detect"), - INVOKE_CONNECTION("invoke connection"); - - private final String interfaceName; - - InterfaceName(String interfaceName) { - this.interfaceName = interfaceName; - } - - public String getName() { - return interfaceName; - } -} diff --git a/v2/src/main/java/com/skyflow/enums/LogLevel.java b/v2/src/main/java/com/skyflow/enums/LogLevel.java deleted file mode 100644 index a605b520..00000000 --- a/v2/src/main/java/com/skyflow/enums/LogLevel.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.skyflow.enums; - -public enum LogLevel { - OFF, - ERROR, - WARN, - INFO, - DEBUG -} diff --git a/v2/src/main/java/com/skyflow/errors/ErrorCode.java b/v2/src/main/java/com/skyflow/errors/ErrorCode.java deleted file mode 100644 index 943913c6..00000000 --- a/v2/src/main/java/com/skyflow/errors/ErrorCode.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.skyflow.errors; - -public enum ErrorCode { - INVALID_INPUT(400), - INVALID_INDEX(404), - SERVER_ERROR(500), - PARTIAL_SUCCESS(500); - - private final int code; - - ErrorCode(int code) { - this.code = code; - } - - public int getCode() { - return code; - } -} diff --git a/v2/src/main/java/com/skyflow/errors/SkyflowException.java b/v2/src/main/java/com/skyflow/errors/SkyflowException.java deleted file mode 100644 index 32c71f39..00000000 --- a/v2/src/main/java/com/skyflow/errors/SkyflowException.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.skyflow.errors; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.skyflow.utils.Constants; - -import java.util.List; -import java.util.Map; - -public class SkyflowException extends Exception { - private String requestId; - private Integer grpcCode; - private Integer httpCode; - private String message; - private String httpStatus; - private JsonArray details; - private JsonObject responseBody; - - public SkyflowException(String message) { - super(message); - this.message = message; - } - - public SkyflowException(Throwable cause) { - super(cause); - this.message = cause.getMessage(); - } - - public SkyflowException(String message, Throwable cause) { - super(message, cause); - this.message = message; - } - - public SkyflowException(int code, String message) { - super(message); - this.httpCode = code; - this.message = message; - this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); - this.details = new JsonArray(); - } - - public SkyflowException(int httpCode, Throwable cause, Map> responseHeaders, String responseBody) { - super(cause); - this.httpCode = httpCode > 0 ? httpCode : 400; - try { - setRequestId(responseHeaders); - setResponseBody(responseBody, responseHeaders); - } catch (Exception e) { - this.httpStatus = HttpStatus.BAD_REQUEST.getHttpStatus(); - String fullMessage = responseBody != null ? responseBody : - (cause.getLocalizedMessage() != null ? cause.getMessage() : ErrorMessage.ErrorOccurred.getMessage()); - this.message = fullMessage.split("HTTP response code:")[0].trim(); - } - } - - private void setResponseBody(String responseBody, Map> responseHeaders) { - this.responseBody = JsonParser.parseString(responseBody).getAsJsonObject(); - if (this.responseBody.get("error") != null) { - setGrpcCode(); - setHttpStatus(); - setMessage(); - setDetails(responseHeaders); - } - } - - public String getRequestId() { - return requestId; - } - - private void setRequestId(Map> responseHeaders) { - List ids = responseHeaders.get(Constants.REQUEST_ID_HEADER_KEY); - this.requestId = ids == null ? null : ids.get(0); - } - - private void setMessage() { - JsonElement messageElement = ((JsonObject) responseBody.get("error")).get("message"); - this.message = messageElement == null ? null : messageElement.getAsString(); - } - - private void setGrpcCode() { - JsonElement grpcElement = ((JsonObject) responseBody.get("error")).get("grpc_code"); - this.grpcCode = grpcElement == null ? null : grpcElement.getAsInt(); - } - - private void setHttpStatus() { - JsonElement statusElement = ((JsonObject) responseBody.get("error")).get("http_status"); - this.httpStatus = statusElement == null ? null : statusElement.getAsString(); - } - - public int getHttpCode() { - return httpCode; - } - - public JsonArray getDetails() { - return details; - } - - private void setDetails(Map> responseHeaders) { - JsonElement detailsElement = ((JsonObject) responseBody.get("error")).get("details"); - List errorFromClientHeader = responseHeaders.get(Constants.ERROR_FROM_CLIENT_HEADER_KEY); - if (detailsElement != null) { - this.details = detailsElement.getAsJsonArray(); - } - if (errorFromClientHeader != null) { - this.details = this.details == null ? new JsonArray() : this.details; - String errorFromClient = errorFromClientHeader.get(0); - JsonObject detailObject = new JsonObject(); - detailObject.addProperty("errorFromClient", errorFromClient); - this.details.add(detailObject); - } - } - - public Integer getGrpcCode() { - return grpcCode; - } - - public String getHttpStatus() { - return httpStatus; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public String toString() { - return String.format( - "%n requestId: %s%n grpcCode: %s%n httpCode: %s%n httpStatus: %s%n message: %s%n details: %s", - this.requestId, this.grpcCode, this.httpCode, this.httpStatus, this.message, this.details - ); - } -} diff --git a/v2/src/main/java/com/skyflow/utils/Constants.java b/v2/src/main/java/com/skyflow/utils/Constants.java index f2f1fff8..c0f2a778 100644 --- a/v2/src/main/java/com/skyflow/utils/Constants.java +++ b/v2/src/main/java/com/skyflow/utils/Constants.java @@ -1,31 +1,9 @@ package com.skyflow.utils; -public final class Constants { - public static final String SECURE_PROTOCOL = "https://"; - public static final String DEV_DOMAIN = ".vault.skyflowapis.dev"; - public static final String STAGE_DOMAIN = ".vault.skyflowapis.tech"; - public static final String SANDBOX_DOMAIN = ".vault.skyflowapis-preview.com"; - public static final String PROD_DOMAIN = ".vault.skyflowapis.com"; - public static final String PKCS8_PRIVATE_HEADER = "-----BEGIN PRIVATE KEY-----"; - public static final String PKCS8_PRIVATE_FOOTER = "-----END PRIVATE KEY-----"; - public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; - public static final String SIGNED_DATA_TOKEN_PREFIX = "signed_token_"; - public static final String ORDER_ASCENDING = "ASCENDING"; - public static final String API_KEY_REGEX = "^sky-[a-zA-Z0-9]{5}-[a-fA-F0-9]{32}$"; - public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; +public final class Constants extends BaseConstants { public static final String SDK_NAME = "Skyflow Java SDK "; - public static final String SDK_VERSION = "v2"; + public static final String SDK_VERSION = "2.0.0-beta.2"; public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; - public static final String SDK_METRIC_NAME_VERSION = "sdk_name_version"; - public static final String SDK_METRIC_NAME_VERSION_PREFIX = "skyflow-java@"; - public static final String SDK_METRIC_CLIENT_DEVICE_MODEL = "sdk_client_device_model"; - public static final String SDK_METRIC_CLIENT_OS_DETAILS = "sdk_client_os_details"; - public static final String SDK_METRIC_RUNTIME_DETAILS = "sdk_runtime_details"; - public static final String SDK_METRIC_RUNTIME_DETAILS_PREFIX = "Java@"; - public static final String SDK_AUTH_HEADER_KEY = "x-skyflow-authorization"; - 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"; } diff --git a/v2/src/main/java/com/skyflow/utils/Utils.java b/v2/src/main/java/com/skyflow/utils/Utils.java index baaf3a51..d1b574a0 100644 --- a/v2/src/main/java/com/skyflow/utils/Utils.java +++ b/v2/src/main/java/com/skyflow/utils/Utils.java @@ -1,105 +1,15 @@ package com.skyflow.utils; import com.google.gson.JsonObject; -import com.skyflow.common.serviceaccount.util.BearerToken; import com.skyflow.config.ConnectionConfig; -import com.skyflow.config.Credentials; -import com.skyflow.enums.Env; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; -import com.skyflow.errors.SkyflowException; -import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; import com.skyflow.utils.logger.LogUtil; import com.skyflow.vault.connection.InvokeConnectionRequest; -import org.apache.commons.codec.binary.Base64; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; import java.util.HashMap; import java.util.Map; -public final class Utils { - public static String getVaultURL(String clusterId, Env env) { - StringBuilder sb = new StringBuilder(Constants.SECURE_PROTOCOL); - sb.append(clusterId); - switch (env) { - case DEV: - sb.append(Constants.DEV_DOMAIN); - break; - case STAGE: - sb.append(Constants.STAGE_DOMAIN); - break; - case SANDBOX: - sb.append(Constants.SANDBOX_DOMAIN); - break; - case PROD: - default: - sb.append(Constants.PROD_DOMAIN); - break; - } - return sb.toString(); - } - - public static String generateBearerToken(Credentials credentials) throws com.skyflow.common.errors.SkyflowException { - if (credentials.getPath() != null) { - return BearerToken.builder() - .setCredentials(new File(credentials.getPath())) - .setRoles(credentials.getRoles()) - .setCtx(credentials.getContext()) - .build() - .getBearerToken(); - } else if (credentials.getCredentialsString() != null) { - return BearerToken.builder() - .setCredentials(credentials.getCredentialsString()) - .setRoles(credentials.getRoles()) - .setCtx(credentials.getContext()) - .build() - .getBearerToken(); - } else { - return credentials.getToken(); - } - } - - public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException { - String PKCS8PrivateHeader = Constants.PKCS8_PRIVATE_HEADER; - String PKCS8PrivateFooter = Constants.PKCS8_PRIVATE_FOOTER; - - String privateKeyContent = pemKey; - PrivateKey privateKey = null; - - if (pemKey.contains(PKCS8PrivateHeader)) { - privateKeyContent = privateKeyContent.replace(PKCS8PrivateHeader, ""); - privateKeyContent = privateKeyContent.replace(PKCS8PrivateFooter, ""); - privateKeyContent = privateKeyContent.replace("\n", ""); - privateKeyContent = privateKeyContent.replace("\r\n", ""); - privateKey = parsePkcs8PrivateKey(Base64.decodeBase64(privateKeyContent)); - } else { - LogUtil.printErrorLog(ErrorLogs.JWT_INVALID_FORMAT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.JwtInvalidFormat.getMessage()); - } - return privateKey; - } - - public static String getBaseURL(String url) throws MalformedURLException { - URL parsedUrl = new URL(url); - String protocol = parsedUrl.getProtocol(); - String host = parsedUrl.getHost(); - return String.format("%s://%s", protocol, host); - } - - public static String parameterizedString(String base, String... args) { - for (int index = 0; index < args.length; index++) { - base = base.replace("%s" + (index + 1), args[index]); - } - return base; - } +public final class Utils extends BaseUtils { public static String constructConnectionURL(ConnectionConfig config, InvokeConnectionRequest invokeConnectionRequest) { StringBuilder filledURL = new StringBuilder(config.getConnectionUrl()); @@ -182,21 +92,4 @@ public static JsonObject getMetrics() { details.addProperty(Constants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); return details; } - - private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws SkyflowException { - KeyFactory keyFactory; - PrivateKey privateKey = null; - try { - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8Bytes); - keyFactory = KeyFactory.getInstance("RSA"); - privateKey = keyFactory.generatePrivate(keySpec); - } catch (NoSuchAlgorithmException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_ALGORITHM.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidAlgorithm.getMessage()); - } catch (InvalidKeySpecException e) { - LogUtil.printErrorLog(ErrorLogs.INVALID_KEY_SPEC.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidKeySpec.getMessage()); - } - return privateKey; - } } diff --git a/v2/src/main/java/com/skyflow/utils/validations/Validations.java b/v2/src/main/java/com/skyflow/utils/validations/Validations.java index 841c03b6..ccc1790d 100644 --- a/v2/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/v2/src/main/java/com/skyflow/utils/validations/Validations.java @@ -3,8 +3,6 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import com.skyflow.config.ConnectionConfig; -import com.skyflow.config.Credentials; -import com.skyflow.config.VaultConfig; import com.skyflow.enums.InterfaceName; import com.skyflow.enums.RedactionType; import com.skyflow.enums.TokenMode; @@ -12,12 +10,14 @@ import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; -import com.skyflow.utils.Constants; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.vault.connection.InvokeConnectionRequest; import com.skyflow.vault.data.*; -import com.skyflow.vault.detect.*; +import com.skyflow.vault.detect.DeidentifyFileRequest; +import com.skyflow.vault.detect.DeidentifyTextRequest; +import com.skyflow.vault.detect.GetDetectRunRequest; +import com.skyflow.vault.detect.ReidentifyTextRequest; import com.skyflow.vault.tokens.ColumnValue; import com.skyflow.vault.tokens.DetokenizeData; import com.skyflow.vault.tokens.DetokenizeRequest; @@ -29,32 +29,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -public class Validations { +public class Validations extends BaseValidations { private Validations() { - } - - public static void validateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - String vaultId = vaultConfig.getVaultId(); - String clusterId = vaultConfig.getClusterId(); - Credentials credentials = vaultConfig.getCredentials(); - if (vaultId == null) { - LogUtil.printErrorLog(ErrorLogs.VAULT_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidVaultId.getMessage()); - } else if (vaultId.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_VAULT_ID.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyVaultId.getMessage()); - } else if (clusterId == null) { - LogUtil.printErrorLog(ErrorLogs.CLUSTER_ID_IS_REQUIRED.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidClusterId.getMessage()); - } else if (clusterId.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CLUSTER_ID.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyClusterId.getMessage()); - } else if (credentials != null) { - validateCredentials(credentials); - } + super(); } public static void validateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { @@ -147,73 +125,6 @@ public static void validateInvokeConnectionRequest(InvokeConnectionRequest invok } } - public static void validateCredentials(Credentials credentials) throws SkyflowException { - int nonNullMembers = 0; - String path = credentials.getPath(); - String credentialsString = credentials.getCredentialsString(); - String token = credentials.getToken(); - String apiKey = credentials.getApiKey(); - String context = credentials.getContext(); - ArrayList roles = credentials.getRoles(); - - if (path != null) nonNullMembers++; - if (credentialsString != null) nonNullMembers++; - if (token != null) nonNullMembers++; - if (apiKey != null) nonNullMembers++; - - if (nonNullMembers > 1) { - LogUtil.printErrorLog(ErrorLogs.MULTIPLE_TOKEN_GENERATION_MEANS_PASSED.getLog()); - throw new SkyflowException( - ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.MultipleTokenGenerationMeansPassed.getMessage() - ); - } else if (nonNullMembers < 1) { - LogUtil.printErrorLog(ErrorLogs.NO_TOKEN_GENERATION_MEANS_PASSED.getLog()); - throw new SkyflowException( - ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NoTokenGenerationMeansPassed.getMessage() - ); - } else if (path != null && path.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_PATH.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialFilePath.getMessage()); - } else if (credentialsString != null && credentialsString.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_CREDENTIALS_STRING.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyCredentialsString.getMessage()); - } else if (token != null && token.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_TOKEN_VALUE.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyToken.getMessage()); - } else if (apiKey != null) { - if (apiKey.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_API_KEY_VALUE.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyApikey.getMessage()); - } else { - Pattern pattern = Pattern.compile(Constants.API_KEY_REGEX); - Matcher matcher = pattern.matcher(apiKey); - if (!matcher.matches()) { - LogUtil.printErrorLog(ErrorLogs.INVALID_API_KEY.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidApikey.getMessage()); - } - } - } else if (roles != null) { - if (roles.isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_ROLES.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoles.getMessage()); - } else { - for (int index = 0; index < roles.size(); index++) { - String role = roles.get(index); - if (role == null || role.trim().isEmpty()) { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.EMPTY_OR_NULL_ROLE_IN_ROLES.getLog(), Integer.toString(index) - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRoleInRoles.getMessage()); - } - } - } - } - if (context != null && context.trim().isEmpty()) { - LogUtil.printErrorLog(ErrorLogs.EMPTY_OR_NULL_CONTEXT.getLog()); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyContext.getMessage()); - } - } - public static void validateDetokenizeRequest(DetokenizeRequest detokenizeRequest) throws SkyflowException { ArrayList detokenizeData = detokenizeRequest.getDetokenizeData(); if (detokenizeData == null) { @@ -802,7 +713,7 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.BothFileAndFilePathProvided.getMessage()); } - if (filePath != null && filePath.trim().isEmpty()){ + if (filePath != null && filePath.trim().isEmpty()) { throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidFilePath.getMessage()); } @@ -838,7 +749,7 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) if (request.getBleep() != null) { if (request.getBleep().getFrequency() == null || request.getBleep().getFrequency() <= 0) { LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_BLEEP_TO_DEIDENTIFY_AUDIO.getLog(), InterfaceName.DETECT.getName() + ErrorLogs.INVALID_BLEEP_TO_DEIDENTIFY_AUDIO.getLog(), InterfaceName.DETECT.getName() )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidRequestBody.getMessage()); } @@ -858,13 +769,13 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) File outDir = new File(request.getOutputDirectory()); if (!outDir.exists() || !outDir.isDirectory()) { LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.OUTPUT_DIRECTORY_NOT_FOUND.getLog(), InterfaceName.DETECT.getName() + ErrorLogs.OUTPUT_DIRECTORY_NOT_FOUND.getLog(), InterfaceName.DETECT.getName() )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.OutputDirectoryNotFound.getMessage()); } if (!outDir.canWrite()) { LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY.getLog(), InterfaceName.DETECT.getName() + ErrorLogs.INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY.getLog(), InterfaceName.DETECT.getName() )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidPermission.getMessage()); } @@ -874,7 +785,7 @@ public static void validateDeidentifyFileRequest(DeidentifyFileRequest request) if (request.getWaitTime() != null && request.getWaitTime() <= 0) { throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidWaitTime.getMessage()); } - if(request.getWaitTime() > 64) { + if (request.getWaitTime() > 64) { throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.WaitTimeExceedsLimit.getMessage()); } } diff --git a/v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java b/v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java deleted file mode 100644 index b6c26b6d..00000000 --- a/v2/src/main/java/com/skyflow/vault/audit/ListEventRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.skyflow.vault.audit; - -public class ListEventRequest { - // members - - // constructor - public ListEventRequest() { - } - - // getters ans setters -} diff --git a/v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java b/v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java deleted file mode 100644 index 2647e617..00000000 --- a/v2/src/main/java/com/skyflow/vault/audit/ListEventResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.skyflow.vault.audit; - -public class ListEventResponse { - // members - - public ListEventResponse() { - } - - // getters ans setters -} diff --git a/v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java b/v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java deleted file mode 100644 index d059245f..00000000 --- a/v2/src/main/java/com/skyflow/vault/bin/GetBinRequest.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.skyflow.vault.bin; - -public class GetBinRequest { - // members - - public GetBinRequest() { - } - - // getters ans setters -} diff --git a/v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java b/v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java deleted file mode 100644 index 86210031..00000000 --- a/v2/src/main/java/com/skyflow/vault/bin/GetBinResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.skyflow.vault.bin; - -public class GetBinResponse { - // members - - public GetBinResponse() { - } - - // getters ans setters -} diff --git a/v2/src/main/java/com/skyflow/vault/controller/AuditController.java b/v2/src/main/java/com/skyflow/vault/controller/AuditController.java deleted file mode 100644 index 2faa04a6..00000000 --- a/v2/src/main/java/com/skyflow/vault/controller/AuditController.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.skyflow.vault.controller; - -import com.skyflow.generated.rest.ApiClient; -import com.skyflow.vault.audit.ListEventRequest; -import com.skyflow.vault.audit.ListEventResponse; - -public class AuditController { - - public AuditController(ApiClient apiClient) { - - } - - // Check for correct return type in python interfaces - public ListEventResponse list(ListEventRequest listEventRequest) { - // return audit events - return null; - } -} diff --git a/v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java b/v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java deleted file mode 100644 index 4eb7a1c8..00000000 --- a/v2/src/main/java/com/skyflow/vault/controller/BinLookupController.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.skyflow.vault.controller; - -import com.skyflow.generated.rest.ApiClient; -import com.skyflow.vault.bin.GetBinRequest; -import com.skyflow.vault.bin.GetBinResponse; - -public class BinLookupController { - - public BinLookupController(ApiClient apiClient) { - } - - public GetBinResponse get(GetBinRequest getBinRequest) { - // return bin lookup response (card metadata associated with BIN) - return null; - } -} diff --git a/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java b/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java index e75a3b7e..68a39751 100644 --- a/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java +++ b/v2/src/main/java/com/skyflow/vault/controller/ConnectionController.java @@ -72,8 +72,6 @@ public InvokeConnectionResponse invoke(InvokeConnectionRequest invokeConnectionR } catch (IOException e) { LogUtil.printErrorLog(ErrorLogs.INVOKE_CONNECTION_REQUEST_REJECTED.getLog()); throw new SkyflowException(e.getMessage(), e); - } catch (com.skyflow.common.errors.SkyflowException e) { - throw new RuntimeException(e); } return connectionResponse; } diff --git a/v2/src/main/java/com/skyflow/vault/controller/DetectController.java b/v2/src/main/java/com/skyflow/vault/controller/DetectController.java index 7752efd0..c16c167b 100644 --- a/v2/src/main/java/com/skyflow/vault/controller/DetectController.java +++ b/v2/src/main/java/com/skyflow/vault/controller/DetectController.java @@ -139,7 +139,7 @@ public DeidentifyFileResponse deidentifyFile(DeidentifyFileRequest request) thro try { Files.write(outputFile.toPath(), decodedBytes); } catch (IOException ioe) { - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedtoSaveProcessedFile.getMessage()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.FailedToSaveProcessedFile.getMessage()); } } diff --git a/src/test/java/com/skyflow/ConnectionClientTests.java b/v2/test/java/com/skyflow/ConnectionClientTests.java similarity index 100% rename from src/test/java/com/skyflow/ConnectionClientTests.java rename to v2/test/java/com/skyflow/ConnectionClientTests.java diff --git a/src/test/java/com/skyflow/SkyflowTests.java b/v2/test/java/com/skyflow/SkyflowTests.java similarity index 100% rename from src/test/java/com/skyflow/SkyflowTests.java rename to v2/test/java/com/skyflow/SkyflowTests.java diff --git a/src/test/java/com/skyflow/VaultClientTests.java b/v2/test/java/com/skyflow/VaultClientTests.java similarity index 99% rename from src/test/java/com/skyflow/VaultClientTests.java rename to v2/test/java/com/skyflow/VaultClientTests.java index 1ebb1b23..3309c82c 100644 --- a/src/test/java/com/skyflow/VaultClientTests.java +++ b/v2/test/java/com/skyflow/VaultClientTests.java @@ -345,6 +345,7 @@ public void testSetBearerTokenWithEnvCredentials() { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), 400); Assert.assertNull(vaultClient.getVaultConfig().getCredentials()); } catch (Exception e) { + e.printStackTrace(); Assert.fail(INVALID_EXCEPTION_THROWN); } } diff --git a/src/test/java/com/skyflow/config/ConnectionConfigTests.java b/v2/test/java/com/skyflow/config/ConnectionConfigTests.java similarity index 100% rename from src/test/java/com/skyflow/config/ConnectionConfigTests.java rename to v2/test/java/com/skyflow/config/ConnectionConfigTests.java diff --git a/src/test/java/com/skyflow/utils/HttpUtilityTests.java b/v2/test/java/com/skyflow/utils/HttpUtilityTests.java similarity index 100% rename from src/test/java/com/skyflow/utils/HttpUtilityTests.java rename to v2/test/java/com/skyflow/utils/HttpUtilityTests.java diff --git a/src/test/java/com/skyflow/utils/UtilsTests.java b/v2/test/java/com/skyflow/utils/UtilsTests.java similarity index 83% rename from src/test/java/com/skyflow/utils/UtilsTests.java rename to v2/test/java/com/skyflow/utils/UtilsTests.java index 83e5a6ff..c9f39c90 100644 --- a/src/test/java/com/skyflow/utils/UtilsTests.java +++ b/v2/test/java/com/skyflow/utils/UtilsTests.java @@ -52,44 +52,18 @@ public static void setup() { } @Test - public void testGetVaultURLForDev() { + public void testGetVaultURLForDifferentENVs() { try { - String vaultURL = Utils.getVaultURL(clusterId, Env.DEV); - String devUrl = "https://test_cluster_id.vault.skyflowapis.dev"; - Assert.assertEquals(devUrl, vaultURL); - } catch (Exception e) { - Assert.fail(INVALID_EXCEPTION_THROWN); - } - } - - @Test - public void testGetVaultURLForStage() { - try { - String vaultURL = Utils.getVaultURL(clusterId, Env.STAGE); - String stageUrl = "https://test_cluster_id.vault.skyflowapis.tech"; - Assert.assertEquals(stageUrl, vaultURL); - } catch (Exception e) { - Assert.fail(INVALID_EXCEPTION_THROWN); - } - } - - @Test - public void testGetVaultURLForSandbox() { - try { - String vaultURL = Utils.getVaultURL(clusterId, Env.SANDBOX); - String sandboxUrl = "https://test_cluster_id.vault.skyflowapis-preview.com"; - Assert.assertEquals(sandboxUrl, vaultURL); - } catch (Exception e) { - Assert.fail(INVALID_EXCEPTION_THROWN); - } - } - - @Test - public void testGetVaultURLForProd() { - try { - String vaultURL = Utils.getVaultURL(clusterId, Env.PROD); - String prodUrl = "https://test_cluster_id.vault.skyflowapis.com"; - Assert.assertEquals(prodUrl, vaultURL); + Map map = new HashMap<>(); + map.put(Env.DEV, "https://test_cluster_id.vault.skyflowapis.dev"); + map.put(Env.STAGE, "https://test_cluster_id.vault.skyflowapis.tech"); + map.put(Env.SANDBOX, "https://test_cluster_id.vault.skyflowapis-preview.com"); + map.put(Env.PROD, "https://test_cluster_id.vault.skyflowapis.com"); + + for (Env env : map.keySet()) { + String vaultURL = Utils.getVaultURL(clusterId, env); + Assert.assertEquals(map.get(env), vaultURL); + } } catch (Exception e) { Assert.fail(INVALID_EXCEPTION_THROWN); } diff --git a/src/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java b/v2/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java rename to v2/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java diff --git a/src/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java b/v2/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java rename to v2/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java diff --git a/src/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java b/v2/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java rename to v2/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java diff --git a/src/test/java/com/skyflow/vault/controller/DetectControllerTests.java b/v2/test/java/com/skyflow/vault/controller/DetectControllerTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/controller/DetectControllerTests.java rename to v2/test/java/com/skyflow/vault/controller/DetectControllerTests.java diff --git a/src/test/java/com/skyflow/vault/controller/VaultControllerTests.java b/v2/test/java/com/skyflow/vault/controller/VaultControllerTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/controller/VaultControllerTests.java rename to v2/test/java/com/skyflow/vault/controller/VaultControllerTests.java diff --git a/src/test/java/com/skyflow/vault/data/DeleteTests.java b/v2/test/java/com/skyflow/vault/data/DeleteTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/data/DeleteTests.java rename to v2/test/java/com/skyflow/vault/data/DeleteTests.java diff --git a/src/test/java/com/skyflow/vault/data/GetTests.java b/v2/test/java/com/skyflow/vault/data/GetTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/data/GetTests.java rename to v2/test/java/com/skyflow/vault/data/GetTests.java diff --git a/src/test/java/com/skyflow/vault/data/InsertTests.java b/v2/test/java/com/skyflow/vault/data/InsertTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/data/InsertTests.java rename to v2/test/java/com/skyflow/vault/data/InsertTests.java diff --git a/src/test/java/com/skyflow/vault/data/QueryTests.java b/v2/test/java/com/skyflow/vault/data/QueryTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/data/QueryTests.java rename to v2/test/java/com/skyflow/vault/data/QueryTests.java diff --git a/src/test/java/com/skyflow/vault/data/UpdateTests.java b/v2/test/java/com/skyflow/vault/data/UpdateTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/data/UpdateTests.java rename to v2/test/java/com/skyflow/vault/data/UpdateTests.java diff --git a/src/test/java/com/skyflow/vault/detect/DeidentifyFileRequestTest.java b/v2/test/java/com/skyflow/vault/detect/DeidentifyFileRequestTest.java similarity index 100% rename from src/test/java/com/skyflow/vault/detect/DeidentifyFileRequestTest.java rename to v2/test/java/com/skyflow/vault/detect/DeidentifyFileRequestTest.java diff --git a/src/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java b/v2/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java similarity index 100% rename from src/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java rename to v2/test/java/com/skyflow/vault/detect/DeidentifyFileResponseTest.java diff --git a/src/test/java/com/skyflow/vault/detect/DeidentifyTextTests.java b/v2/test/java/com/skyflow/vault/detect/DeidentifyTextTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/detect/DeidentifyTextTests.java rename to v2/test/java/com/skyflow/vault/detect/DeidentifyTextTests.java diff --git a/src/test/java/com/skyflow/vault/detect/FileEntityInfoTest.java b/v2/test/java/com/skyflow/vault/detect/FileEntityInfoTest.java similarity index 100% rename from src/test/java/com/skyflow/vault/detect/FileEntityInfoTest.java rename to v2/test/java/com/skyflow/vault/detect/FileEntityInfoTest.java diff --git a/src/test/java/com/skyflow/vault/detect/FileInfoTest.java b/v2/test/java/com/skyflow/vault/detect/FileInfoTest.java similarity index 100% rename from src/test/java/com/skyflow/vault/detect/FileInfoTest.java rename to v2/test/java/com/skyflow/vault/detect/FileInfoTest.java diff --git a/src/test/java/com/skyflow/vault/detect/ReidentifyTextTests.java b/v2/test/java/com/skyflow/vault/detect/ReidentifyTextTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/detect/ReidentifyTextTests.java rename to v2/test/java/com/skyflow/vault/detect/ReidentifyTextTests.java diff --git a/src/test/java/com/skyflow/vault/tokens/DetokenizeTests.java b/v2/test/java/com/skyflow/vault/tokens/DetokenizeTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/tokens/DetokenizeTests.java rename to v2/test/java/com/skyflow/vault/tokens/DetokenizeTests.java diff --git a/src/test/java/com/skyflow/vault/tokens/TokenizeTests.java b/v2/test/java/com/skyflow/vault/tokens/TokenizeTests.java similarity index 100% rename from src/test/java/com/skyflow/vault/tokens/TokenizeTests.java rename to v2/test/java/com/skyflow/vault/tokens/TokenizeTests.java diff --git a/v2/v2.iml b/v2/v2.iml new file mode 100644 index 00000000..b06a6787 --- /dev/null +++ b/v2/v2.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/v3/pom.xml b/v3/pom.xml index 47ab8dbd..0e01c5e8 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -20,36 +20,9 @@ - com.skyflow.common + com.skyflow common 1.0.0 - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - - package - - shade - - - - - com.skyflow.common:common - - - - - - - - - \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/Skyflow.java b/v3/src/main/java/com/skyflow/Skyflow.java new file mode 100644 index 00000000..c81326ae --- /dev/null +++ b/v3/src/main/java/com/skyflow/Skyflow.java @@ -0,0 +1,150 @@ +package com.skyflow; + +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.Env; +import com.skyflow.enums.LogLevel; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.controller.VaultController; + +import java.util.LinkedHashMap; + +public final class Skyflow { + private final SkyflowClientBuilder builder; + + private Skyflow(SkyflowClientBuilder builder) { + this.builder = builder; + com.skyflow.utils.logger.LogUtil.printInfoLog(InfoLogs.CLIENT_INITIALIZED.getLog()); + } + + public static SkyflowClientBuilder builder() { + return new SkyflowClientBuilder(); + } + + public VaultConfig getVaultConfig(String vaultId) { + return this.builder.vaultConfigMap.get(vaultId); + } + + public LogLevel getLogLevel() { + return this.builder.logLevel; + } + + public VaultController vault() throws SkyflowException { + Object[] array = this.builder.vaultClientsMap.keySet().toArray(); + if (array.length < 1) { + LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + String vaultId = (String) array[0]; + return this.vault(vaultId); + } + + public VaultController vault(String vaultId) throws SkyflowException { + VaultController controller = this.builder.vaultClientsMap.get(vaultId); + if (controller == null) { + LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return controller; + } + + public static final class SkyflowClientBuilder { + private final LinkedHashMap vaultClientsMap; + private final LinkedHashMap vaultConfigMap; + private Credentials skyflowCredentials; + private LogLevel logLevel; + + public SkyflowClientBuilder() { + this.vaultClientsMap = new LinkedHashMap<>(); + this.vaultConfigMap = new LinkedHashMap<>(); + this.skyflowCredentials = null; + this.logLevel = LogLevel.ERROR; + } + + public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); + Validations.validateVaultConfig(vaultConfig); + if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.VAULT_CONFIG_EXISTS.getLog(), vaultConfig.getVaultId() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), + ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); + } else { + this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); + this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); + } + return this; + } + + public SkyflowClientBuilder updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); + Validations.validateVaultConfig(vaultConfig); + if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { + VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfig); + this.vaultClientsMap.get(updatedConfig.getVaultId()).updateVaultConfig(); + } else { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultConfig.getVaultId() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return this; + } + + public SkyflowClientBuilder removeVaultConfig(String vaultId) throws SkyflowException { + if (this.vaultClientsMap.containsKey(vaultId)) { + this.vaultClientsMap.remove(vaultId); + this.vaultConfigMap.remove(vaultId); + } else { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultId)); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); + } + return this; + } + + public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throws SkyflowException { + Validations.validateCredentials(credentials); + this.skyflowCredentials = credentials; + for (VaultController vault : this.vaultClientsMap.values()) { + vault.setCommonCredentials(this.skyflowCredentials); + } + return this; + } + + public SkyflowClientBuilder setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; + LogUtil.setupLogger(this.logLevel); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.CURRENT_LOG_LEVEL.getLog(), String.valueOf(logLevel) + )); + return this; + } + + public Skyflow build() { + return new Skyflow(this); + } + + private VaultConfig findAndUpdateVaultConfig(VaultConfig vaultConfig) { + VaultConfig previousConfig = this.vaultConfigMap.get(vaultConfig.getVaultId()); + Env env = vaultConfig.getEnv() != null ? vaultConfig.getEnv() : previousConfig.getEnv(); + String clusterId = vaultConfig.getClusterId() != null ? vaultConfig.getClusterId() : previousConfig.getClusterId(); + Credentials credentials = vaultConfig.getCredentials() != null ? vaultConfig.getCredentials() : previousConfig.getCredentials(); + previousConfig.setEnv(env); + previousConfig.setClusterId(clusterId); + previousConfig.setCredentials(credentials); + return previousConfig; + } + } +} diff --git a/src/main/java/com/skyflow/ConnectionClient.java b/v3/src/main/java/com/skyflow/VaultClient.java similarity index 66% rename from src/main/java/com/skyflow/ConnectionClient.java rename to v3/src/main/java/com/skyflow/VaultClient.java index 7cb10713..e8860080 100644 --- a/src/main/java/com/skyflow/ConnectionClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -1,10 +1,13 @@ package com.skyflow; -import com.skyflow.config.ConnectionConfig; import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.ApiClient; +import com.skyflow.generated.rest.ApiClientBuilder; +import com.skyflow.generated.rest.resources.recordservice.RecordserviceClient; import com.skyflow.logs.InfoLogs; import com.skyflow.serviceaccount.util.Token; import com.skyflow.utils.Constants; @@ -14,21 +17,31 @@ import io.github.cdimascio.dotenv.Dotenv; import io.github.cdimascio.dotenv.DotenvException; -public class ConnectionClient { - private final ConnectionConfig connectionConfig; - protected String token; - protected String apiKey; + +public class VaultClient { + private final VaultConfig vaultConfig; + private final ApiClientBuilder apiClientBuilder; + private ApiClient apiClient; private Credentials commonCredentials; private Credentials finalCredentials; + private String token; + private String apiKey; - protected ConnectionClient(ConnectionConfig connectionConfig, Credentials credentials) { + protected VaultClient(VaultConfig vaultConfig, Credentials credentials) { super(); - this.connectionConfig = connectionConfig; + this.vaultConfig = vaultConfig; this.commonCredentials = credentials; + this.apiClientBuilder = new ApiClientBuilder(); + this.apiClient = null; + updateVaultURL(); + } + + protected RecordserviceClient getRecordsApi() { + return this.apiClient.recordservice(); } - protected ConnectionConfig getConnectionConfig() { - return connectionConfig; + protected VaultConfig getVaultConfig() { + return vaultConfig; } protected void setCommonCredentials(Credentials commonCredentials) throws SkyflowException { @@ -36,7 +49,8 @@ protected void setCommonCredentials(Credentials commonCredentials) throws Skyflo prioritiseCredentials(); } - protected void updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException { + protected void updateVaultConfig() throws SkyflowException { + updateVaultURL(); prioritiseCredentials(); } @@ -44,28 +58,27 @@ protected void setBearerToken() throws SkyflowException { prioritiseCredentials(); Validations.validateCredentials(this.finalCredentials); if (this.finalCredentials.getApiKey() != null) { - setApiKey(); + LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); + token = this.finalCredentials.getApiKey(); } else if (Token.isExpired(token)) { LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); token = Utils.generateBearerToken(this.finalCredentials); } else { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); } + this.apiClient = this.apiClientBuilder.build(); } - private void setApiKey() { - if (apiKey == null) { - apiKey = this.finalCredentials.getApiKey(); - } else { - LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); - } + private void updateVaultURL() { + String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); + this.apiClientBuilder.url(vaultURL); } private void prioritiseCredentials() throws SkyflowException { try { Credentials original = this.finalCredentials; - if (this.connectionConfig.getCredentials() != null) { - this.finalCredentials = this.connectionConfig.getCredentials(); + if (this.vaultConfig.getCredentials() != null) { + this.finalCredentials = this.vaultConfig.getCredentials(); } else if (this.commonCredentials != null) { this.finalCredentials = this.commonCredentials; } else { @@ -90,5 +103,4 @@ private void prioritiseCredentials() throws SkyflowException { throw new RuntimeException(e); } } - } diff --git a/v3/src/main/java/com/skyflow/vaultLH/ApiClient.java b/v3/src/main/java/com/skyflow/generated/rest/ApiClient.java similarity index 75% rename from v3/src/main/java/com/skyflow/vaultLH/ApiClient.java rename to v3/src/main/java/com/skyflow/generated/rest/ApiClient.java index 3a5036c8..3bf1a6e7 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/ApiClient.java +++ b/v3/src/main/java/com/skyflow/generated/rest/ApiClient.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH; +package com.skyflow.generated.rest; -import com.skyflow.vaultLH.core.ClientOptions; -import com.skyflow.vaultLH.core.Suppliers; -import com.skyflow.vaultLH.resources.recordservice.RecordserviceClient; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Suppliers; +import com.skyflow.generated.rest.resources.recordservice.RecordserviceClient; import java.util.function.Supplier; diff --git a/v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java b/v3/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java similarity index 89% rename from v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java rename to v3/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java index 143854e7..fa3d6e9d 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/ApiClientBuilder.java +++ b/v3/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH; +package com.skyflow.generated.rest; -import com.skyflow.vaultLH.core.ClientOptions; -import com.skyflow.vaultLH.core.Environment; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Environment; import okhttp3.OkHttpClient; public final class ApiClientBuilder { diff --git a/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java b/v3/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java similarity index 75% rename from v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java rename to v3/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java index 3dc250fb..6edb11d9 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClient.java +++ b/v3/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH; +package com.skyflow.generated.rest; -import com.skyflow.vaultLH.core.ClientOptions; -import com.skyflow.vaultLH.core.Suppliers; -import com.skyflow.vaultLH.resources.recordservice.AsyncRecordserviceClient; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Suppliers; +import com.skyflow.generated.rest.resources.recordservice.AsyncRecordserviceClient; import java.util.function.Supplier; diff --git a/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java b/v3/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java similarity index 89% rename from v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java rename to v3/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java index 2c3117a7..10c08d51 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/AsyncApiClientBuilder.java +++ b/v3/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH; +package com.skyflow.generated.rest; -import com.skyflow.vaultLH.core.ClientOptions; -import com.skyflow.vaultLH.core.Environment; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.Environment; import okhttp3.OkHttpClient; public final class AsyncApiClientBuilder { diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java b/v3/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java index 7a47d49f..be5247eb 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientApiException.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.Response; diff --git a/common/src/main/java/com/skyflow/common/core/ApiClientException.java b/v3/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java similarity index 90% rename from common/src/main/java/com/skyflow/common/core/ApiClientException.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java index 6537d6e8..7987eba6 100644 --- a/common/src/main/java/com/skyflow/common/core/ApiClientException.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.core; +package com.skyflow.generated.rest.core; /** * This class serves as the base exception for all errors in the SDK. diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java b/v3/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java similarity index 95% rename from v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java index 17e505c5..c743352c 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientHttpResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.Response; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java b/v3/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java similarity index 99% rename from v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java index ea1434c2..39235d01 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ClientOptions.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.OkHttpClient; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java b/v3/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java rename to v3/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java index a8beea13..a0a6d7c4 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/DateTimeDeserializer.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Environment.java b/v3/src/main/java/com/skyflow/generated/rest/core/Environment.java similarity index 89% rename from v3/src/main/java/com/skyflow/vaultLH/core/Environment.java rename to v3/src/main/java/com/skyflow/generated/rest/core/Environment.java index 2b6492f1..2fc27c36 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/Environment.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/Environment.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; public final class Environment { private final String url; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java b/v3/src/main/java/com/skyflow/generated/rest/core/FileStream.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java rename to v3/src/main/java/com/skyflow/generated/rest/core/FileStream.java index 2ff273c3..2131b0a4 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/FileStream.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/FileStream.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.MediaType; import okhttp3.RequestBody; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java b/v3/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java rename to v3/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java index 5c462dac..55c3c971 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/InputStreamRequestBody.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.MediaType; import okhttp3.RequestBody; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java b/v3/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java similarity index 86% rename from v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java rename to v3/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java index 9f30207c..11714cb8 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/MediaTypes.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.MediaType; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java b/v3/src/main/java/com/skyflow/generated/rest/core/Nullable.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java rename to v3/src/main/java/com/skyflow/generated/rest/core/Nullable.java index e5e4d5b3..5929c12d 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/Nullable.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/Nullable.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import java.util.Optional; import java.util.function.Function; diff --git a/common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java b/v3/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java similarity index 91% rename from common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java rename to v3/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java index c0a6fe3d..98c33be4 100644 --- a/common/src/main/java/com/skyflow/common/core/NullableNonemptyFilter.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.core; +package com.skyflow.generated.rest.core; import java.util.Optional; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java b/v3/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java index c9b2e7c6..acec32b4 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ObjectMappers.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java b/v3/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java similarity index 99% rename from v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java rename to v3/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java index c813cc0b..c0687736 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/QueryStringMapper.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java b/v3/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java rename to v3/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java index 3dd2c6d9..b8a8d14b 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/RequestOptions.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java b/v3/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java index 254debd6..1bb0b5dc 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyInputStream.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.Response; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java b/v3/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java rename to v3/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java index f36ac01a..e6c1a525 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ResponseBodyReader.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.Response; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java b/v3/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java rename to v3/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java index 81dc3d05..7a28c3c9 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/RetryInterceptor.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import okhttp3.Interceptor; import okhttp3.Response; diff --git a/common/src/main/java/com/skyflow/common/core/Stream.java b/v3/src/main/java/com/skyflow/generated/rest/core/Stream.java similarity index 98% rename from common/src/main/java/com/skyflow/common/core/Stream.java rename to v3/src/main/java/com/skyflow/generated/rest/core/Stream.java index 486fc238..f037712a 100644 --- a/common/src/main/java/com/skyflow/common/core/Stream.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/Stream.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.common.core; +package com.skyflow.generated.rest.core; import java.io.Reader; import java.util.Iterator; diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java b/v3/src/main/java/com/skyflow/generated/rest/core/Suppliers.java similarity index 93% rename from v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java rename to v3/src/main/java/com/skyflow/generated/rest/core/Suppliers.java index cb921e80..307d5852 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/core/Suppliers.java +++ b/v3/src/main/java/com/skyflow/generated/rest/core/Suppliers.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.core; +package com.skyflow.generated.rest.core; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/AsyncRawRecordserviceClient.java similarity index 99% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/AsyncRawRecordserviceClient.java index 5066a298..dcc988a3 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRawRecordserviceClient.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/AsyncRawRecordserviceClient.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice; +package com.skyflow.generated.rest.resources.recordservice; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.vaultLH.core.*; -import com.skyflow.vaultLH.resources.recordservice.requests.*; -import com.skyflow.vaultLH.types.*; +import com.skyflow.generated.rest.core.*; +import com.skyflow.generated.rest.resources.recordservice.requests.*; +import com.skyflow.generated.rest.types.*; import okhttp3.*; import org.jetbrains.annotations.NotNull; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/AsyncRecordserviceClient.java similarity index 94% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/AsyncRecordserviceClient.java index ec2371c1..78746a94 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/AsyncRecordserviceClient.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/AsyncRecordserviceClient.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice; +package com.skyflow.generated.rest.resources.recordservice; -import com.skyflow.vaultLH.core.ClientOptions; -import com.skyflow.vaultLH.core.RequestOptions; -import com.skyflow.vaultLH.resources.recordservice.requests.*; -import com.skyflow.vaultLH.types.*; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.recordservice.requests.*; +import com.skyflow.generated.rest.types.*; import java.util.concurrent.CompletableFuture; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/RawRecordserviceClient.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/RawRecordserviceClient.java index 8bc46f02..f4ddaa10 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RawRecordserviceClient.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/RawRecordserviceClient.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice; +package com.skyflow.generated.rest.resources.recordservice; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.vaultLH.core.*; -import com.skyflow.vaultLH.resources.recordservice.requests.*; -import com.skyflow.vaultLH.types.*; +import com.skyflow.generated.rest.core.*; +import com.skyflow.generated.rest.resources.recordservice.requests.*; +import com.skyflow.generated.rest.types.*; import okhttp3.*; import java.io.IOException; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/RecordserviceClient.java similarity index 93% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/RecordserviceClient.java index a939d023..53e22f6e 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/RecordserviceClient.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/RecordserviceClient.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice; +package com.skyflow.generated.rest.resources.recordservice; -import com.skyflow.vaultLH.core.ClientOptions; -import com.skyflow.vaultLH.core.RequestOptions; -import com.skyflow.vaultLH.resources.recordservice.requests.*; -import com.skyflow.vaultLH.types.*; +import com.skyflow.generated.rest.core.ClientOptions; +import com.skyflow.generated.rest.core.RequestOptions; +import com.skyflow.generated.rest.resources.recordservice.requests.*; +import com.skyflow.generated.rest.types.*; public class RecordserviceClient { protected final ClientOptions clientOptions; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DeleteRequest.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DeleteRequest.java index 0dcd903a..073da6cb 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DeleteRequest.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DeleteTokenRequest.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DeleteTokenRequest.java index 6cbab965..4d7039a8 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DeleteTokenRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DeleteTokenRequest.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DetokenizeRequest.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DetokenizeRequest.java index 57cf43f3..ae1c837c 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/DetokenizeRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/DetokenizeRequest.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; -import com.skyflow.vaultLH.types.TokenGroupRedactions; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.types.TokenGroupRedactions; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/ExecuteQueryRequest.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/ExecuteQueryRequest.java index eb1572aa..9f4a4914 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/ExecuteQueryRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/ExecuteQueryRequest.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/GetRequest.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/GetRequest.java index 03fa9b32..d9367799 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/GetRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/GetRequest.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; -import com.skyflow.vaultLH.types.ColumnRedactions; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.types.ColumnRedactions; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/InsertRequest.java similarity index 95% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/InsertRequest.java index eb1bb342..1ebb5dfb 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/InsertRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/InsertRequest.java @@ -1,13 +1,13 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; -import com.skyflow.vaultLH.types.InsertRecordData; -import com.skyflow.vaultLH.types.Upsert; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.types.InsertRecordData; +import com.skyflow.generated.rest.types.Upsert; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/TokenizeRequest.java similarity index 94% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/TokenizeRequest.java index a57f4246..e1056b7e 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/TokenizeRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/TokenizeRequest.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; -import com.skyflow.vaultLH.types.TokenizeRequestObject; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.types.TokenizeRequestObject; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/UpdateRequest.java similarity index 95% rename from v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java rename to v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/UpdateRequest.java index 96027644..aa859087 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/resources/recordservice/requests/UpdateRequest.java +++ b/v3/src/main/java/com/skyflow/generated/rest/resources/recordservice/requests/UpdateRequest.java @@ -1,13 +1,13 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.resources.recordservice.requests; +package com.skyflow.generated.rest.resources.recordservice.requests; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; -import com.skyflow.vaultLH.types.EnumUpdateType; -import com.skyflow.vaultLH.types.UpdateRecordData; +import com.skyflow.generated.rest.core.ObjectMappers; +import com.skyflow.generated.rest.types.EnumUpdateType; +import com.skyflow.generated.rest.types.UpdateRecordData; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java b/v3/src/main/java/com/skyflow/generated/rest/types/ColumnRedactions.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java rename to v3/src/main/java/com/skyflow/generated/rest/types/ColumnRedactions.java index 14a09d6d..bd0c6915 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/ColumnRedactions.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/ColumnRedactions.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/DeleteResponse.java index 514e1d06..d3d825f0 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteResponseObject.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java rename to v3/src/main/java/com/skyflow/generated/rest/types/DeleteResponseObject.java index a40b18e9..31d34920 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteResponseObject.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteResponseObject.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteTokenResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/DeleteTokenResponse.java index 849ec5ee..728c1877 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteTokenResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteTokenResponseObject.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java rename to v3/src/main/java/com/skyflow/generated/rest/types/DeleteTokenResponseObject.java index 0a994b6c..98e3620f 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/DeleteTokenResponseObject.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/DeleteTokenResponseObject.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/DetokenizeResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/DetokenizeResponse.java index b52a0b92..7e3fa23a 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/DetokenizeResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java b/v3/src/main/java/com/skyflow/generated/rest/types/DetokenizeResponseObject.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java rename to v3/src/main/java/com/skyflow/generated/rest/types/DetokenizeResponseObject.java index 76835758..ed7ed16d 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/DetokenizeResponseObject.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/DetokenizeResponseObject.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java b/v3/src/main/java/com/skyflow/generated/rest/types/EnumDataType.java similarity index 91% rename from v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java rename to v3/src/main/java/com/skyflow/generated/rest/types/EnumDataType.java index 8167e99c..eda51d21 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/EnumDataType.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/EnumDataType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java b/v3/src/main/java/com/skyflow/generated/rest/types/EnumUpdateType.java similarity index 90% rename from v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java rename to v3/src/main/java/com/skyflow/generated/rest/types/EnumUpdateType.java index 8c416624..a435ac27 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/EnumUpdateType.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/EnumUpdateType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/ExecuteQueryRecordResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/ExecuteQueryRecordResponse.java index db676077..5a670a73 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryRecordResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/ExecuteQueryRecordResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/ExecuteQueryResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/ExecuteQueryResponse.java index d8aea21a..e9eb635a 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/ExecuteQueryResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/ExecuteQueryResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/GetResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/GetResponse.java index 71f9e184..190ce169 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/GetResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/GetResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java b/v3/src/main/java/com/skyflow/generated/rest/types/InsertRecordData.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java rename to v3/src/main/java/com/skyflow/generated/rest/types/InsertRecordData.java index e5635b40..2738332b 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/InsertRecordData.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/InsertRecordData.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/InsertResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/InsertResponse.java index 45cd8889..9b577820 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/InsertResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java b/v3/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java similarity index 95% rename from v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java rename to v3/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java index ca2d1dd5..40e73b99 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/ProtobufAny.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java b/v3/src/main/java/com/skyflow/generated/rest/types/RecordResponseObject.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java rename to v3/src/main/java/com/skyflow/generated/rest/types/RecordResponseObject.java index bf3f5614..8e47bba0 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/RecordResponseObject.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/RecordResponseObject.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java b/v3/src/main/java/com/skyflow/generated/rest/types/RpcStatus.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java rename to v3/src/main/java/com/skyflow/generated/rest/types/RpcStatus.java index bf8517e1..bce5f3e9 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/RpcStatus.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/RpcStatus.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java b/v3/src/main/java/com/skyflow/generated/rest/types/TokenGroupRedactions.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java rename to v3/src/main/java/com/skyflow/generated/rest/types/TokenGroupRedactions.java index ba471b8a..cdf3e5e6 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/TokenGroupRedactions.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/TokenGroupRedactions.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeRequestObject.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java rename to v3/src/main/java/com/skyflow/generated/rest/types/TokenizeRequestObject.java index 6fef6c9f..e467650e 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeRequestObject.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeRequestObject.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponse.java index 20688f36..9bd93527 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponseObject.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java rename to v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponseObject.java index 0339565d..77b47099 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObject.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponseObject.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponseObjectToken.java similarity index 98% rename from v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java rename to v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponseObjectToken.java index ee03df38..62c8f32b 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/TokenizeResponseObjectToken.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/TokenizeResponseObjectToken.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java b/v3/src/main/java/com/skyflow/generated/rest/types/UpdateRecordData.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java rename to v3/src/main/java/com/skyflow/generated/rest/types/UpdateRecordData.java index 8a41303b..f9c39572 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/UpdateRecordData.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/UpdateRecordData.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java b/v3/src/main/java/com/skyflow/generated/rest/types/UpdateResponse.java similarity index 96% rename from v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java rename to v3/src/main/java/com/skyflow/generated/rest/types/UpdateResponse.java index f77ef04d..71d49aa8 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/UpdateResponse.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/UpdateResponse.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java b/v3/src/main/java/com/skyflow/generated/rest/types/Upsert.java similarity index 97% rename from v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java rename to v3/src/main/java/com/skyflow/generated/rest/types/Upsert.java index db3c4d77..5bfe7b1b 100644 --- a/v3/src/main/java/com/skyflow/vaultLH/types/Upsert.java +++ b/v3/src/main/java/com/skyflow/generated/rest/types/Upsert.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.vaultLH.types; +package com.skyflow.generated.rest.types; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.vaultLH.core.ObjectMappers; +import com.skyflow.generated.rest.core.ObjectMappers; import java.util.*; diff --git a/v3/src/main/java/com/skyflow/utils/Constants.java b/v3/src/main/java/com/skyflow/utils/Constants.java new file mode 100644 index 00000000..a8fd82ab --- /dev/null +++ b/v3/src/main/java/com/skyflow/utils/Constants.java @@ -0,0 +1,7 @@ +package com.skyflow.utils; + +public class Constants extends BaseConstants { + public static final String SDK_NAME = "Skyflow Java SDK "; + public static final String SDK_VERSION = "3.0.0-beta.0"; + public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; +} diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java new file mode 100644 index 00000000..32c66e63 --- /dev/null +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -0,0 +1,56 @@ +package com.skyflow.utils; + +import com.google.gson.JsonObject; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.logger.LogUtil; + +public final class Utils extends BaseUtils { + + public static JsonObject getMetrics() { + JsonObject details = new JsonObject(); + String sdkVersion = Constants.SDK_VERSION; + String deviceModel; + String osDetails; + String javaVersion; + // Retrieve device model + try { + deviceModel = System.getProperty("os.name"); + if (deviceModel == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + Constants.SDK_METRIC_CLIENT_DEVICE_MODEL + )); + deviceModel = ""; + } + + // Retrieve OS details + try { + osDetails = System.getProperty("os.version"); + if (osDetails == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + Constants.SDK_METRIC_CLIENT_OS_DETAILS + )); + osDetails = ""; + } + + // Retrieve Java version details + try { + javaVersion = System.getProperty("java.version"); + if (javaVersion == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + Constants.SDK_METRIC_RUNTIME_DETAILS + )); + javaVersion = ""; + } + details.addProperty(Constants.SDK_METRIC_NAME_VERSION, Constants.SDK_METRIC_NAME_VERSION_PREFIX + sdkVersion); + details.addProperty(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL, deviceModel); + details.addProperty(Constants.SDK_METRIC_RUNTIME_DETAILS, Constants.SDK_METRIC_RUNTIME_DETAILS_PREFIX + javaVersion); + details.addProperty(Constants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); + return details; + } +} diff --git a/v3/src/main/java/com/skyflow/utils/validations/Validations.java b/v3/src/main/java/com/skyflow/utils/validations/Validations.java new file mode 100644 index 00000000..374e84d4 --- /dev/null +++ b/v3/src/main/java/com/skyflow/utils/validations/Validations.java @@ -0,0 +1,9 @@ +package com.skyflow.utils.validations; + +public class Validations extends BaseValidations { + private Validations() { + super(); + } + + // add validations specific to v3 SDK +} diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java new file mode 100644 index 00000000..3d3a656a --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -0,0 +1,17 @@ +package com.skyflow.vault.controller; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.skyflow.VaultClient; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; + +public final class VaultController extends VaultClient { + private static final Gson gson = new GsonBuilder().serializeNulls().create(); + + public VaultController(VaultConfig vaultConfig, Credentials credentials) { + super(vaultConfig, credentials); + } + + // add methods for v3 SDK +} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java b/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java deleted file mode 100644 index 4e108d3f..00000000 --- a/v3/src/main/java/com/skyflow/vaultLH/core/ApiClientException.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.vaultLH.core; - -/** - * This class serves as the base exception for all errors in the SDK. - */ -public class ApiClientException extends RuntimeException { - public ApiClientException(String message) { - super(message); - } - - public ApiClientException(String message, Exception e) { - super(message, e); - } -} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java b/v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java deleted file mode 100644 index e1cc5eb3..00000000 --- a/v3/src/main/java/com/skyflow/vaultLH/core/NullableNonemptyFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.vaultLH.core; - -import java.util.Optional; - -public final class NullableNonemptyFilter { - @Override - public boolean equals(Object o) { - boolean isOptionalEmpty = isOptionalEmpty(o); - - return isOptionalEmpty; - } - - private boolean isOptionalEmpty(Object o) { - return o instanceof Optional && !((Optional) o).isPresent(); - } -} diff --git a/v3/src/main/java/com/skyflow/vaultLH/core/Stream.java b/v3/src/main/java/com/skyflow/vaultLH/core/Stream.java deleted file mode 100644 index 3b6225b8..00000000 --- a/v3/src/main/java/com/skyflow/vaultLH/core/Stream.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.vaultLH.core; - -import java.io.Reader; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Scanner; - -/** - * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing - * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. - *

- * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a - * {@code Scanner} to block during iteration if the next object is not available. - * - * @param The type of objects in the stream. - */ -public final class Stream implements Iterable { - /** - * The {@link Class} of the objects in the stream. - */ - private final Class valueType; - /** - * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. - */ - private final Scanner scanner; - - /** - * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. - * - * @param valueType The class of the objects in the stream. - * @param reader The reader that provides the streamed data. - * @param delimiter The delimiter used to separate elements in the stream. - */ - public Stream(Class valueType, Reader reader, String delimiter) { - this.scanner = new Scanner(reader).useDelimiter(delimiter); - this.valueType = valueType; - } - - /** - * Returns an iterator over the elements in this stream that blocks during iteration when the next object is - * not yet available. - * - * @return An iterator that can be used to traverse the elements in the stream. - */ - @Override - public Iterator iterator() { - return new Iterator() { - /** - * Returns {@code true} if there are more elements in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return {@code true} if there are more elements, {@code false} otherwise. - */ - @Override - public boolean hasNext() { - return scanner.hasNext(); - } - - /** - * Returns the next element in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return The next element in the stream. - * @throws NoSuchElementException If there are no more elements in the stream. - */ - @Override - public T next() { - if (!scanner.hasNext()) { - throw new NoSuchElementException(); - } else { - try { - T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - scanner.next().trim(), valueType); - return parsedResponse; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - /** - * Removing elements from {@code Stream} is not supported. - * - * @throws UnsupportedOperationException Always, as removal is not supported. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } -} From e7809d859eed1ae3a53a1a4f453a707212f2a2cc Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Wed, 20 Aug 2025 14:28:29 +0530 Subject: [PATCH 03/97] SK-2243 Refactor v2 and v3 wrapper code --- common/pom.xml | 3 +- .../main/java/com/skyflow/BaseSkyflow.java | 48 +++++++ .../java/com/skyflow/config/VaultConfig.java | 4 +- .../java/com/skyflow/logs/WarningLogs.java | 15 +++ .../java/com/skyflow/utils/BaseUtils.java | 25 +++- .../com/skyflow/vault/RequestOptions.java | 37 ++++++ .../skyflow/vault/data/BaseGetRequest.java | 122 ++++++++++++++++++ .../skyflow/vault/data/BaseGetResponse.java | 30 +++++ .../skyflow/vault/data/BaseInsertRequest.java | 70 ++++++++++ .../vault/data/BaseInsertResponse.java | 30 +++++ .../com/skyflow/vault/data/DeleteRequest.java | 45 +++++++ .../skyflow/vault/data/DeleteResponse.java | 27 ++++ .../com/skyflow/vault/data/QueryRequest.java | 33 +++++ .../com/skyflow/vault/data/QueryResponse.java | 32 +++++ .../com/skyflow/vault/data/UpdateRequest.java | 67 ++++++++++ .../skyflow/vault/data/UpdateResponse.java | 39 ++++++ .../com/skyflow/vault/tokens/ColumnValue.java | 45 +++++++ .../skyflow/vault/tokens/DetokenizeData.java | 14 ++ .../tokens/DetokenizeRecordResponse.java | 54 ++++++++ .../vault/tokens/DetokenizeRequest.java | 57 ++++++++ .../vault/tokens/DetokenizeResponse.java | 29 +++++ .../skyflow/vault/tokens/TokenizeRequest.java | 35 +++++ .../vault/tokens/TokenizeResponse.java | 33 +++++ pom.xml | 2 +- v2/pom.xml | 3 +- v2/src/main/java/com/skyflow/Skyflow.java | 41 +++--- .../vault/controller/VaultController.java | 1 + .../com/skyflow/vault/data/GetRequest.java | 86 ++++-------- .../com/skyflow/vault/data/InsertRequest.java | 47 ++----- v3/pom.xml | 3 +- .../java/com/example/BulkRecordInserter.java | 107 +++++++++++++++ v3/src/main/java/com/skyflow/Skyflow.java | 81 ++---------- .../vault/controller/VaultController.java | 17 +++ 33 files changed, 1089 insertions(+), 193 deletions(-) create mode 100644 common/src/main/java/com/skyflow/BaseSkyflow.java create mode 100644 common/src/main/java/com/skyflow/logs/WarningLogs.java create mode 100644 common/src/main/java/com/skyflow/vault/RequestOptions.java create mode 100644 common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/data/DeleteRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/data/DeleteResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/data/QueryRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/data/QueryResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/data/UpdateRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/data/UpdateResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java create mode 100644 common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java create mode 100644 v3/src/main/java/com/example/BulkRecordInserter.java diff --git a/common/pom.xml b/common/pom.xml index 1695ca87..d971c1b5 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -6,12 +6,11 @@ com.skyflow skyflow-java - 2.0.0-beta.2 + 1.0.0 common 1.0.0 - com.skyflow 8 diff --git a/common/src/main/java/com/skyflow/BaseSkyflow.java b/common/src/main/java/com/skyflow/BaseSkyflow.java new file mode 100644 index 00000000..9a117a16 --- /dev/null +++ b/common/src/main/java/com/skyflow/BaseSkyflow.java @@ -0,0 +1,48 @@ +package com.skyflow; + +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.LogLevel; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.BaseUtils; +import com.skyflow.utils.logger.LogUtil; + +import java.util.LinkedHashMap; + +class BaseSkyflow { + private final BaseSkyflowClientBuilder builder; + + protected BaseSkyflow(BaseSkyflowClientBuilder builder) { + this.builder = builder; + } + + public LogLevel getLogLevel() { + return this.builder.logLevel; + } + + public VaultConfig getVaultConfig() { + Object[] array = this.builder.vaultConfigMap.values().toArray(); + return (VaultConfig) array[0]; + } + + static class BaseSkyflowClientBuilder { + protected final LinkedHashMap vaultConfigMap; + protected Credentials skyflowCredentials; + protected LogLevel logLevel; + + protected BaseSkyflowClientBuilder() { + this.vaultConfigMap = new LinkedHashMap<>(); + this.skyflowCredentials = null; + this.logLevel = LogLevel.ERROR; + } + + public BaseSkyflowClientBuilder setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; + LogUtil.setupLogger(this.logLevel); + LogUtil.printInfoLog(BaseUtils.parameterizedString( + InfoLogs.CURRENT_LOG_LEVEL.getLog(), String.valueOf(logLevel) + )); + return this; + } + } +} diff --git a/common/src/main/java/com/skyflow/config/VaultConfig.java b/common/src/main/java/com/skyflow/config/VaultConfig.java index 4f61af2a..7e660373 100644 --- a/common/src/main/java/com/skyflow/config/VaultConfig.java +++ b/common/src/main/java/com/skyflow/config/VaultConfig.java @@ -2,7 +2,9 @@ import com.skyflow.enums.Env; -public class VaultConfig { +import java.io.Serializable; + +public class VaultConfig implements Serializable { private String vaultId; private String clusterId; private Env env; diff --git a/common/src/main/java/com/skyflow/logs/WarningLogs.java b/common/src/main/java/com/skyflow/logs/WarningLogs.java new file mode 100644 index 00000000..8d49f056 --- /dev/null +++ b/common/src/main/java/com/skyflow/logs/WarningLogs.java @@ -0,0 +1,15 @@ +package com.skyflow.logs; + +public enum WarningLogs { + OVERRIDING_EXISTING_VAULT_CONFIG("New vault config identified. Overriding existing vault config"); + + private final String log; + + WarningLogs(String log) { + this.log = log; + } + + public final String getLog() { + return log; + } +} diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index ba7d7206..c1049f9a 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -10,7 +10,7 @@ import com.skyflow.utils.logger.LogUtil; import org.apache.commons.codec.binary.Base64; -import java.io.File; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.security.KeyFactory; @@ -111,4 +111,27 @@ private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws Skyflow } return privateKey; } + + public static T deepCopy(T obj) { + try { + // Serialize the object to a byte array + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(obj); + oos.close(); + bos.close(); + + // Deserialize the byte array back to a new object + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bis); + T copiedObj = (T) ois.readObject(); + ois.close(); + bis.close(); + + return copiedObj; + } catch (IOException | ClassNotFoundException e) { + e.printStackTrace(); + return null; + } + } } diff --git a/common/src/main/java/com/skyflow/vault/RequestOptions.java b/common/src/main/java/com/skyflow/vault/RequestOptions.java new file mode 100644 index 00000000..0855e175 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/RequestOptions.java @@ -0,0 +1,37 @@ +package com.skyflow.vault; + +public class RequestOptions { + public RequestOptionsBuilder builder; + + public static RequestOptionsBuilder builder() { + return new RequestOptionsBuilder(); + } + + public int getBatchSize() { + return this.builder.batchSize; + } + + public int getConcurrencyLimit() { + return this.builder.concurrencyLimit; + } + + public static class RequestOptionsBuilder { + private int batchSize; + private int concurrencyLimit; + + private RequestOptionsBuilder() { + this.batchSize = 100; + this.concurrencyLimit = 1; + } + + public RequestOptionsBuilder batchSize(int batchSize) { + this.batchSize = batchSize; + return this; + } + + public RequestOptionsBuilder concurrencyLimit(int concurrencyLimit) { + this.concurrencyLimit = concurrencyLimit; + return this; + } + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java b/common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java new file mode 100644 index 00000000..c6d828cc --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java @@ -0,0 +1,122 @@ +package com.skyflow.vault.data; + +import com.skyflow.utils.BaseConstants; + +import java.util.ArrayList; + +class BaseGetRequest { + private final BaseGetRequestBuilder builder; + + protected BaseGetRequest(BaseGetRequestBuilder builder) { + this.builder = builder; + } + + public String getTable() { + return this.builder.table; + } + + public ArrayList getIds() { + return this.builder.ids; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public ArrayList getFields() { + return this.builder.fields; + } + + public String getOffset() { + return this.builder.offset; + } + + public String getLimit() { + return this.builder.limit; + } + + public Boolean getDownloadURL() { + return this.builder.downloadURL; + } + + public String getColumnName() { + return this.builder.columnName; + } + + public ArrayList getColumnValues() { + return this.builder.columnValues; + } + + public String getOrderBy() { + return this.builder.orderBy; + } + + static class BaseGetRequestBuilder { + protected String table; + protected ArrayList ids; + protected Boolean returnTokens; + protected ArrayList fields; + protected String offset; + protected String limit; + protected Boolean downloadURL; + protected String columnName; + protected ArrayList columnValues; + protected String orderBy; + + protected BaseGetRequestBuilder() { + this.downloadURL = true; + this.orderBy = BaseConstants.ORDER_ASCENDING; + } + + public BaseGetRequestBuilder table(String table) { + this.table = table; + return this; + } + + public BaseGetRequestBuilder ids(ArrayList ids) { + this.ids = ids; + return this; + } + + public BaseGetRequestBuilder returnTokens(Boolean returnTokens) { + this.returnTokens = returnTokens; + return this; + } + + public BaseGetRequestBuilder fields(ArrayList fields) { + this.fields = fields; + return this; + } + + public BaseGetRequestBuilder offset(String offset) { + this.offset = offset; + return this; + } + + public BaseGetRequestBuilder limit(String limit) { + this.limit = limit; + return this; + } + + public BaseGetRequestBuilder downloadURL(Boolean downloadURL) { + this.downloadURL = downloadURL == null || downloadURL; + return this; + } + + public BaseGetRequestBuilder columnName(String columnName) { + this.columnName = columnName; + return this; + } + + public BaseGetRequestBuilder columnValues(ArrayList columnValues) { + this.columnValues = columnValues; + return this; + } + + public BaseGetRequestBuilder orderBy(String orderBy) { + this.orderBy = orderBy == null ? BaseConstants.ORDER_ASCENDING : orderBy; + return this; + } + + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java b/common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java new file mode 100644 index 00000000..7a985fe6 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java @@ -0,0 +1,30 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.HashMap; + +public class BaseGetResponse { + private final ArrayList> data; + private final ArrayList> errors; + + public BaseGetResponse(ArrayList> data, ArrayList> errors) { + this.data = data; + this.errors = errors; + } + + public ArrayList> getData() { + return data; + } + + public ArrayList> getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java new file mode 100644 index 00000000..64e61153 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java @@ -0,0 +1,70 @@ +package com.skyflow.vault.data; + +import java.util.ArrayList; +import java.util.HashMap; + +class BaseInsertRequest { + private final BaseInsertRequestBuilder builder; + + protected BaseInsertRequest(BaseInsertRequestBuilder builder) { + this.builder = builder; + } + + public String getTable() { + return this.builder.table; + } + + public ArrayList> getValues() { + return this.builder.values; + } + + public ArrayList> getTokens() { + return this.builder.tokens; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public String getUpsert() { + return this.builder.upsert; + } + + static class BaseInsertRequestBuilder { + protected String table; + protected ArrayList> values; + protected ArrayList> tokens; + protected Boolean returnTokens; + protected String upsert; + + protected BaseInsertRequestBuilder() { + this.returnTokens = false; + } + + public BaseInsertRequestBuilder table(String table) { + this.table = table; + return this; + } + + public BaseInsertRequestBuilder values(ArrayList> values) { + this.values = values; + return this; + } + + public BaseInsertRequestBuilder tokens(ArrayList> tokens) { + this.tokens = tokens; + return this; + } + + public BaseInsertRequestBuilder returnTokens(Boolean returnTokens) { + this.returnTokens = returnTokens != null && returnTokens; + return this; + } + + public BaseInsertRequestBuilder upsert(String upsert) { + this.upsert = upsert; + return this; + } + } +} + diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java new file mode 100644 index 00000000..b3eead69 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java @@ -0,0 +1,30 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.HashMap; + +public class BaseInsertResponse { + private final ArrayList> insertedFields; + private final ArrayList> errors; + + public BaseInsertResponse(ArrayList> insertedFields, ArrayList> errors) { + this.insertedFields = insertedFields; + this.errors = errors; + } + + public ArrayList> getInsertedFields() { + return insertedFields; + } + + public ArrayList> getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/DeleteRequest.java b/common/src/main/java/com/skyflow/vault/data/DeleteRequest.java new file mode 100644 index 00000000..d61c996f --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/DeleteRequest.java @@ -0,0 +1,45 @@ +package com.skyflow.vault.data; + +import java.util.ArrayList; + +public class DeleteRequest { + private final DeleteRequestBuilder builder; + + private DeleteRequest(DeleteRequestBuilder builder) { + this.builder = builder; + } + + public static DeleteRequestBuilder builder() { + return new DeleteRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public ArrayList getIds() { + return this.builder.ids; + } + + public static final class DeleteRequestBuilder { + private String table; + private ArrayList ids; + + private DeleteRequestBuilder() { + } + + public DeleteRequestBuilder table(String table) { + this.table = table; + return this; + } + + public DeleteRequestBuilder ids(ArrayList ids) { + this.ids = ids; + return this; + } + + public DeleteRequest build() { + return new DeleteRequest(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/DeleteResponse.java b/common/src/main/java/com/skyflow/vault/data/DeleteResponse.java new file mode 100644 index 00000000..f34d219a --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/DeleteResponse.java @@ -0,0 +1,27 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.util.List; + +public class DeleteResponse { + private final List deletedIds; + + public DeleteResponse(List deletedIds) { + this.deletedIds = deletedIds; + } + + public List getDeletedIds() { + return deletedIds; + } + + @Override + public String toString() { + Gson gson = new Gson(); + JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); + responseObject.add("errors", null); + return responseObject.toString(); + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/QueryRequest.java b/common/src/main/java/com/skyflow/vault/data/QueryRequest.java new file mode 100644 index 00000000..2aaa200d --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/QueryRequest.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.data; + +public class QueryRequest { + private final QueryRequestBuilder builder; + + private QueryRequest(QueryRequestBuilder builder) { + this.builder = builder; + } + + public static QueryRequestBuilder builder() { + return new QueryRequestBuilder(); + } + + public String getQuery() { + return this.builder.query; + } + + public static final class QueryRequestBuilder { + private String query; + + private QueryRequestBuilder() { + } + + public QueryRequestBuilder query(String query) { + this.query = query; + return this; + } + + public QueryRequest build() { + return new QueryRequest(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/QueryResponse.java b/common/src/main/java/com/skyflow/vault/data/QueryResponse.java new file mode 100644 index 00000000..7a1bca51 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/QueryResponse.java @@ -0,0 +1,32 @@ +package com.skyflow.vault.data; + +import com.google.gson.*; + +import java.util.ArrayList; +import java.util.HashMap; + +public class QueryResponse { + private final ArrayList> fields; + private ArrayList> tokenizedData; + + public QueryResponse(ArrayList> fields) { + this.fields = fields; + } + + public ArrayList> getFields() { + return fields; + } + + @Override + public String toString() { + Gson gson = new GsonBuilder().serializeNulls().create(); + JsonObject responseObject = gson.toJsonTree(this).getAsJsonObject(); + JsonArray fieldsArray = responseObject.get("fields").getAsJsonArray(); + for (JsonElement fieldElement : fieldsArray) { + fieldElement.getAsJsonObject().add("tokenizedData", new JsonObject()); + } + responseObject.add("errors", null); + responseObject.remove("tokenizedData"); + return responseObject.toString(); + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/UpdateRequest.java b/common/src/main/java/com/skyflow/vault/data/UpdateRequest.java new file mode 100644 index 00000000..ac88b18b --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/UpdateRequest.java @@ -0,0 +1,67 @@ +package com.skyflow.vault.data; + +import java.util.HashMap; + +public class UpdateRequest { + private final UpdateRequestBuilder builder; + + private UpdateRequest(UpdateRequestBuilder builder) { + this.builder = builder; + } + + public static UpdateRequestBuilder builder() { + return new UpdateRequestBuilder(); + } + + public String getTable() { + return this.builder.table; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public HashMap getData() { + return this.builder.data; + } + + public HashMap getTokens() { + return this.builder.tokens; + } + + + public static final class UpdateRequestBuilder { + private String table; + private Boolean returnTokens; + private HashMap data; + private HashMap tokens; + + private UpdateRequestBuilder() { + this.returnTokens = false; + } + + public UpdateRequestBuilder table(String table) { + this.table = table; + return this; + } + + public UpdateRequestBuilder returnTokens(Boolean returnTokens) { + this.returnTokens = returnTokens != null && returnTokens; + return this; + } + + public UpdateRequestBuilder data(HashMap data) { + this.data = data; + return this; + } + + public UpdateRequestBuilder tokens(HashMap tokens) { + this.tokens = tokens; + return this; + } + + public UpdateRequest build() { + return new UpdateRequest(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/vault/data/UpdateResponse.java b/common/src/main/java/com/skyflow/vault/data/UpdateResponse.java new file mode 100644 index 00000000..b1013cb9 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/data/UpdateResponse.java @@ -0,0 +1,39 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.util.HashMap; + +public class UpdateResponse { + private final String skyflowId; + private final HashMap tokens; + + public UpdateResponse(String skyflowId, HashMap tokens) { + this.skyflowId = skyflowId; + this.tokens = tokens; + } + + public String getSkyflowId() { + return skyflowId; + } + + public HashMap getTokens() { + return tokens; + } + + @Override + public String toString() { + Gson gson = new Gson(); + JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); + JsonObject tokensObject = responseObject.remove("tokens").getAsJsonObject(); + for (String key : tokensObject.keySet()) { + responseObject.add(key, tokensObject.get(key)); + } + JsonObject finalResponseObject = new JsonObject(); + finalResponseObject.add("updatedField", responseObject); + finalResponseObject.add("errors", null); + return finalResponseObject.toString(); + } +} diff --git a/common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java b/common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java new file mode 100644 index 00000000..3fa08b2e --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java @@ -0,0 +1,45 @@ +package com.skyflow.vault.tokens; + +public class ColumnValue { + + private final ColumnValueBuilder builder; + + private ColumnValue(ColumnValueBuilder builder) { + this.builder = builder; + } + + public static ColumnValueBuilder builder() { + return new ColumnValueBuilder(); + } + + public String getValue() { + return this.builder.value; + } + + public String getColumnGroup() { + return this.builder.columnGroup; + } + + public static final class ColumnValueBuilder { + private String value; + private String columnGroup; + + private ColumnValueBuilder() { + } + + public ColumnValueBuilder value(String value) { + this.value = value; + return this; + } + + public ColumnValueBuilder columnGroup(String columnGroup) { + this.columnGroup = columnGroup; + return this; + } + + public ColumnValue build() { + return new ColumnValue(this); + } + } + +} diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java new file mode 100644 index 00000000..c42abff6 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java @@ -0,0 +1,14 @@ +package com.skyflow.vault.tokens; + +public class DetokenizeData { + private final String token; + + public DetokenizeData(String token) { + this.token = token; + } + + public String getToken() { + return this.token; + } + +} diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java new file mode 100644 index 00000000..7d2ae73c --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java @@ -0,0 +1,54 @@ +package com.skyflow.vault.tokens; + + +import com.skyflow.generated.rest.types.V1DetokenizeRecordResponse; + +public class DetokenizeRecordResponse { + private final String token; + private final String value; + private final String type; + private final String error; + private final String requestId; + + public DetokenizeRecordResponse(V1DetokenizeRecordResponse record) { + this(record, null); + } + + public DetokenizeRecordResponse(V1DetokenizeRecordResponse record, String requestId) { + this.token = record.getToken().orElse(null); + + this.value = record.getValue() + .filter(val -> val != null && !val.toString().isEmpty()) + .orElse(null); + + this.type = record.getValueType() + .map(Enum::toString) + .filter(val -> !"NONE".equals(val)) + .orElse(null); + + this.error = record.getError().orElse(null); + + this.requestId = requestId; + } + + + public String getError() { + return error; + } + + public String getToken() { + return token; + } + + public String getValue() { + return value; + } + + public String getType() { + return type; + } + + public String getRequestId() { + return requestId; + } +} \ No newline at end of file diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java new file mode 100644 index 00000000..186a18d2 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java @@ -0,0 +1,57 @@ +package com.skyflow.vault.tokens; + +import java.util.ArrayList; + +public class DetokenizeRequest { + private final DetokenizeRequestBuilder builder; + + private DetokenizeRequest(DetokenizeRequestBuilder builder) { + this.builder = builder; + } + + public static DetokenizeRequestBuilder builder() { + return new DetokenizeRequestBuilder(); + } + + public ArrayList getDetokenizeData() { + return this.builder.detokenizeData; + } + + public Boolean getContinueOnError() { + return this.builder.continueOnError; + } + + public Boolean getDownloadURL() { + return this.builder.downloadURL; + } + + public static final class DetokenizeRequestBuilder { + private ArrayList detokenizeData; + private Boolean continueOnError; + private Boolean downloadURL; + + private DetokenizeRequestBuilder() { + this.continueOnError = false; + this.downloadURL = false; + } + + public DetokenizeRequestBuilder detokenizeData(ArrayList detokenizeData) { + this.detokenizeData = detokenizeData; + return this; + } + + public DetokenizeRequestBuilder continueOnError(Boolean continueOnError) { + this.continueOnError = continueOnError != null && continueOnError; + return this; + } + + public DetokenizeRequestBuilder downloadURL(Boolean downloadURL) { + this.downloadURL = downloadURL; + return this; + } + + public DetokenizeRequest build() { + return new DetokenizeRequest(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java new file mode 100644 index 00000000..31ff64b2 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java @@ -0,0 +1,29 @@ +package com.skyflow.vault.tokens; + +import com.google.gson.Gson; + +import java.util.ArrayList; + +public class DetokenizeResponse { + private final ArrayList detokenizedFields; + private final ArrayList errors; + + public DetokenizeResponse(ArrayList detokenizedFields, ArrayList errors) { + this.detokenizedFields = detokenizedFields; + this.errors = errors; + } + + public ArrayList getDetokenizedFields() { + return detokenizedFields; + } + + public ArrayList getErrors() { + return errors; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java b/common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java new file mode 100644 index 00000000..8f6da5d9 --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java @@ -0,0 +1,35 @@ +package com.skyflow.vault.tokens; + +import java.util.List; + +public class TokenizeRequest { + private final TokenizeRequestBuilder builder; + + private TokenizeRequest(TokenizeRequestBuilder builder) { + this.builder = builder; + } + + public static TokenizeRequestBuilder builder() { + return new TokenizeRequestBuilder(); + } + + public List getColumnValues() { + return this.builder.columnValues; + } + + public static final class TokenizeRequestBuilder { + private List columnValues; + + private TokenizeRequestBuilder() { + } + + public TokenizeRequestBuilder values(List columnValues) { + this.columnValues = columnValues; + return this; + } + + public TokenizeRequest build() { + return new TokenizeRequest(this); + } + } +} diff --git a/common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java b/common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java new file mode 100644 index 00000000..d8d8072b --- /dev/null +++ b/common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.tokens; + +import com.google.gson.*; + +import java.util.List; + +public class TokenizeResponse { + private final List tokens; + + public TokenizeResponse(List tokens) { + this.tokens = tokens; + } + + public List getTokens() { + return tokens; + } + + @Override + public String toString() { + Gson gson = new Gson(); + JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); + JsonArray tokensArray = responseObject.remove("tokens").getAsJsonArray(); + JsonArray newTokensArray = new JsonArray(); + for (JsonElement token : tokensArray) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("token", token.getAsString()); + newTokensArray.add(jsonObject); + } + responseObject.add("tokens", newTokensArray); + responseObject.add("errors", null); + return responseObject.toString(); + } +} diff --git a/pom.xml b/pom.xml index 40d47190..f36b6778 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow-java - 2.0.0-beta.2 + 1.0.0 pom ${project.groupId}:${project.artifactId} diff --git a/v2/pom.xml b/v2/pom.xml index 788af67f..294d6df0 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -6,12 +6,11 @@ com.skyflow skyflow-java - 2.0.0-beta.2 + 1.0.0 v2 2.0.0-beta.2 - com.skyflow.v2 8 diff --git a/v2/src/main/java/com/skyflow/Skyflow.java b/v2/src/main/java/com/skyflow/Skyflow.java index 8e51da57..4bddb9b3 100644 --- a/v2/src/main/java/com/skyflow/Skyflow.java +++ b/v2/src/main/java/com/skyflow/Skyflow.java @@ -19,10 +19,11 @@ import java.util.LinkedHashMap; -public final class Skyflow { +public final class Skyflow extends BaseSkyflow { private final SkyflowClientBuilder builder; private Skyflow(SkyflowClientBuilder builder) { + super(builder); this.builder = builder; LogUtil.printInfoLog(InfoLogs.CLIENT_INITIALIZED.getLog()); } @@ -79,10 +80,6 @@ public Skyflow updateLogLevel(LogLevel logLevel) { return this; } - public LogLevel getLogLevel() { - return this.builder.logLevel; - } - public VaultController vault() throws SkyflowException { Object[] array = this.builder.vaultClientsMap.keySet().toArray(); if (array.length < 1) { @@ -102,7 +99,6 @@ public VaultController vault(String vaultId) throws SkyflowException { return controller; } - public ConnectionController connection() throws SkyflowException { Object[] array = this.builder.connectionsMap.keySet().toArray(); if (array.length < 1) { @@ -141,23 +137,21 @@ public DetectController detect(String vaultId) throws SkyflowException { return controller; } - public static final class SkyflowClientBuilder { + public static final class SkyflowClientBuilder extends BaseSkyflowClientBuilder { private final LinkedHashMap connectionsMap; private final LinkedHashMap vaultClientsMap; private final LinkedHashMap detectClientsMap; - private final LinkedHashMap vaultConfigMap; + // private final LinkedHashMap vaultConfigMap; private final LinkedHashMap connectionConfigMap; - private Credentials skyflowCredentials; - private LogLevel logLevel; +// private Credentials skyflowCredentials; +// private LogLevel logLevel; public SkyflowClientBuilder() { + super(); this.vaultClientsMap = new LinkedHashMap<>(); this.detectClientsMap = new LinkedHashMap<>(); - this.vaultConfigMap = new LinkedHashMap<>(); this.connectionsMap = new LinkedHashMap<>(); this.connectionConfigMap = new LinkedHashMap<>(); - this.skyflowCredentials = null; - this.logLevel = LogLevel.ERROR; } public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { @@ -170,9 +164,11 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); } else { - this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); - this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); - this.detectClientsMap.put(vaultConfig.getVaultId(), new DetectController(vaultConfig, this.skyflowCredentials)); + VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); + assert vaultConfigDeepCopy != null; + this.vaultConfigMap.put(vaultConfigDeepCopy.getVaultId(), vaultConfigDeepCopy); + this.vaultClientsMap.put(vaultConfigDeepCopy.getVaultId(), new VaultController(vaultConfigDeepCopy, this.skyflowCredentials)); + this.detectClientsMap.put(vaultConfigDeepCopy.getVaultId(), new DetectController(vaultConfigDeepCopy, this.skyflowCredentials)); LogUtil.printInfoLog(Utils.parameterizedString( InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); LogUtil.printInfoLog(Utils.parameterizedString( @@ -184,8 +180,10 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl public SkyflowClientBuilder updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); Validations.validateVaultConfig(vaultConfig); - if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { - VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfig); + VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); + assert vaultConfigDeepCopy != null; + if (this.vaultClientsMap.containsKey(vaultConfigDeepCopy.getVaultId())) { + VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfigDeepCopy); this.vaultClientsMap.get(updatedConfig.getVaultId()).updateVaultConfig(); } else { LogUtil.printErrorLog(Utils.parameterizedString( @@ -271,12 +269,9 @@ public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throw return this; } + @Override public SkyflowClientBuilder setLogLevel(LogLevel logLevel) { - this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; - LogUtil.setupLogger(this.logLevel); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.CURRENT_LOG_LEVEL.getLog(), String.valueOf(logLevel) - )); + super.setLogLevel(logLevel); return this; } diff --git a/v2/src/main/java/com/skyflow/vault/controller/VaultController.java b/v2/src/main/java/com/skyflow/vault/controller/VaultController.java index 84e528b0..adac6e0c 100644 --- a/v2/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v2/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -22,6 +22,7 @@ import com.skyflow.utils.validations.Validations; import com.skyflow.vault.data.*; import com.skyflow.vault.tokens.*; + import java.util.*; public final class VaultController extends VaultClient { diff --git a/v2/src/main/java/com/skyflow/vault/data/GetRequest.java b/v2/src/main/java/com/skyflow/vault/data/GetRequest.java index 04626e35..ef4edea2 100644 --- a/v2/src/main/java/com/skyflow/vault/data/GetRequest.java +++ b/v2/src/main/java/com/skyflow/vault/data/GetRequest.java @@ -5,10 +5,11 @@ import java.util.ArrayList; -public class GetRequest { +public class GetRequest extends BaseGetRequest { private final GetRequestBuilder builder; private GetRequest(GetRequestBuilder builder) { + super(builder); this.builder = builder; } @@ -16,75 +17,28 @@ public static GetRequestBuilder builder() { return new GetRequestBuilder(); } - public String getTable() { - return this.builder.table; - } - - public ArrayList getIds() { - return this.builder.ids; - } - public RedactionType getRedactionType() { return this.builder.redactionType; } - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public ArrayList getFields() { - return this.builder.fields; - } - - public String getOffset() { - return this.builder.offset; - } - - public String getLimit() { - return this.builder.limit; - } - - public Boolean getDownloadURL() { - return this.builder.downloadURL; - } - - public String getColumnName() { - return this.builder.columnName; - } - - public ArrayList getColumnValues() { - return this.builder.columnValues; - } - - public String getOrderBy() { - return this.builder.orderBy; - } - - public static final class GetRequestBuilder { - private String table; - private ArrayList ids; + public static final class GetRequestBuilder extends BaseGetRequestBuilder { private RedactionType redactionType; - private Boolean returnTokens; - private ArrayList fields; - private String offset; - private String limit; - private Boolean downloadURL; - private String columnName; - private ArrayList columnValues; - private String orderBy; private GetRequestBuilder() { + super(); this.downloadURL = true; this.orderBy = Constants.ORDER_ASCENDING; } + @Override public GetRequestBuilder table(String table) { - this.table = table; + super.table(table); return this; } + @Override public GetRequestBuilder ids(ArrayList ids) { - this.ids = ids; + super.ids(ids); return this; } @@ -93,43 +47,51 @@ public GetRequestBuilder redactionType(RedactionType redactionType) { return this; } + @Override public GetRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens; + super.returnTokens(returnTokens); return this; } + @Override public GetRequestBuilder fields(ArrayList fields) { - this.fields = fields; + super.fields(fields); return this; } + @Override public GetRequestBuilder offset(String offset) { - this.offset = offset; + super.offset(offset); return this; } + @Override public GetRequestBuilder limit(String limit) { - this.limit = limit; + super.limit(limit); return this; } + @Override public GetRequestBuilder downloadURL(Boolean downloadURL) { - this.downloadURL = downloadURL == null || downloadURL; + super.downloadURL(downloadURL); return this; } + @Override public GetRequestBuilder columnName(String columnName) { - this.columnName = columnName; + super.columnName(columnName); return this; } + @Override public GetRequestBuilder columnValues(ArrayList columnValues) { - this.columnValues = columnValues; + super.columnValues(columnValues); return this; } + @Override public GetRequestBuilder orderBy(String orderBy) { - this.orderBy = orderBy == null ? Constants.ORDER_ASCENDING : orderBy; + super.orderBy(orderBy); return this; } diff --git a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java index 54093467..01655f02 100644 --- a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -5,10 +5,11 @@ import java.util.ArrayList; import java.util.HashMap; -public class InsertRequest { +public class InsertRequest extends BaseInsertRequest { private final InsertRequestBuilder builder; private InsertRequest(InsertRequestBuilder builder) { + super(builder); this.builder = builder; } @@ -16,26 +17,6 @@ public static InsertRequestBuilder builder() { return new InsertRequestBuilder(); } - public String getTable() { - return this.builder.table; - } - - public ArrayList> getValues() { - return this.builder.values; - } - - public ArrayList> getTokens() { - return this.builder.tokens; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public String getUpsert() { - return this.builder.upsert; - } - public Boolean getHomogeneous() { return this.builder.homogeneous; } @@ -48,44 +29,44 @@ public TokenMode getTokenMode() { return this.builder.tokenMode; } - public static final class InsertRequestBuilder { - private String table; - private ArrayList> values; - private ArrayList> tokens; - private Boolean returnTokens; - private String upsert; + public static final class InsertRequestBuilder extends BaseInsertRequestBuilder { private Boolean homogeneous; private Boolean continueOnError; private TokenMode tokenMode; private InsertRequestBuilder() { - this.returnTokens = false; + super(); this.continueOnError = false; this.tokenMode = TokenMode.DISABLE; } + @Override public InsertRequestBuilder table(String table) { - this.table = table; + super.table(table); return this; } + @Override public InsertRequestBuilder values(ArrayList> values) { - this.values = values; + super.values(values); return this; } + @Override public InsertRequestBuilder tokens(ArrayList> tokens) { - this.tokens = tokens; + super.tokens(tokens); return this; } + @Override public InsertRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens != null && returnTokens; + super.returnTokens(returnTokens); return this; } + @Override public InsertRequestBuilder upsert(String upsert) { - this.upsert = upsert; + super.upsert(upsert); return this; } diff --git a/v3/pom.xml b/v3/pom.xml index 0e01c5e8..972f81b2 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -6,10 +6,11 @@ com.skyflow skyflow-java - 2.0.0-beta.2 + 1.0.0 v3 + 3.0.0-beta.0 8 diff --git a/v3/src/main/java/com/example/BulkRecordInserter.java b/v3/src/main/java/com/example/BulkRecordInserter.java new file mode 100644 index 00000000..ee7a5215 --- /dev/null +++ b/v3/src/main/java/com/example/BulkRecordInserter.java @@ -0,0 +1,107 @@ +package com.example; + +import com.skyflow.generated.rest.types.InsertRecordData; +import com.skyflow.generated.rest.types.InsertResponse; +import okhttp3.OkHttpClient; +import okhttp3.Request; + +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; + +public class BulkRecordInserter { + private final int concurrencyLimit; + private final int batchSize; + private final OkHttpClient httpClient; + + public BulkRecordInserter(int concurrencyLimit, int batchSize, String token) { + this.concurrencyLimit = concurrencyLimit; + this.batchSize = batchSize; + this.httpClient = new OkHttpClient.Builder() + .addInterceptor(chain -> { + Request original = chain.request(); + Request requestWithAuth = original.newBuilder() + .header("Authorization", "Bearer " + token) + .build(); + return chain.proceed(requestWithAuth); + }) + .build(); + } + + public void process(List records) { + List> batches = createBatches(records, batchSize); + System.out.printf("Processing %d batches with concurrency=%d...\n", batches.size(), concurrencyLimit); + List> futures = new ArrayList<>(); + AtomicInteger successCount = new AtomicInteger(); + AtomicInteger failureCount = new AtomicInteger(); + + for (int i = 0; i < batches.size(); i++) { + final int batchNumber = i + 1; + List batch = batches.get(i); + try { + System.out.println("Starting Batch " + batchNumber + + " on thread " + Thread.currentThread().getName()); + + CompletableFuture future = InsertSample2.insertData(batch, httpClient); +// .thenAccept(response -> { +//// System.out.println("Batch " + batchNumber + " completed on thread " + +//// Thread.currentThread().getName() + ": " + response); +// }) +// .exceptionally(ex -> { +//// System.err.println("Batch " + batchNumber + " failed: " + ex); +// return null; +// }) +// .whenComplete((res, ex) -> System.out.println("Batch " + batchNumber + " processing finished on thread " + +// Thread.currentThread().getName())); + futures.add(future); + } catch (Exception e) { + System.out.printf("Batch %d failed with exception: %s\n", batchNumber, e.getMessage()); + } finally { + System.out.println("Batch " + batchNumber + " processing finished on thread " + + Thread.currentThread().getName()); + } + } + + for (CompletableFuture future : futures) { + try { + InsertResponse response = future.join(); // Retrieve the result + System.out.println("Response here: " + response); + successCount.incrementAndGet(); + } catch (Exception e) { + failureCount.incrementAndGet(); + System.err.println("Error while processing future: " + e.getMessage()); + } + } + System.out.printf("All batches completed. Success=%d, Failed=%d\n", + successCount.get(), failureCount.get()); + } + + private List> createBatches(List records, int batchSize) { + List> batches = new ArrayList<>(); + for (int i = 0; i < records.size(); i += batchSize) { + batches.add(records.subList(i, Math.min(i + batchSize, records.size()))); + } + return batches; + } + + public static void main(String[] args) { + int recordsCount = 1; + int concurrency = 1; + int batchSize = 1; + + BatchProcessor processor = new BatchProcessor(concurrency, batchSize, "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2MiOiJiOTYzZTcxMjFkZDY0YTZkOTY0MGQ3ZTNlNGNjODdhNyIsImF1ZCI6Imh0dHBzOi8vbWFuYWdlLWJsaXR6LnNreWZsb3dhcGlzLmRldiIsImV4cCI6MTc1NTU5NjEwNSwiaWF0IjoxNzU1NTA5NzA1LCJpc3MiOiJzYS1hdXRoQG1hbmFnZS1ibGl0ei5za3lmbG93YXBpcy5kZXYiLCJqdGkiOiJ0NjQ2OWUyZWJlNzY0YmNiODIzZGY3ZjYwYTY1NjgyZSIsInN1YiI6ImUzMThiYjk0NzA4YjQ0MmRiZjBkMWY2MjEwYmQxMGU5In0.bhyK9y7wDvUXY1Q3UCJs_Rhv3xOfHScXBCa8-zZJ5xSd5uryBfOOjVhx4X9ZOO8vEwRAU4Ij8deBKZ08k7knXHd3MTLjkq7euKdFqIhkL1TknQkAQHhxES8FoZQuzV4_WZJejnmopZOXYviY-SeggaQTMyfoSdI3ObmLsPjkHo7InJJGwr9Jyc2eiae_4KVMFPTLw9yZVx55fJ7wa1i3VJFT_OMiiyxjVS8f6NYTjIzQtvqxh_NRMRhIMxcGoh0ZLh6yZJQzMU9sg9DBfRdrlVOMDOfGhptb38i3hodsnIw08AtOrDHdjwwHC_lqT96o8z8bUJzGW9fKZLclcAN3wg"); + List mockRecords = generateMockRecords(recordsCount); + processor.process(mockRecords); + } + + private static List generateMockRecords(int count) { + List records = new ArrayList<>(); + for (int i = 0; i < count; i++) { + Map map = new HashMap<>(); + map.put("name", "bharti"); + map.put("email", "email" + i + "@email.com"); + records.add(InsertRecordData.builder().data(map).build()); + } + return records; + } +} diff --git a/v3/src/main/java/com/skyflow/Skyflow.java b/v3/src/main/java/com/skyflow/Skyflow.java index c81326ae..2fc6d9e0 100644 --- a/v3/src/main/java/com/skyflow/Skyflow.java +++ b/v3/src/main/java/com/skyflow/Skyflow.java @@ -2,13 +2,13 @@ import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; -import com.skyflow.enums.Env; import com.skyflow.enums.LogLevel; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; +import com.skyflow.logs.WarningLogs; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; @@ -16,10 +16,11 @@ import java.util.LinkedHashMap; -public final class Skyflow { +public final class Skyflow extends BaseSkyflow { private final SkyflowClientBuilder builder; private Skyflow(SkyflowClientBuilder builder) { + super(builder); this.builder = builder; com.skyflow.utils.logger.LogUtil.printInfoLog(InfoLogs.CLIENT_INITIALIZED.getLog()); } @@ -28,14 +29,6 @@ public static SkyflowClientBuilder builder() { return new SkyflowClientBuilder(); } - public VaultConfig getVaultConfig(String vaultId) { - return this.builder.vaultConfigMap.get(vaultId); - } - - public LogLevel getLogLevel() { - return this.builder.logLevel; - } - public VaultController vault() throws SkyflowException { Object[] array = this.builder.vaultClientsMap.keySet().toArray(); if (array.length < 1) { @@ -43,10 +36,6 @@ public VaultController vault() throws SkyflowException { throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); } String vaultId = (String) array[0]; - return this.vault(vaultId); - } - - public VaultController vault(String vaultId) throws SkyflowException { VaultController controller = this.builder.vaultClientsMap.get(vaultId); if (controller == null) { LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); @@ -55,17 +44,11 @@ public VaultController vault(String vaultId) throws SkyflowException { return controller; } - public static final class SkyflowClientBuilder { + public static final class SkyflowClientBuilder extends BaseSkyflowClientBuilder { private final LinkedHashMap vaultClientsMap; - private final LinkedHashMap vaultConfigMap; - private Credentials skyflowCredentials; - private LogLevel logLevel; public SkyflowClientBuilder() { this.vaultClientsMap = new LinkedHashMap<>(); - this.vaultConfigMap = new LinkedHashMap<>(); - this.skyflowCredentials = null; - this.logLevel = LogLevel.ERROR; } public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { @@ -78,38 +61,16 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); } else { - this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); - this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); + LogUtil.printWarningLog(WarningLogs.OVERRIDING_EXISTING_VAULT_CONFIG.getLog()); + VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); + this.vaultConfigMap.clear(); // clear existing config + assert vaultConfigDeepCopy != null; + this.vaultConfigMap.put(vaultConfigDeepCopy.getVaultId(), vaultConfigDeepCopy); // add new config in map + + this.vaultClientsMap.clear(); // clear existing vault controller + this.vaultClientsMap.put(vaultConfigDeepCopy.getVaultId(), new VaultController(vaultConfigDeepCopy, this.skyflowCredentials)); // add new controller with new config LogUtil.printInfoLog(Utils.parameterizedString( InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); - } - return this; - } - - public SkyflowClientBuilder updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { - LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); - Validations.validateVaultConfig(vaultConfig); - if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { - VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfig); - this.vaultClientsMap.get(updatedConfig.getVaultId()).updateVaultConfig(); - } else { - LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultConfig.getVaultId() - )); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); - } - return this; - } - - public SkyflowClientBuilder removeVaultConfig(String vaultId) throws SkyflowException { - if (this.vaultClientsMap.containsKey(vaultId)) { - this.vaultClientsMap.remove(vaultId); - this.vaultConfigMap.remove(vaultId); - } else { - LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog(), vaultId)); - throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); } return this; } @@ -123,28 +84,14 @@ public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throw return this; } + @Override public SkyflowClientBuilder setLogLevel(LogLevel logLevel) { - this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; - LogUtil.setupLogger(this.logLevel); - LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.CURRENT_LOG_LEVEL.getLog(), String.valueOf(logLevel) - )); + super.setLogLevel(logLevel); return this; } public Skyflow build() { return new Skyflow(this); } - - private VaultConfig findAndUpdateVaultConfig(VaultConfig vaultConfig) { - VaultConfig previousConfig = this.vaultConfigMap.get(vaultConfig.getVaultId()); - Env env = vaultConfig.getEnv() != null ? vaultConfig.getEnv() : previousConfig.getEnv(); - String clusterId = vaultConfig.getClusterId() != null ? vaultConfig.getClusterId() : previousConfig.getClusterId(); - Credentials credentials = vaultConfig.getCredentials() != null ? vaultConfig.getCredentials() : previousConfig.getCredentials(); - previousConfig.setEnv(env); - previousConfig.setClusterId(clusterId); - previousConfig.setCredentials(credentials); - return previousConfig; - } } } diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 3d3a656a..b5181f07 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -5,6 +5,13 @@ import com.skyflow.VaultClient; import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; +import com.skyflow.generated.rest.types.InsertResponse; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.vault.RequestOptions; +import com.skyflow.vault.data.BaseInsertRequest; + +import java.util.concurrent.CompletableFuture; public final class VaultController extends VaultClient { private static final Gson gson = new GsonBuilder().serializeNulls().create(); @@ -14,4 +21,14 @@ public VaultController(VaultConfig vaultConfig, Credentials credentials) { } // add methods for v3 SDK + public InsertResponse bulkInsert(BaseInsertRequest insertRequest, RequestOptions requestOptions) { + InsertResponse response = null; + LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); + return response; + } + + public CompletableFuture bulkInsertAsync(BaseInsertRequest insertRequest, RequestOptions requestOptions){ + CompletableFuture future = null; + return future; + } } From 5dfc0b69f11e2e1badeaec13585793187fb3dcb2 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Thu, 21 Aug 2025 15:08:52 +0530 Subject: [PATCH 04/97] SK-2243 added insert req and res class --- .../skyflow/vault/data/BaseInsertRequest.java | 16 ++-- .../com/skyflow/vault/data/InsertRequest.java | 3 +- .../com/skyflow/vault/data/InsertRequest.java | 77 +++++++++++++++++++ .../skyflow/vault/data/InsertResponse.java | 33 ++++++++ .../java/com/skyflow/vault/data/Success.java | 42 ++++++++++ .../java/com/skyflow/vault/data/Summary.java | 31 ++++++++ .../java/com/skyflow/vault/data/Token.java | 22 ++++++ 7 files changed, 214 insertions(+), 10 deletions(-) create mode 100644 v3/src/main/java/com/skyflow/vault/data/InsertRequest.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/InsertResponse.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/Success.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/Summary.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/Token.java diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java index 64e61153..eba79af3 100644 --- a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java +++ b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; -class BaseInsertRequest { +public class BaseInsertRequest { private final BaseInsertRequestBuilder builder; protected BaseInsertRequest(BaseInsertRequestBuilder builder) { @@ -26,9 +26,9 @@ public Boolean getReturnTokens() { return this.builder.returnTokens; } - public String getUpsert() { - return this.builder.upsert; - } +// public String getUpsert() { +// return this.builder.upsert; +// } static class BaseInsertRequestBuilder { protected String table; @@ -61,10 +61,10 @@ public BaseInsertRequestBuilder returnTokens(Boolean returnTokens) { return this; } - public BaseInsertRequestBuilder upsert(String upsert) { - this.upsert = upsert; - return this; - } +// public BaseInsertRequestBuilder upsert(String upsert) { +// this.upsert = upsert; +// return this; +// } } } diff --git a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java index 01655f02..025b4572 100644 --- a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -64,9 +64,8 @@ public InsertRequestBuilder returnTokens(Boolean returnTokens) { return this; } - @Override public InsertRequestBuilder upsert(String upsert) { - super.upsert(upsert); + this.upsert = upsert; return this; } diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java new file mode 100644 index 00000000..2063799b --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -0,0 +1,77 @@ +package com.skyflow.vault.data; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class InsertRequest extends BaseInsertRequest { + private final InsertRequestBuilder builder; + + private InsertRequest(InsertRequestBuilder builder) { + super(builder); + this.builder = builder; + } + + public static InsertRequestBuilder builder() { + return new InsertRequestBuilder(); + } + + public Boolean getReturnData() { + return this.builder.returnData; + } + public List getUpsert() { + return this.builder.upsert; + } + public String getUpsertType() { + return this.builder.upsertType; + } + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public static final class InsertRequestBuilder extends BaseInsertRequestBuilder { + private Boolean returnData; + private List upsert; + + private String upsertType; + + private InsertRequestBuilder() { + super(); + this.returnData = false; + } + + @Override + public InsertRequestBuilder table(String table) { + super.table(table); + return this; + } + + @Override + public InsertRequestBuilder values(ArrayList> values) { + super.values(values); + return this; + } + + public InsertRequestBuilder upsert(List upsert) { + this.upsert = upsert; + return this; + } + public InsertRequestBuilder upsertType(String upsertType) { + this.upsertType = upsertType; + return this; + } + @Override + public InsertRequestBuilder returnTokens(Boolean returnTokens) { + super.returnTokens(returnTokens); + return this; + } + + public InsertRequestBuilder returnData(Boolean returnData) { + this.returnData = returnData; + return this; + } + public InsertRequest build() { + return new InsertRequest(this); + } + } +} diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java new file mode 100644 index 00000000..7bdda1f2 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -0,0 +1,33 @@ +package com.skyflow.vault.data; + +import java.util.List; + +public class InsertResponse { + private Summary summary; + private List success; + private List errors; + + public Summary getSummary() { + return summary; + } + + public void setSummary(Summary summary) { + this.summary = summary; + } + + public List getSuccess() { + return success; + } + + public void setSuccess(List success) { + this.success = success; + } + + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/Success.java b/v3/src/main/java/com/skyflow/vault/data/Success.java new file mode 100644 index 00000000..ed71e0db --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/Success.java @@ -0,0 +1,42 @@ +package com.skyflow.vault.data; +import java.util.List; +import java.util.Map; + +public class Success { + private String index; + private String skyflow_id; + private Map> tokens; + private Map data; + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public String getSkyflowId() { + return skyflow_id; + } + + public void setSkyflowId(String skyflow_id) { + this.skyflow_id = skyflow_id; + } + + public Map> getTokens() { + return tokens; + } + + public void setTokens(Map> tokens) { + this.tokens = tokens; + } + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } +} \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/Summary.java b/v3/src/main/java/com/skyflow/vault/data/Summary.java new file mode 100644 index 00000000..fe34e536 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/Summary.java @@ -0,0 +1,31 @@ +package com.skyflow.vault.data; + +public class Summary { + private int total_records; + private int total_inserted; + private int total_failed; + + public int getTotalRecords() { + return total_records; + } + + public void setTotalRecords(int total_records) { + this.total_records = total_records; + } + + public int getTotalInserted() { + return total_inserted; + } + + public void setTotalInserted(int total_inserted) { + this.total_inserted = total_inserted; + } + + public int getTotalFailed() { + return total_failed; + } + + public void setTotalFailed(int total_failed) { + this.total_failed = total_failed; + } +} \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/Token.java b/v3/src/main/java/com/skyflow/vault/data/Token.java new file mode 100644 index 00000000..cde8cb97 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/Token.java @@ -0,0 +1,22 @@ +package com.skyflow.vault.data; + +public class Token { + private String token; + private String tokenGroupName; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getTokenGroupName() { + return tokenGroupName; + } + + public void setTokenGroupName(String tokenGroupName) { + this.tokenGroupName = tokenGroupName; + } +} \ No newline at end of file From a55aed1eb9477978b203f03722150a23080770c8 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Thu, 21 Aug 2025 15:23:13 +0530 Subject: [PATCH 05/97] SK-2258 error class added --- .../com/skyflow/vault/data/ErrorRecord.java | 22 +++++++++++++++++++ .../skyflow/vault/data/InsertResponse.java | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java diff --git a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java new file mode 100644 index 00000000..89091f55 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java @@ -0,0 +1,22 @@ +package com.skyflow.vault.data; + +public class ErrorRecord { + private String index; + private String error; + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } +} \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 7bdda1f2..f9007955 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -5,7 +5,7 @@ public class InsertResponse { private Summary summary; private List success; - private List errors; + private List errors; public Summary getSummary() { return summary; From df379b729299bb93f9360f714e7c664996ed31d7 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Fri, 22 Aug 2025 20:02:12 +0530 Subject: [PATCH 06/97] SK-2259 Added Immutable Skyflow client for V3 - Fixed some errors in overall project - Updated POM configuration --- .../java/com/skyflow/config/Credentials.java | 11 +- .../java/com/skyflow/config/VaultConfig.java | 13 +- .../java/com/skyflow/utils/BaseUtils.java | 24 +--- .../com/skyflow/vault/RequestOptions.java | 37 ------ .../com/skyflow/vault/data/DeleteRequest.java | 45 ------- .../skyflow/vault/data/DeleteResponse.java | 27 ---- .../com/skyflow/vault/data/QueryRequest.java | 33 ----- .../com/skyflow/vault/data/QueryResponse.java | 32 ----- .../com/skyflow/vault/data/UpdateRequest.java | 67 ---------- .../skyflow/vault/data/UpdateResponse.java | 39 ------ .../com/skyflow/vault/tokens/ColumnValue.java | 45 ------- .../skyflow/vault/tokens/DetokenizeData.java | 14 -- .../tokens/DetokenizeRecordResponse.java | 54 -------- .../vault/tokens/DetokenizeRequest.java | 57 --------- .../vault/tokens/DetokenizeResponse.java | 29 ----- .../skyflow/vault/tokens/TokenizeRequest.java | 35 ----- .../vault/tokens/TokenizeResponse.java | 33 ----- v2/pom.xml | 30 ++++- .../com/example/ConcurrentBatchProcessor.java | 120 ------------------ v2/src/main/java/com/skyflow/Skyflow.java | 17 +-- v3/pom.xml | 30 ++++- .../java/com/example/BulkRecordInserter.java | 107 ---------------- v3/src/main/java/com/skyflow/Skyflow.java | 31 +++-- v3/test/java/com/skyflow/SkyflowTests.java | 92 ++++++++++++++ v3/v3.iml | 8 ++ 25 files changed, 200 insertions(+), 830 deletions(-) delete mode 100644 common/src/main/java/com/skyflow/vault/RequestOptions.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/DeleteRequest.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/DeleteResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/QueryRequest.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/QueryResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/UpdateRequest.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/UpdateResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java delete mode 100644 v2/src/main/java/com/example/ConcurrentBatchProcessor.java delete mode 100644 v3/src/main/java/com/example/BulkRecordInserter.java create mode 100644 v3/test/java/com/skyflow/SkyflowTests.java create mode 100644 v3/v3.iml diff --git a/common/src/main/java/com/skyflow/config/Credentials.java b/common/src/main/java/com/skyflow/config/Credentials.java index f1865dc7..7f2d6c8c 100644 --- a/common/src/main/java/com/skyflow/config/Credentials.java +++ b/common/src/main/java/com/skyflow/config/Credentials.java @@ -2,7 +2,7 @@ import java.util.ArrayList; -public class Credentials { +public class Credentials implements Cloneable { private String path; private ArrayList roles; private String context; @@ -63,4 +63,13 @@ public String getApiKey() { public void setApiKey(String apiKey) { this.apiKey = apiKey; } + + @Override + public Object clone() throws CloneNotSupportedException { + Credentials cloned = (Credentials) super.clone(); + if (this.roles != null) { + cloned.roles = new ArrayList<>(this.roles); + } + return cloned; + } } diff --git a/common/src/main/java/com/skyflow/config/VaultConfig.java b/common/src/main/java/com/skyflow/config/VaultConfig.java index 7e660373..8797e2bd 100644 --- a/common/src/main/java/com/skyflow/config/VaultConfig.java +++ b/common/src/main/java/com/skyflow/config/VaultConfig.java @@ -2,9 +2,7 @@ import com.skyflow.enums.Env; -import java.io.Serializable; - -public class VaultConfig implements Serializable { +public class VaultConfig implements Cloneable { private String vaultId; private String clusterId; private Env env; @@ -48,4 +46,13 @@ public Credentials getCredentials() { public void setCredentials(Credentials credentials) { this.credentials = credentials; } + + @Override + public Object clone() throws CloneNotSupportedException { + VaultConfig cloned = (VaultConfig) super.clone(); + if (this.credentials != null) { + cloned.credentials = (Credentials) this.credentials.clone(); + } + return cloned; + } } diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index c1049f9a..263220dd 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -10,7 +10,7 @@ import com.skyflow.utils.logger.LogUtil; import org.apache.commons.codec.binary.Base64; -import java.io.*; +import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.security.KeyFactory; @@ -112,26 +112,4 @@ private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws Skyflow return privateKey; } - public static T deepCopy(T obj) { - try { - // Serialize the object to a byte array - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(obj); - oos.close(); - bos.close(); - - // Deserialize the byte array back to a new object - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - ObjectInputStream ois = new ObjectInputStream(bis); - T copiedObj = (T) ois.readObject(); - ois.close(); - bis.close(); - - return copiedObj; - } catch (IOException | ClassNotFoundException e) { - e.printStackTrace(); - return null; - } - } } diff --git a/common/src/main/java/com/skyflow/vault/RequestOptions.java b/common/src/main/java/com/skyflow/vault/RequestOptions.java deleted file mode 100644 index 0855e175..00000000 --- a/common/src/main/java/com/skyflow/vault/RequestOptions.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.skyflow.vault; - -public class RequestOptions { - public RequestOptionsBuilder builder; - - public static RequestOptionsBuilder builder() { - return new RequestOptionsBuilder(); - } - - public int getBatchSize() { - return this.builder.batchSize; - } - - public int getConcurrencyLimit() { - return this.builder.concurrencyLimit; - } - - public static class RequestOptionsBuilder { - private int batchSize; - private int concurrencyLimit; - - private RequestOptionsBuilder() { - this.batchSize = 100; - this.concurrencyLimit = 1; - } - - public RequestOptionsBuilder batchSize(int batchSize) { - this.batchSize = batchSize; - return this; - } - - public RequestOptionsBuilder concurrencyLimit(int concurrencyLimit) { - this.concurrencyLimit = concurrencyLimit; - return this; - } - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/DeleteRequest.java b/common/src/main/java/com/skyflow/vault/data/DeleteRequest.java deleted file mode 100644 index d61c996f..00000000 --- a/common/src/main/java/com/skyflow/vault/data/DeleteRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.skyflow.vault.data; - -import java.util.ArrayList; - -public class DeleteRequest { - private final DeleteRequestBuilder builder; - - private DeleteRequest(DeleteRequestBuilder builder) { - this.builder = builder; - } - - public static DeleteRequestBuilder builder() { - return new DeleteRequestBuilder(); - } - - public String getTable() { - return this.builder.table; - } - - public ArrayList getIds() { - return this.builder.ids; - } - - public static final class DeleteRequestBuilder { - private String table; - private ArrayList ids; - - private DeleteRequestBuilder() { - } - - public DeleteRequestBuilder table(String table) { - this.table = table; - return this; - } - - public DeleteRequestBuilder ids(ArrayList ids) { - this.ids = ids; - return this; - } - - public DeleteRequest build() { - return new DeleteRequest(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/DeleteResponse.java b/common/src/main/java/com/skyflow/vault/data/DeleteResponse.java deleted file mode 100644 index f34d219a..00000000 --- a/common/src/main/java/com/skyflow/vault/data/DeleteResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.List; - -public class DeleteResponse { - private final List deletedIds; - - public DeleteResponse(List deletedIds) { - this.deletedIds = deletedIds; - } - - public List getDeletedIds() { - return deletedIds; - } - - @Override - public String toString() { - Gson gson = new Gson(); - JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); - responseObject.add("errors", null); - return responseObject.toString(); - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/QueryRequest.java b/common/src/main/java/com/skyflow/vault/data/QueryRequest.java deleted file mode 100644 index 2aaa200d..00000000 --- a/common/src/main/java/com/skyflow/vault/data/QueryRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.skyflow.vault.data; - -public class QueryRequest { - private final QueryRequestBuilder builder; - - private QueryRequest(QueryRequestBuilder builder) { - this.builder = builder; - } - - public static QueryRequestBuilder builder() { - return new QueryRequestBuilder(); - } - - public String getQuery() { - return this.builder.query; - } - - public static final class QueryRequestBuilder { - private String query; - - private QueryRequestBuilder() { - } - - public QueryRequestBuilder query(String query) { - this.query = query; - return this; - } - - public QueryRequest build() { - return new QueryRequest(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/QueryResponse.java b/common/src/main/java/com/skyflow/vault/data/QueryResponse.java deleted file mode 100644 index 7a1bca51..00000000 --- a/common/src/main/java/com/skyflow/vault/data/QueryResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.*; - -import java.util.ArrayList; -import java.util.HashMap; - -public class QueryResponse { - private final ArrayList> fields; - private ArrayList> tokenizedData; - - public QueryResponse(ArrayList> fields) { - this.fields = fields; - } - - public ArrayList> getFields() { - return fields; - } - - @Override - public String toString() { - Gson gson = new GsonBuilder().serializeNulls().create(); - JsonObject responseObject = gson.toJsonTree(this).getAsJsonObject(); - JsonArray fieldsArray = responseObject.get("fields").getAsJsonArray(); - for (JsonElement fieldElement : fieldsArray) { - fieldElement.getAsJsonObject().add("tokenizedData", new JsonObject()); - } - responseObject.add("errors", null); - responseObject.remove("tokenizedData"); - return responseObject.toString(); - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/UpdateRequest.java b/common/src/main/java/com/skyflow/vault/data/UpdateRequest.java deleted file mode 100644 index ac88b18b..00000000 --- a/common/src/main/java/com/skyflow/vault/data/UpdateRequest.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.skyflow.vault.data; - -import java.util.HashMap; - -public class UpdateRequest { - private final UpdateRequestBuilder builder; - - private UpdateRequest(UpdateRequestBuilder builder) { - this.builder = builder; - } - - public static UpdateRequestBuilder builder() { - return new UpdateRequestBuilder(); - } - - public String getTable() { - return this.builder.table; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public HashMap getData() { - return this.builder.data; - } - - public HashMap getTokens() { - return this.builder.tokens; - } - - - public static final class UpdateRequestBuilder { - private String table; - private Boolean returnTokens; - private HashMap data; - private HashMap tokens; - - private UpdateRequestBuilder() { - this.returnTokens = false; - } - - public UpdateRequestBuilder table(String table) { - this.table = table; - return this; - } - - public UpdateRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens != null && returnTokens; - return this; - } - - public UpdateRequestBuilder data(HashMap data) { - this.data = data; - return this; - } - - public UpdateRequestBuilder tokens(HashMap tokens) { - this.tokens = tokens; - return this; - } - - public UpdateRequest build() { - return new UpdateRequest(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/UpdateResponse.java b/common/src/main/java/com/skyflow/vault/data/UpdateResponse.java deleted file mode 100644 index b1013cb9..00000000 --- a/common/src/main/java/com/skyflow/vault/data/UpdateResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.HashMap; - -public class UpdateResponse { - private final String skyflowId; - private final HashMap tokens; - - public UpdateResponse(String skyflowId, HashMap tokens) { - this.skyflowId = skyflowId; - this.tokens = tokens; - } - - public String getSkyflowId() { - return skyflowId; - } - - public HashMap getTokens() { - return tokens; - } - - @Override - public String toString() { - Gson gson = new Gson(); - JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); - JsonObject tokensObject = responseObject.remove("tokens").getAsJsonObject(); - for (String key : tokensObject.keySet()) { - responseObject.add(key, tokensObject.get(key)); - } - JsonObject finalResponseObject = new JsonObject(); - finalResponseObject.add("updatedField", responseObject); - finalResponseObject.add("errors", null); - return finalResponseObject.toString(); - } -} diff --git a/common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java b/common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java deleted file mode 100644 index 3fa08b2e..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/ColumnValue.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.skyflow.vault.tokens; - -public class ColumnValue { - - private final ColumnValueBuilder builder; - - private ColumnValue(ColumnValueBuilder builder) { - this.builder = builder; - } - - public static ColumnValueBuilder builder() { - return new ColumnValueBuilder(); - } - - public String getValue() { - return this.builder.value; - } - - public String getColumnGroup() { - return this.builder.columnGroup; - } - - public static final class ColumnValueBuilder { - private String value; - private String columnGroup; - - private ColumnValueBuilder() { - } - - public ColumnValueBuilder value(String value) { - this.value = value; - return this; - } - - public ColumnValueBuilder columnGroup(String columnGroup) { - this.columnGroup = columnGroup; - return this; - } - - public ColumnValue build() { - return new ColumnValue(this); - } - } - -} diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java deleted file mode 100644 index c42abff6..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeData.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.skyflow.vault.tokens; - -public class DetokenizeData { - private final String token; - - public DetokenizeData(String token) { - this.token = token; - } - - public String getToken() { - return this.token; - } - -} diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java deleted file mode 100644 index 7d2ae73c..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.skyflow.vault.tokens; - - -import com.skyflow.generated.rest.types.V1DetokenizeRecordResponse; - -public class DetokenizeRecordResponse { - private final String token; - private final String value; - private final String type; - private final String error; - private final String requestId; - - public DetokenizeRecordResponse(V1DetokenizeRecordResponse record) { - this(record, null); - } - - public DetokenizeRecordResponse(V1DetokenizeRecordResponse record, String requestId) { - this.token = record.getToken().orElse(null); - - this.value = record.getValue() - .filter(val -> val != null && !val.toString().isEmpty()) - .orElse(null); - - this.type = record.getValueType() - .map(Enum::toString) - .filter(val -> !"NONE".equals(val)) - .orElse(null); - - this.error = record.getError().orElse(null); - - this.requestId = requestId; - } - - - public String getError() { - return error; - } - - public String getToken() { - return token; - } - - public String getValue() { - return value; - } - - public String getType() { - return type; - } - - public String getRequestId() { - return requestId; - } -} \ No newline at end of file diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java deleted file mode 100644 index 186a18d2..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRequest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.skyflow.vault.tokens; - -import java.util.ArrayList; - -public class DetokenizeRequest { - private final DetokenizeRequestBuilder builder; - - private DetokenizeRequest(DetokenizeRequestBuilder builder) { - this.builder = builder; - } - - public static DetokenizeRequestBuilder builder() { - return new DetokenizeRequestBuilder(); - } - - public ArrayList getDetokenizeData() { - return this.builder.detokenizeData; - } - - public Boolean getContinueOnError() { - return this.builder.continueOnError; - } - - public Boolean getDownloadURL() { - return this.builder.downloadURL; - } - - public static final class DetokenizeRequestBuilder { - private ArrayList detokenizeData; - private Boolean continueOnError; - private Boolean downloadURL; - - private DetokenizeRequestBuilder() { - this.continueOnError = false; - this.downloadURL = false; - } - - public DetokenizeRequestBuilder detokenizeData(ArrayList detokenizeData) { - this.detokenizeData = detokenizeData; - return this; - } - - public DetokenizeRequestBuilder continueOnError(Boolean continueOnError) { - this.continueOnError = continueOnError != null && continueOnError; - return this; - } - - public DetokenizeRequestBuilder downloadURL(Boolean downloadURL) { - this.downloadURL = downloadURL; - return this; - } - - public DetokenizeRequest build() { - return new DetokenizeRequest(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java deleted file mode 100644 index 31ff64b2..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.skyflow.vault.tokens; - -import com.google.gson.Gson; - -import java.util.ArrayList; - -public class DetokenizeResponse { - private final ArrayList detokenizedFields; - private final ArrayList errors; - - public DetokenizeResponse(ArrayList detokenizedFields, ArrayList errors) { - this.detokenizedFields = detokenizedFields; - this.errors = errors; - } - - public ArrayList getDetokenizedFields() { - return detokenizedFields; - } - - public ArrayList getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java b/common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java deleted file mode 100644 index 8f6da5d9..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/TokenizeRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.skyflow.vault.tokens; - -import java.util.List; - -public class TokenizeRequest { - private final TokenizeRequestBuilder builder; - - private TokenizeRequest(TokenizeRequestBuilder builder) { - this.builder = builder; - } - - public static TokenizeRequestBuilder builder() { - return new TokenizeRequestBuilder(); - } - - public List getColumnValues() { - return this.builder.columnValues; - } - - public static final class TokenizeRequestBuilder { - private List columnValues; - - private TokenizeRequestBuilder() { - } - - public TokenizeRequestBuilder values(List columnValues) { - this.columnValues = columnValues; - return this; - } - - public TokenizeRequest build() { - return new TokenizeRequest(this); - } - } -} diff --git a/common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java b/common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java deleted file mode 100644 index d8d8072b..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/TokenizeResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.skyflow.vault.tokens; - -import com.google.gson.*; - -import java.util.List; - -public class TokenizeResponse { - private final List tokens; - - public TokenizeResponse(List tokens) { - this.tokens = tokens; - } - - public List getTokens() { - return tokens; - } - - @Override - public String toString() { - Gson gson = new Gson(); - JsonObject responseObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject(); - JsonArray tokensArray = responseObject.remove("tokens").getAsJsonArray(); - JsonArray newTokensArray = new JsonArray(); - for (JsonElement token : tokensArray) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("token", token.getAsString()); - newTokensArray.add(jsonObject); - } - responseObject.add("tokens", newTokensArray); - responseObject.add("errors", null); - return responseObject.toString(); - } -} diff --git a/v2/pom.xml b/v2/pom.xml index 294d6df0..943b7c80 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -7,10 +7,12 @@ com.skyflow skyflow-java 1.0.0 + ../pom.xml - v2 + skyflow-java 2.0.0-beta.2 + jar 8 @@ -24,6 +26,30 @@ common 1.0.0 - + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + com.skyflow:common + + + + + + + + \ No newline at end of file diff --git a/v2/src/main/java/com/example/ConcurrentBatchProcessor.java b/v2/src/main/java/com/example/ConcurrentBatchProcessor.java deleted file mode 100644 index 1cc46d9f..00000000 --- a/v2/src/main/java/com/example/ConcurrentBatchProcessor.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.example; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.*; - -public class ConcurrentBatchProcessor { - - // A static executor to be shared by all methods in the class - private static ExecutorService executor; - - // --- Main Method to demonstrate the functionality --- - public static void main(String[] args) { - // Define the parameters for the batch processing - int totalRecords = 1000; // L: Total number of records to process - int batchSize = 50; // M: Size of each batch - int concurrencyLimit = 5; // N: Maximum number of concurrent calls - - // Create a list of dummy records (e.g., strings) - List allRecords = new ArrayList<>(); - for (int i = 1; i <= totalRecords; i++) { - allRecords.add("Record-" + i); - } - - System.out.println("Starting batch processing for " + allRecords.size() + " records."); - System.out.println("Batch Size (M): " + batchSize); - System.out.println("Concurrency Limit (N): " + concurrencyLimit); - - try { - processRecordsInBatches(allRecords, batchSize, concurrencyLimit); - } catch (InterruptedException | ExecutionException e) { - System.err.println("Processing failed due to an exception: " + e.getMessage()); - e.printStackTrace(); - } - System.out.println("All batches have been processed."); - } - - // --- Core logic for concurrent batch processing --- - - /** - * Chunks a list of records and processes each batch concurrently. - * - * @param records The list of all records (L) to be processed. - * @param batchSize The number of records in each batch (M). - * @param concurrencyLimit The maximum number of concurrent calls (N). - * @throws InterruptedException if the thread is interrupted while waiting. - * @throws ExecutionException if a task failed to complete. - */ - public static void processRecordsInBatches(List records, int batchSize, int concurrencyLimit) - throws InterruptedException, ExecutionException { - - // Initialize the shared fixed-size thread pool - executor = Executors.newFixedThreadPool(concurrencyLimit); - - // List to hold all the futures for each batch - List> futures = new ArrayList<>(); - - // Loop through the records to create batches -// 1st itr -> i=0 bs=10 ei=10 -// 2nd itr -> i=10 bs=10 ei=20 - - int counter = 0; - for (int i = 0; i < records.size(); i += batchSize) { - int endIndex = Math.min(i + batchSize, records.size()); - List batch = records.subList(i, endIndex); - int batchId = counter + 1; - - // Submit the batch processing task using CompletableFuture.supplyAsync() - // This is where we create the CompletableFuture and pass the executor. - - CompletableFuture future = CompletableFuture - .supplyAsync(() -> performApiCall(batch, batchId), executor) - .whenComplete((resp, ex) -> System.out.printf("Batch %d End Time:\t%s for thread %s\n", batchId, System.currentTimeMillis(), Thread.currentThread().getName()) - ); - futures.add(future); - counter++; - } - - // Wait for all submitted tasks to complete. - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); - - // Optional: Process the results if needed. - System.out.println("All batches completed. Here are the results:"); - for (CompletableFuture future : futures) { - // get() blocks until the future is complete. - System.out.println(future.get()); - } - - // Shut down the executor gracefully - executor.shutdown(); - if (!executor.awaitTermination(60, TimeUnit.SECONDS)) { - System.err.println("Executor did not terminate in the specified time."); - } - } - - // --- Placeholder method to simulate a synchronous API call --- - - /** - * Simulates a synchronous, blocking API call with a batch of records. - * This method does not return a CompletableFuture and doesn't need to know about the executor. - * - * @param batch The list of records for a single API call. - * @return A success message string. - */ - private static String performApiCall(List batch, int batchId) { - // Simulate a network call delay - try { - System.out.printf("Batch %d Start Time:\t%s for thread %s\n", batchId, System.currentTimeMillis(), Thread.currentThread().getName()); - long processingTime = (long) (Math.random() * 2000) + 500; // 0.5 to 2.5 seconds - Thread.sleep(processingTime); - String result = "Successfully processed batch of " + batch.size() + - " records, starting with " + batch.get(0) + - " (simulated duration: " + processingTime + "ms)"; - return result; - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new IllegalStateException("API call was interrupted.", e); - } - } -} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/Skyflow.java b/v2/src/main/java/com/skyflow/Skyflow.java index 4bddb9b3..e623d127 100644 --- a/v2/src/main/java/com/skyflow/Skyflow.java +++ b/v2/src/main/java/com/skyflow/Skyflow.java @@ -141,10 +141,7 @@ public static final class SkyflowClientBuilder extends BaseSkyflowClientBuilder private final LinkedHashMap connectionsMap; private final LinkedHashMap vaultClientsMap; private final LinkedHashMap detectClientsMap; - // private final LinkedHashMap vaultConfigMap; private final LinkedHashMap connectionConfigMap; -// private Credentials skyflowCredentials; -// private LogLevel logLevel; public SkyflowClientBuilder() { super(); @@ -164,11 +161,9 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); } else { - VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); - assert vaultConfigDeepCopy != null; - this.vaultConfigMap.put(vaultConfigDeepCopy.getVaultId(), vaultConfigDeepCopy); - this.vaultClientsMap.put(vaultConfigDeepCopy.getVaultId(), new VaultController(vaultConfigDeepCopy, this.skyflowCredentials)); - this.detectClientsMap.put(vaultConfigDeepCopy.getVaultId(), new DetectController(vaultConfigDeepCopy, this.skyflowCredentials)); + this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); + this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); + this.detectClientsMap.put(vaultConfig.getVaultId(), new DetectController(vaultConfig, this.skyflowCredentials)); LogUtil.printInfoLog(Utils.parameterizedString( InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); LogUtil.printInfoLog(Utils.parameterizedString( @@ -180,10 +175,8 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl public SkyflowClientBuilder updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException { LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); Validations.validateVaultConfig(vaultConfig); - VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); - assert vaultConfigDeepCopy != null; - if (this.vaultClientsMap.containsKey(vaultConfigDeepCopy.getVaultId())) { - VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfigDeepCopy); + if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { + VaultConfig updatedConfig = findAndUpdateVaultConfig(vaultConfig); this.vaultClientsMap.get(updatedConfig.getVaultId()).updateVaultConfig(); } else { LogUtil.printErrorLog(Utils.parameterizedString( diff --git a/v3/pom.xml b/v3/pom.xml index 972f81b2..a2ba27a5 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -7,10 +7,12 @@ com.skyflow skyflow-java 1.0.0 + ../pom.xml - v3 + skyflow-java 3.0.0-beta.0 + jar 8 @@ -18,7 +20,6 @@ UTF-8 - com.skyflow @@ -26,4 +27,29 @@ 1.0.0 + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + com.skyflow:common + + + + + + + + \ No newline at end of file diff --git a/v3/src/main/java/com/example/BulkRecordInserter.java b/v3/src/main/java/com/example/BulkRecordInserter.java deleted file mode 100644 index ee7a5215..00000000 --- a/v3/src/main/java/com/example/BulkRecordInserter.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.example; - -import com.skyflow.generated.rest.types.InsertRecordData; -import com.skyflow.generated.rest.types.InsertResponse; -import okhttp3.OkHttpClient; -import okhttp3.Request; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; - -public class BulkRecordInserter { - private final int concurrencyLimit; - private final int batchSize; - private final OkHttpClient httpClient; - - public BulkRecordInserter(int concurrencyLimit, int batchSize, String token) { - this.concurrencyLimit = concurrencyLimit; - this.batchSize = batchSize; - this.httpClient = new OkHttpClient.Builder() - .addInterceptor(chain -> { - Request original = chain.request(); - Request requestWithAuth = original.newBuilder() - .header("Authorization", "Bearer " + token) - .build(); - return chain.proceed(requestWithAuth); - }) - .build(); - } - - public void process(List records) { - List> batches = createBatches(records, batchSize); - System.out.printf("Processing %d batches with concurrency=%d...\n", batches.size(), concurrencyLimit); - List> futures = new ArrayList<>(); - AtomicInteger successCount = new AtomicInteger(); - AtomicInteger failureCount = new AtomicInteger(); - - for (int i = 0; i < batches.size(); i++) { - final int batchNumber = i + 1; - List batch = batches.get(i); - try { - System.out.println("Starting Batch " + batchNumber + - " on thread " + Thread.currentThread().getName()); - - CompletableFuture future = InsertSample2.insertData(batch, httpClient); -// .thenAccept(response -> { -//// System.out.println("Batch " + batchNumber + " completed on thread " + -//// Thread.currentThread().getName() + ": " + response); -// }) -// .exceptionally(ex -> { -//// System.err.println("Batch " + batchNumber + " failed: " + ex); -// return null; -// }) -// .whenComplete((res, ex) -> System.out.println("Batch " + batchNumber + " processing finished on thread " + -// Thread.currentThread().getName())); - futures.add(future); - } catch (Exception e) { - System.out.printf("Batch %d failed with exception: %s\n", batchNumber, e.getMessage()); - } finally { - System.out.println("Batch " + batchNumber + " processing finished on thread " + - Thread.currentThread().getName()); - } - } - - for (CompletableFuture future : futures) { - try { - InsertResponse response = future.join(); // Retrieve the result - System.out.println("Response here: " + response); - successCount.incrementAndGet(); - } catch (Exception e) { - failureCount.incrementAndGet(); - System.err.println("Error while processing future: " + e.getMessage()); - } - } - System.out.printf("All batches completed. Success=%d, Failed=%d\n", - successCount.get(), failureCount.get()); - } - - private List> createBatches(List records, int batchSize) { - List> batches = new ArrayList<>(); - for (int i = 0; i < records.size(); i += batchSize) { - batches.add(records.subList(i, Math.min(i + batchSize, records.size()))); - } - return batches; - } - - public static void main(String[] args) { - int recordsCount = 1; - int concurrency = 1; - int batchSize = 1; - - BatchProcessor processor = new BatchProcessor(concurrency, batchSize, "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2MiOiJiOTYzZTcxMjFkZDY0YTZkOTY0MGQ3ZTNlNGNjODdhNyIsImF1ZCI6Imh0dHBzOi8vbWFuYWdlLWJsaXR6LnNreWZsb3dhcGlzLmRldiIsImV4cCI6MTc1NTU5NjEwNSwiaWF0IjoxNzU1NTA5NzA1LCJpc3MiOiJzYS1hdXRoQG1hbmFnZS1ibGl0ei5za3lmbG93YXBpcy5kZXYiLCJqdGkiOiJ0NjQ2OWUyZWJlNzY0YmNiODIzZGY3ZjYwYTY1NjgyZSIsInN1YiI6ImUzMThiYjk0NzA4YjQ0MmRiZjBkMWY2MjEwYmQxMGU5In0.bhyK9y7wDvUXY1Q3UCJs_Rhv3xOfHScXBCa8-zZJ5xSd5uryBfOOjVhx4X9ZOO8vEwRAU4Ij8deBKZ08k7knXHd3MTLjkq7euKdFqIhkL1TknQkAQHhxES8FoZQuzV4_WZJejnmopZOXYviY-SeggaQTMyfoSdI3ObmLsPjkHo7InJJGwr9Jyc2eiae_4KVMFPTLw9yZVx55fJ7wa1i3VJFT_OMiiyxjVS8f6NYTjIzQtvqxh_NRMRhIMxcGoh0ZLh6yZJQzMU9sg9DBfRdrlVOMDOfGhptb38i3hodsnIw08AtOrDHdjwwHC_lqT96o8z8bUJzGW9fKZLclcAN3wg"); - List mockRecords = generateMockRecords(recordsCount); - processor.process(mockRecords); - } - - private static List generateMockRecords(int count) { - List records = new ArrayList<>(); - for (int i = 0; i < count; i++) { - Map map = new HashMap<>(); - map.put("name", "bharti"); - map.put("email", "email" + i + "@email.com"); - records.add(InsertRecordData.builder().data(map).build()); - } - return records; - } -} diff --git a/v3/src/main/java/com/skyflow/Skyflow.java b/v3/src/main/java/com/skyflow/Skyflow.java index 2fc6d9e0..ff5a2de5 100644 --- a/v3/src/main/java/com/skyflow/Skyflow.java +++ b/v3/src/main/java/com/skyflow/Skyflow.java @@ -8,7 +8,6 @@ import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; -import com.skyflow.logs.WarningLogs; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; @@ -54,30 +53,36 @@ public SkyflowClientBuilder() { public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws SkyflowException { LogUtil.printInfoLog(InfoLogs.VALIDATING_VAULT_CONFIG.getLog()); Validations.validateVaultConfig(vaultConfig); - if (this.vaultClientsMap.containsKey(vaultConfig.getVaultId())) { + VaultConfig vaultConfigCopy; + try { + vaultConfigCopy = (VaultConfig) vaultConfig.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + if (!this.vaultClientsMap.isEmpty()) { LogUtil.printErrorLog(Utils.parameterizedString( - ErrorLogs.VAULT_CONFIG_EXISTS.getLog(), vaultConfig.getVaultId() + ErrorLogs.VAULT_CONFIG_EXISTS.getLog(), vaultConfigCopy.getVaultId() )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); } else { - LogUtil.printWarningLog(WarningLogs.OVERRIDING_EXISTING_VAULT_CONFIG.getLog()); - VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); - this.vaultConfigMap.clear(); // clear existing config - assert vaultConfigDeepCopy != null; - this.vaultConfigMap.put(vaultConfigDeepCopy.getVaultId(), vaultConfigDeepCopy); // add new config in map - - this.vaultClientsMap.clear(); // clear existing vault controller - this.vaultClientsMap.put(vaultConfigDeepCopy.getVaultId(), new VaultController(vaultConfigDeepCopy, this.skyflowCredentials)); // add new controller with new config + this.vaultConfigMap.put(vaultConfigCopy.getVaultId(), vaultConfigCopy); // add new config in map + this.vaultClientsMap.put(vaultConfigCopy.getVaultId(), new VaultController(vaultConfigCopy, this.skyflowCredentials)); // add new controller with new config LogUtil.printInfoLog(Utils.parameterizedString( - InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); + InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfigCopy.getVaultId())); } return this; } public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throws SkyflowException { Validations.validateCredentials(credentials); - this.skyflowCredentials = credentials; + Credentials credentialsCopy; + try { + credentialsCopy = (Credentials) credentials.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + this.skyflowCredentials = credentialsCopy; for (VaultController vault : this.vaultClientsMap.values()) { vault.setCommonCredentials(this.skyflowCredentials); } diff --git a/v3/test/java/com/skyflow/SkyflowTests.java b/v3/test/java/com/skyflow/SkyflowTests.java new file mode 100644 index 00000000..c003e5e9 --- /dev/null +++ b/v3/test/java/com/skyflow/SkyflowTests.java @@ -0,0 +1,92 @@ +package com.skyflow; + +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.Env; +import com.skyflow.enums.LogLevel; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class SkyflowTests { + 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 vaultID = null; + private static String clusterID = null; + private static String newClusterID = null; + private static String token = null; + private static String anotherToken = null; + + @BeforeClass + public static void setup() { + vaultID = "test_vault_id"; + clusterID = "test_cluster_id"; + newClusterID = "new_test_cluster_id"; + token = "test_token"; + anotherToken = "another_test_token"; + } + + @Test + public void testAddingInvalidVaultConfig() { + try { + VaultConfig config = new VaultConfig(); + config.setVaultId(""); + config.setClusterId(clusterID); + config.setEnv(Env.SANDBOX); + Skyflow.builder().addVaultConfig(config).build(); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals(ErrorMessage.EmptyVaultId.getMessage(), e.getMessage()); + } + } + + @Test + public void testAddingAnotherVaultConfig() { + try { + VaultConfig config = new VaultConfig(); + config.setVaultId(vaultID); + config.setClusterId(clusterID); + config.setEnv(Env.SANDBOX); + Skyflow.builder().addVaultConfig(config).addVaultConfig(config).build(); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals(ErrorMessage.VaultIdAlreadyInConfigList.getMessage(), e.getMessage()); + } + } + + @Test + public void testUpdatingValidVaultConfig() { + try { + VaultConfig config = new VaultConfig(); + config.setVaultId(vaultID); + config.setClusterId(clusterID); + config.setEnv(Env.SANDBOX); + + // Set the config + Skyflow skyflowClient = Skyflow.builder().addVaultConfig(config).build(); + + Credentials credentials = new Credentials(); + credentials.setToken(token); + + // Updating the config directly + config.setClusterId(newClusterID); + config.setEnv(Env.PROD); + config.setCredentials(credentials); + + Assert.assertNotEquals(newClusterID, skyflowClient.getVaultConfig().getClusterId()); + Assert.assertEquals(clusterID, skyflowClient.getVaultConfig().getClusterId()); + Assert.assertNotEquals(Env.PROD, skyflowClient.getVaultConfig().getEnv()); + Assert.assertEquals(Env.SANDBOX, skyflowClient.getVaultConfig().getEnv()); + Assert.assertNotEquals(credentials, skyflowClient.getVaultConfig().getCredentials()); + Assert.assertNull(skyflowClient.getVaultConfig().getCredentials()); + + } catch (SkyflowException e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } +} diff --git a/v3/v3.iml b/v3/v3.iml new file mode 100644 index 00000000..c23533a1 --- /dev/null +++ b/v3/v3.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file From facb69950005cf149124289c29909f0ba0f0446a Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Mon, 25 Aug 2025 17:40:16 +0530 Subject: [PATCH 07/97] SK-2259 Immutable skyflow client for V3 - Fixed some failing unit tests - Refactored more code into common - Added more unit tests for V3 --- .gitignore | 5 +- .../java/com/skyflow/utils/BaseConstants.java | 4 +- .../java/com/skyflow/utils/BaseUtils.java | 48 ++++++ .../com/skyflow/utils/logger/LogUtil.java | 6 +- .../util/SignedDataTokensTests.java | 6 +- .../com/skyflow/utils/BaseUtilsTests.java | 22 +++ v2/src/main/java/com/skyflow/Skyflow.java | 3 + v2/src/main/java/com/skyflow/utils/Utils.java | 45 +---- .../com/skyflow/utils/logger/LogUtil.java | 100 ----------- .../com/skyflow/ConnectionClientTests.java | 3 + v2/test/java/com/skyflow/SkyflowTests.java | 4 + .../java/com/skyflow/VaultClientTests.java | 3 + .../skyflow/config/ConnectionConfigTests.java | 3 + .../java/com/skyflow/utils/UtilsTests.java | 4 +- .../connection/InvokeConnectionTests.java | 3 + .../controller/ConnectionControllerTests.java | 3 + .../controller/DetectControllerFileTests.java | 3 + .../controller/DetectControllerTests.java | 2 + .../controller/VaultControllerTests.java | 3 +- .../com/skyflow/vault/data/DeleteTests.java | 2 + .../java/com/skyflow/vault/data/GetTests.java | 2 + .../com/skyflow/vault/data/InsertTests.java | 2 + .../com/skyflow/vault/data/QueryTests.java | 2 + .../com/skyflow/vault/data/UpdateTests.java | 2 + v3/src/main/java/com/skyflow/Skyflow.java | 3 + v3/src/main/java/com/skyflow/VaultClient.java | 5 - v3/src/main/java/com/skyflow/utils/Utils.java | 45 +---- .../java/com/skyflow/VaultClientTests.java | 161 ++++++++++++++++++ .../java/com/skyflow/utils/UtilsTests.java | 25 +++ 29 files changed, 313 insertions(+), 206 deletions(-) create mode 100644 common/src/test/java/com/skyflow/utils/BaseUtilsTests.java delete mode 100644 v2/src/main/java/com/skyflow/utils/logger/LogUtil.java create mode 100644 v3/test/java/com/skyflow/VaultClientTests.java create mode 100644 v3/test/java/com/skyflow/utils/UtilsTests.java diff --git a/.gitignore b/.gitignore index d5a178d4..5d871d11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .idea -target \ No newline at end of file +target + +**/dependency-reduced-pom.xml +.env diff --git a/common/src/main/java/com/skyflow/utils/BaseConstants.java b/common/src/main/java/com/skyflow/utils/BaseConstants.java index cf069e5e..f38be8e8 100644 --- a/common/src/main/java/com/skyflow/utils/BaseConstants.java +++ b/common/src/main/java/com/skyflow/utils/BaseConstants.java @@ -1,8 +1,8 @@ package com.skyflow.utils; public class BaseConstants { - public static final String SDK_NAME= "skyflow java"; - public static final String SDK_VERSION = "2.0.0"; + public static final String SDK_NAME= "Skyflow Java SDK "; + public static final String SDK_VERSION = "1.0.0"; public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; public static final String ORDER_ASCENDING = "ASCENDING"; public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index 263220dd..b51aaaf3 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -1,11 +1,13 @@ package com.skyflow.utils; +import com.google.gson.JsonObject; import com.skyflow.config.Credentials; import com.skyflow.enums.Env; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; +import com.skyflow.logs.InfoLogs; import com.skyflow.serviceaccount.util.BearerToken; import com.skyflow.utils.logger.LogUtil; import org.apache.commons.codec.binary.Base64; @@ -95,6 +97,52 @@ public static String parameterizedString(String base, String... args) { return base; } + protected static JsonObject getCommonMetrics() { + JsonObject details = new JsonObject(); + String deviceModel; + String osDetails; + String javaVersion; + // Retrieve device model + try { + deviceModel = System.getProperty("os.name"); + if (deviceModel == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + BaseConstants.SDK_METRIC_CLIENT_DEVICE_MODEL + )); + deviceModel = ""; + } + + // Retrieve OS details + try { + osDetails = System.getProperty("os.version"); + if (osDetails == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + BaseConstants.SDK_METRIC_CLIENT_OS_DETAILS + )); + osDetails = ""; + } + + // Retrieve Java version details + try { + javaVersion = System.getProperty("java.version"); + if (javaVersion == null) throw new Exception(); + } catch (Exception e) { + LogUtil.printInfoLog(parameterizedString( + InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), + BaseConstants.SDK_METRIC_RUNTIME_DETAILS + )); + javaVersion = ""; + } + details.addProperty(BaseConstants.SDK_METRIC_CLIENT_DEVICE_MODEL, deviceModel); + details.addProperty(BaseConstants.SDK_METRIC_RUNTIME_DETAILS, BaseConstants.SDK_METRIC_RUNTIME_DETAILS_PREFIX + javaVersion); + details.addProperty(BaseConstants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); + return details; + } + private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws SkyflowException { KeyFactory keyFactory; PrivateKey privateKey = null; diff --git a/common/src/main/java/com/skyflow/utils/logger/LogUtil.java b/common/src/main/java/com/skyflow/utils/logger/LogUtil.java index 8746d930..54fc7d47 100644 --- a/common/src/main/java/com/skyflow/utils/logger/LogUtil.java +++ b/common/src/main/java/com/skyflow/utils/logger/LogUtil.java @@ -1,14 +1,14 @@ package com.skyflow.utils.logger; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.BaseConstants; import com.skyflow.enums.LogLevel; +import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.SdkVersion; import java.util.logging.*; public final class LogUtil { private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName()); - private static final String SDK_LOG_PREFIX = "[" + BaseConstants.SDK_PREFIX + "] "; + private static final String SDK_LOG_PREFIX = "[" + SdkVersion.getSdkPrefix() + "] "; private static boolean IS_LOGGER_SETUP_DONE = false; synchronized public static void setupLogger(LogLevel logLevel) { diff --git a/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java b/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java index 56b1403f..bd46cc9f 100644 --- a/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java +++ b/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java @@ -109,19 +109,15 @@ public void testEmptyCredentialsString() { try { SignedDataTokens signedTokens = SignedDataTokens.builder().setCredentials("").build(); signedTokens.getSignedDataTokens(); - System.out.println("in try block"); Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { - System.out.println("caught skyflow exception"); - System.out.println(e); Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( BaseUtils.parameterizedString(ErrorMessage.InvalidCredentials.getMessage(), invalidJsonFilePath), e.getMessage() ); } catch (Exception e) { - System.out.println("catching exception"); - System.out.println(e); + Assert.fail(e.getMessage()); } } diff --git a/common/src/test/java/com/skyflow/utils/BaseUtilsTests.java b/common/src/test/java/com/skyflow/utils/BaseUtilsTests.java new file mode 100644 index 00000000..60958841 --- /dev/null +++ b/common/src/test/java/com/skyflow/utils/BaseUtilsTests.java @@ -0,0 +1,22 @@ +package com.skyflow.utils; + +import com.google.gson.JsonObject; +import org.junit.Assert; +import org.junit.Test; + +public class BaseUtilsTests { + 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"; + + @Test + public void testGetBaseMetrics() { + try { + JsonObject metrics = BaseUtils.getCommonMetrics(); + Assert.assertNotNull(metrics.get(BaseConstants.SDK_METRIC_RUNTIME_DETAILS).getAsString()); + Assert.assertNotNull(metrics.get(BaseConstants.SDK_METRIC_CLIENT_DEVICE_MODEL).getAsString()); + Assert.assertNotNull(metrics.get(BaseConstants.SDK_METRIC_CLIENT_OS_DETAILS).getAsString()); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } +} diff --git a/v2/src/main/java/com/skyflow/Skyflow.java b/v2/src/main/java/com/skyflow/Skyflow.java index e623d127..03e38c3a 100644 --- a/v2/src/main/java/com/skyflow/Skyflow.java +++ b/v2/src/main/java/com/skyflow/Skyflow.java @@ -10,6 +10,8 @@ import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; @@ -29,6 +31,7 @@ private Skyflow(SkyflowClientBuilder builder) { } public static SkyflowClientBuilder builder() { + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); return new SkyflowClientBuilder(); } diff --git a/v2/src/main/java/com/skyflow/utils/Utils.java b/v2/src/main/java/com/skyflow/utils/Utils.java index d1b574a0..c1b34102 100644 --- a/v2/src/main/java/com/skyflow/utils/Utils.java +++ b/v2/src/main/java/com/skyflow/utils/Utils.java @@ -2,8 +2,6 @@ import com.google.gson.JsonObject; import com.skyflow.config.ConnectionConfig; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.logger.LogUtil; import com.skyflow.vault.connection.InvokeConnectionRequest; import java.util.HashMap; @@ -46,50 +44,9 @@ public static Map constructConnectionHeadersMap(Map(); queryParams = new HashMap<>(); requestHeaders = new HashMap<>(); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Test @@ -181,8 +182,9 @@ public void testGetMetricsWithException() { System.clearProperty("os.version"); System.clearProperty("java.version"); + String sdkVersion = Constants.SDK_VERSION; JsonObject metrics = Utils.getMetrics(); - Assert.assertEquals("skyflow-java@v2", metrics.get(Constants.SDK_METRIC_NAME_VERSION).getAsString()); + Assert.assertEquals("skyflow-java@" + sdkVersion, metrics.get(Constants.SDK_METRIC_NAME_VERSION).getAsString()); Assert.assertEquals("Java@", metrics.get(Constants.SDK_METRIC_RUNTIME_DETAILS).getAsString()); Assert.assertTrue(metrics.get(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL).getAsString().isEmpty()); Assert.assertTrue(metrics.get(Constants.SDK_METRIC_CLIENT_OS_DETAILS).getAsString().isEmpty()); diff --git a/v2/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java b/v2/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java index a29a3335..35b53dca 100644 --- a/v2/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java +++ b/v2/test/java/com/skyflow/vault/connection/InvokeConnectionTests.java @@ -5,6 +5,8 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.validations.Validations; import org.junit.Assert; import org.junit.Before; @@ -28,6 +30,7 @@ public static void setup() { pathParams = new HashMap<>(); requestHeaders = new HashMap<>(); requestBody = new HashMap<>(); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Before diff --git a/v2/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java b/v2/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java index b121280a..9e498173 100644 --- a/v2/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java +++ b/v2/test/java/com/skyflow/vault/controller/ConnectionControllerTests.java @@ -7,6 +7,8 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.vault.connection.InvokeConnectionRequest; import org.junit.Assert; import org.junit.BeforeClass; @@ -34,6 +36,7 @@ public static void setup() { connectionConfig.setConnectionId(connectionID); connectionConfig.setConnectionUrl(connectionURL); connectionConfig.setCredentials(credentials); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Test diff --git a/v2/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java b/v2/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java index da8494e1..b8193545 100644 --- a/v2/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java +++ b/v2/test/java/com/skyflow/vault/controller/DetectControllerFileTests.java @@ -5,6 +5,8 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.vault.detect.AudioBleep; import com.skyflow.vault.detect.DeidentifyFileRequest; import com.skyflow.vault.detect.FileInput; @@ -39,6 +41,7 @@ public static void setup() { vaultConfig.setCredentials(credentials); detectController = new DetectController(vaultConfig, credentials); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Test diff --git a/v2/test/java/com/skyflow/vault/controller/DetectControllerTests.java b/v2/test/java/com/skyflow/vault/controller/DetectControllerTests.java index aae713b1..e685b0df 100644 --- a/v2/test/java/com/skyflow/vault/controller/DetectControllerTests.java +++ b/v2/test/java/com/skyflow/vault/controller/DetectControllerTests.java @@ -9,6 +9,7 @@ import com.skyflow.errors.HttpStatus; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.vault.detect.DeidentifyTextRequest; import com.skyflow.vault.detect.ReidentifyTextRequest; @@ -42,6 +43,7 @@ public static void setup() throws SkyflowException, NoSuchMethodException { .setLogLevel(LogLevel.DEBUG) .addVaultConfig(vaultConfig) .build(); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } diff --git a/v2/test/java/com/skyflow/vault/controller/VaultControllerTests.java b/v2/test/java/com/skyflow/vault/controller/VaultControllerTests.java index 5f3ae771..cd32b4a0 100644 --- a/v2/test/java/com/skyflow/vault/controller/VaultControllerTests.java +++ b/v2/test/java/com/skyflow/vault/controller/VaultControllerTests.java @@ -11,6 +11,7 @@ import com.skyflow.errors.SkyflowException; import com.skyflow.generated.rest.ApiClient; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.vault.data.*; import com.skyflow.vault.tokens.DetokenizeRequest; @@ -47,7 +48,7 @@ public static void setup() throws SkyflowException, NoSuchMethodException { .setLogLevel(LogLevel.DEBUG) .addVaultConfig(vaultConfig) .build(); - + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Test diff --git a/v2/test/java/com/skyflow/vault/data/DeleteTests.java b/v2/test/java/com/skyflow/vault/data/DeleteTests.java index befc3d26..f54a46b7 100644 --- a/v2/test/java/com/skyflow/vault/data/DeleteTests.java +++ b/v2/test/java/com/skyflow/vault/data/DeleteTests.java @@ -8,6 +8,7 @@ import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.validations.Validations; import org.junit.Assert; @@ -42,6 +43,7 @@ public static void setup() { skyflowID = "test_delete_id_1"; ids = new ArrayList<>(); table = "test_table"; + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Before diff --git a/v2/test/java/com/skyflow/vault/data/GetTests.java b/v2/test/java/com/skyflow/vault/data/GetTests.java index 43b3f132..b1d6da2e 100644 --- a/v2/test/java/com/skyflow/vault/data/GetTests.java +++ b/v2/test/java/com/skyflow/vault/data/GetTests.java @@ -9,6 +9,7 @@ import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.validations.Validations; import org.junit.Assert; @@ -57,6 +58,7 @@ public static void setup() { columnValue = "test_column_value"; columnValues = new ArrayList<>(); table = "test_table"; + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Before diff --git a/v2/test/java/com/skyflow/vault/data/InsertTests.java b/v2/test/java/com/skyflow/vault/data/InsertTests.java index 00399f00..6721d3c7 100644 --- a/v2/test/java/com/skyflow/vault/data/InsertTests.java +++ b/v2/test/java/com/skyflow/vault/data/InsertTests.java @@ -9,6 +9,7 @@ import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.validations.Validations; import org.junit.Assert; @@ -54,6 +55,7 @@ public static void setup() { valueMap = new HashMap<>(); tokenMap = new HashMap<>(); upsert = "upsert_column"; + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Before diff --git a/v2/test/java/com/skyflow/vault/data/QueryTests.java b/v2/test/java/com/skyflow/vault/data/QueryTests.java index c8e453f5..ac290b6f 100644 --- a/v2/test/java/com/skyflow/vault/data/QueryTests.java +++ b/v2/test/java/com/skyflow/vault/data/QueryTests.java @@ -8,6 +8,7 @@ import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.validations.Validations; import org.junit.Assert; @@ -44,6 +45,7 @@ public static void setup() { queryRecord = new HashMap<>(); queryRecord.put("name", "test_name"); queryRecord.put("card_number", "test_card_number"); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Test diff --git a/v2/test/java/com/skyflow/vault/data/UpdateTests.java b/v2/test/java/com/skyflow/vault/data/UpdateTests.java index be702d4e..d2ee6369 100644 --- a/v2/test/java/com/skyflow/vault/data/UpdateTests.java +++ b/v2/test/java/com/skyflow/vault/data/UpdateTests.java @@ -9,6 +9,7 @@ import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.validations.Validations; import org.junit.Assert; @@ -47,6 +48,7 @@ public static void setup() { table = "test_table"; dataMap = new HashMap<>(); tokenMap = new HashMap<>(); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } @Before diff --git a/v3/src/main/java/com/skyflow/Skyflow.java b/v3/src/main/java/com/skyflow/Skyflow.java index ff5a2de5..09b16a2c 100644 --- a/v3/src/main/java/com/skyflow/Skyflow.java +++ b/v3/src/main/java/com/skyflow/Skyflow.java @@ -8,6 +8,8 @@ import com.skyflow.errors.SkyflowException; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; @@ -25,6 +27,7 @@ private Skyflow(SkyflowClientBuilder builder) { } public static SkyflowClientBuilder builder() { + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); return new SkyflowClientBuilder(); } diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index e8860080..cbeedb94 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -49,11 +49,6 @@ protected void setCommonCredentials(Credentials commonCredentials) throws Skyflo prioritiseCredentials(); } - protected void updateVaultConfig() throws SkyflowException { - updateVaultURL(); - prioritiseCredentials(); - } - protected void setBearerToken() throws SkyflowException { prioritiseCredentials(); Validations.validateCredentials(this.finalCredentials); diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 32c66e63..915c7e55 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -1,56 +1,13 @@ package com.skyflow.utils; import com.google.gson.JsonObject; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.logger.LogUtil; public final class Utils extends BaseUtils { public static JsonObject getMetrics() { - JsonObject details = new JsonObject(); + JsonObject details = getCommonMetrics(); String sdkVersion = Constants.SDK_VERSION; - String deviceModel; - String osDetails; - String javaVersion; - // Retrieve device model - try { - deviceModel = System.getProperty("os.name"); - if (deviceModel == null) throw new Exception(); - } catch (Exception e) { - LogUtil.printInfoLog(parameterizedString( - InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), - Constants.SDK_METRIC_CLIENT_DEVICE_MODEL - )); - deviceModel = ""; - } - - // Retrieve OS details - try { - osDetails = System.getProperty("os.version"); - if (osDetails == null) throw new Exception(); - } catch (Exception e) { - LogUtil.printInfoLog(parameterizedString( - InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), - Constants.SDK_METRIC_CLIENT_OS_DETAILS - )); - osDetails = ""; - } - - // Retrieve Java version details - try { - javaVersion = System.getProperty("java.version"); - if (javaVersion == null) throw new Exception(); - } catch (Exception e) { - LogUtil.printInfoLog(parameterizedString( - InfoLogs.UNABLE_TO_GENERATE_SDK_METRIC.getLog(), - Constants.SDK_METRIC_RUNTIME_DETAILS - )); - javaVersion = ""; - } details.addProperty(Constants.SDK_METRIC_NAME_VERSION, Constants.SDK_METRIC_NAME_VERSION_PREFIX + sdkVersion); - details.addProperty(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL, deviceModel); - details.addProperty(Constants.SDK_METRIC_RUNTIME_DETAILS, Constants.SDK_METRIC_RUNTIME_DETAILS_PREFIX + javaVersion); - details.addProperty(Constants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); return details; } } diff --git a/v3/test/java/com/skyflow/VaultClientTests.java b/v3/test/java/com/skyflow/VaultClientTests.java new file mode 100644 index 00000000..c99d8a08 --- /dev/null +++ b/v3/test/java/com/skyflow/VaultClientTests.java @@ -0,0 +1,161 @@ +package com.skyflow; + +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.Env; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.resources.recordservice.RecordserviceClient; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; +import io.github.cdimascio.dotenv.Dotenv; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class VaultClientTests { + private static final String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception"; + private static VaultClient vaultClient; + private static String vaultID = null; + private static String clusterID = null; + private static VaultConfig vaultConfig; + + @BeforeClass + public static void setup() throws SkyflowException { + vaultID = "vault123"; + clusterID = "cluster123"; + vaultConfig = new VaultConfig(); + vaultConfig.setVaultId(vaultID); + vaultConfig.setClusterId(clusterID); + vaultConfig.setEnv(Env.PROD); + + Credentials credentials = new Credentials(); + credentials.setApiKey("sky-ab123-abcd1234cdef1234abcd4321cdef4321"); + vaultConfig.setCredentials(credentials); + vaultClient = new VaultClient(vaultConfig, credentials); + vaultClient.setBearerToken(); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); + } + + @Test + public void testVaultClientGetRecordsAPI() { + try { + RecordserviceClient recordsClient = vaultClient.getRecordsApi(); + Assert.assertNotNull(recordsClient); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(INVALID_EXCEPTION_THROWN + e.getMessage()); + } + } + + @Test + public void testVaultClientGetVaultConfig() { + try { + VaultConfig config = vaultClient.getVaultConfig(); + Assert.assertNotNull(config); + Assert.assertEquals(vaultID, config.getVaultId()); + Assert.assertEquals(clusterID, config.getClusterId()); + Assert.assertEquals(Env.PROD, config.getEnv()); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testSetBearerToken() { + try { + Credentials credentials = new Credentials(); + credentials.setApiKey("sky-ab123-abcd1234cdef1234abcd4321cdef4321"); + vaultConfig.setCredentials(credentials); + vaultClient = new VaultClient(vaultConfig, credentials); + vaultClient.setBearerToken(); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN + ": " + e.getMessage()); + } + } + + @Test + public void testSetBearerTokenWithApiKey() { + try { + Credentials credentials = new Credentials(); + credentials.setApiKey("sky-ab123-abcd1234cdef1234abcd4321cdef4321"); // Use a non-null dummy API key +// vaultConfig.setCredentials(credentials); +// vaultClient.updateVaultConfig(); + vaultClient.setCommonCredentials(credentials); + + // regular scenario + vaultClient.setBearerToken(); + + // re-use scenario + vaultClient.setBearerToken(); + + // If no exception is thrown, the test passes + Assert.assertTrue(true); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN + ": " + e.getMessage()); + } + } + + @Test + public void testSetBearerTokenWithEnvCredentials() { + try { + Dotenv dotenv = Dotenv.load(); + Credentials credentials = new Credentials(); + credentials.setCredentialsString(dotenv.get("SKYFLOW_CREDENTIALS")); + + // no credentials set at vault config and skyflow levels + vaultConfig.setCredentials(null); + vaultClient.setCommonCredentials(null); + + vaultClient.setBearerToken(); + + // Credentials at ENV level should be prioritised + Assert.assertEquals(credentials, getPrivateField(vaultClient, "finalCredentials")); + + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), 400); + Assert.assertNull(vaultClient.getVaultConfig().getCredentials()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testPrioritiseCredentialsWithVaultConfigCredentials() throws Exception { + // set credentials at vault config level + Credentials credentials = new Credentials(); + credentials.setApiKey("test_api_key"); + vaultConfig.setCredentials(credentials); + + // set credentials at skyflow level + Credentials commonCredentials = new Credentials(); + commonCredentials.setToken("test_common_token"); + vaultClient.setCommonCredentials(commonCredentials); + + // vault config credentials should be prioritised + Assert.assertEquals(credentials, getPrivateField(vaultClient, "finalCredentials")); + } + + @Test + public void testPrioritiseCredentialsWithCommonCredentials() throws Exception { + // no credentials in vault config level + vaultConfig.setCredentials(null); + + // set credentials at skyflow level + Credentials credentials = new Credentials(); + credentials.setApiKey("common_api_key"); + vaultClient.setCommonCredentials(credentials); + + // common credentials should be prioritised + Assert.assertEquals(credentials, getPrivateField(vaultClient, "finalCredentials")); + } + + // Helper methods for reflection field access + private Object getPrivateField(Object obj, String fieldName) throws Exception { + java.lang.reflect.Field field = obj.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + return field.get(obj); + } + +} diff --git a/v3/test/java/com/skyflow/utils/UtilsTests.java b/v3/test/java/com/skyflow/utils/UtilsTests.java new file mode 100644 index 00000000..096a4ec6 --- /dev/null +++ b/v3/test/java/com/skyflow/utils/UtilsTests.java @@ -0,0 +1,25 @@ +package com.skyflow.utils; + +import com.google.gson.JsonObject; +import org.junit.Assert; +import org.junit.Test; + +public class UtilsTests { + 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"; + + @Test + public void testGetMetrics() { + try { + JsonObject metrics = Utils.getMetrics(); + String sdkVersion = Constants.SDK_VERSION; + Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_NAME_VERSION)); + Assert.assertEquals("skyflow-java@" + sdkVersion, metrics.get(Constants.SDK_METRIC_NAME_VERSION).getAsString()); + Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL)); + Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_CLIENT_OS_DETAILS)); + Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_RUNTIME_DETAILS)); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } +} From 46a2c773b3f9a5013d2e1c0895c0ff11205bd983 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 25 Aug 2025 23:03:22 +0530 Subject: [PATCH 08/97] SK-2258 implement bulk insert sync and asyncin flowdb --- .../main/java/com/skyflow/logs/ErrorLogs.java | 2 + .../main/java/com/skyflow/logs/InfoLogs.java | 2 + .../java/com/skyflow/utils/BaseConstants.java | 11 +- .../java/com/skyflow/utils/BaseUtils.java | 10 +- .../skyflow/vault/data/BaseInsertRequest.java | 32 +-- .../tokens/DetokenizeRecordResponse.java | 54 ----- .../vault/tokens/DetokenizeResponse.java | 29 --- .../com/example/ConcurrentBatchProcessor.java | 120 ----------- v2/src/main/java/com/skyflow/VaultClient.java | 2 +- .../com/skyflow/vault/data/InsertRequest.java | 20 +- .../java/com/skyflow/utils/UtilsTests.java | 2 +- .../java/com/example/BulkRecordInserter.java | 107 ---------- v3/src/main/java/com/skyflow/Skyflow.java | 12 +- v3/src/main/java/com/skyflow/VaultClient.java | 62 +++++- .../java/com/skyflow/enums/UpdateType.java | 20 ++ v3/src/main/java/com/skyflow/utils/Utils.java | 118 +++++++++++ .../utils/validations/Validations.java | 62 ++++++ .../vault/controller/VaultController.java | 193 +++++++++++++++++- .../com/skyflow/vault/data/ErrorRecord.java | 20 +- .../com/skyflow/vault/data/InsertRequest.java | 24 ++- .../skyflow/vault/data/InsertResponse.java | 30 ++- .../java/com/skyflow/vault/data/Success.java | 19 +- .../java/com/skyflow/vault/data/Summary.java | 8 + 23 files changed, 575 insertions(+), 384 deletions(-) delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java delete mode 100644 v2/src/main/java/com/example/ConcurrentBatchProcessor.java delete mode 100644 v3/src/main/java/com/example/BulkRecordInserter.java create mode 100644 v3/src/main/java/com/skyflow/enums/UpdateType.java diff --git a/common/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java index 3415860c..7a7745a8 100644 --- a/common/src/main/java/com/skyflow/logs/ErrorLogs.java +++ b/common/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -126,6 +126,8 @@ public enum ErrorLogs { OUTPUT_DIRECTORY_NOT_FOUND("Invalid %s1 request. The output directory does not exist. Please specify a valid output directory."), INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY("Invalid %s1 request. The output directory is not writable. Please check the permissions or specify a valid output directory."), EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file and file path fields are both empty. Specify a valid file object or file path."), + + UNEXPECTED_ERROR_DURING_BATCH_PROCESSING("Unexpected error occurred during batch processing. Error: %s1"), ; private final String log; diff --git a/common/src/main/java/com/skyflow/logs/InfoLogs.java b/common/src/main/java/com/skyflow/logs/InfoLogs.java index efd81a49..e54df467 100644 --- a/common/src/main/java/com/skyflow/logs/InfoLogs.java +++ b/common/src/main/java/com/skyflow/logs/InfoLogs.java @@ -90,6 +90,8 @@ public enum InfoLogs { GET_DETECT_RUN_TRIGGERED("Get detect run method triggered."), VALIDATE_GET_DETECT_RUN_REQUEST("Validating get detect run request."), REIDENTIFY_TEXT_SUCCESS("Text data re-identified."), + + PROCESSING_BATCHES("Processing batch") ; diff --git a/common/src/main/java/com/skyflow/utils/BaseConstants.java b/common/src/main/java/com/skyflow/utils/BaseConstants.java index cf069e5e..2b1c3165 100644 --- a/common/src/main/java/com/skyflow/utils/BaseConstants.java +++ b/common/src/main/java/com/skyflow/utils/BaseConstants.java @@ -7,10 +7,13 @@ public class BaseConstants { public static final String ORDER_ASCENDING = "ASCENDING"; public static final String ENV_CREDENTIALS_KEY_NAME = "SKYFLOW_CREDENTIALS"; public static final String SECURE_PROTOCOL = "https://"; - public static final String DEV_DOMAIN = ".vault.skyflowapis.dev"; - public static final String STAGE_DOMAIN = ".vault.skyflowapis.tech"; - public static final String SANDBOX_DOMAIN = ".vault.skyflowapis-preview.com"; - public static final String PROD_DOMAIN = ".vault.skyflowapis.com"; + + public static final String V2_VAULT_DOMAIN = ".vault."; + public static final String V3_VAULT_DOMAIN = ".skyvault."; + public static final String DEV_DOMAIN = "skyflowapis.dev"; + public static final String STAGE_DOMAIN = "skyflowapis.tech"; + public static final String SANDBOX_DOMAIN = "skyflowapis-preview.com"; + public static final String PROD_DOMAIN = "skyflowapis.com"; public static final String PKCS8_PRIVATE_HEADER = "-----BEGIN PRIVATE KEY-----"; public static final String PKCS8_PRIVATE_FOOTER = "-----END PRIVATE KEY-----"; public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index c1049f9a..a7b2de37 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -20,9 +20,10 @@ import java.security.spec.PKCS8EncodedKeySpec; public class BaseUtils { - public static String getVaultURL(String clusterId, Env env) { + public static String getVaultURL(String clusterId, Env env, String vaultDomain) { StringBuilder sb = new StringBuilder(BaseConstants.SECURE_PROTOCOL); sb.append(clusterId); + sb.append(vaultDomain); switch (env) { case DEV: sb.append(BaseConstants.DEV_DOMAIN); @@ -41,6 +42,13 @@ public static String getVaultURL(String clusterId, Env env) { return sb.toString(); } + public static String getV2VaultURL(String clusterId, Env env) { + return getVaultURL(clusterId, env, BaseConstants.V2_VAULT_DOMAIN); + } + + public static String getV3VaultURL(String clusterId, Env env) { + return getVaultURL(clusterId, env, BaseConstants.V3_VAULT_DOMAIN); + } public static String generateBearerToken(Credentials credentials) throws SkyflowException { if (credentials.getPath() != null) { return BearerToken.builder() diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java index eba79af3..483b41f0 100644 --- a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java +++ b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java @@ -18,27 +18,19 @@ public ArrayList> getValues() { return this.builder.values; } - public ArrayList> getTokens() { - return this.builder.tokens; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - -// public String getUpsert() { -// return this.builder.upsert; +// public Boolean getReturnTokens() { +// return this.builder.returnTokens; // } static class BaseInsertRequestBuilder { protected String table; protected ArrayList> values; - protected ArrayList> tokens; - protected Boolean returnTokens; +// protected ArrayList> tokens; +// protected Boolean returnTokens; protected String upsert; protected BaseInsertRequestBuilder() { - this.returnTokens = false; +// this.returnTokens = false; } public BaseInsertRequestBuilder table(String table) { @@ -51,18 +43,8 @@ public BaseInsertRequestBuilder values(ArrayList> values return this; } - public BaseInsertRequestBuilder tokens(ArrayList> tokens) { - this.tokens = tokens; - return this; - } - - public BaseInsertRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens != null && returnTokens; - return this; - } - -// public BaseInsertRequestBuilder upsert(String upsert) { -// this.upsert = upsert; +// public BaseInsertRequestBuilder returnTokens(Boolean returnTokens) { +// this.returnTokens = returnTokens != null && returnTokens; // return this; // } } diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java deleted file mode 100644 index 7d2ae73c..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeRecordResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.skyflow.vault.tokens; - - -import com.skyflow.generated.rest.types.V1DetokenizeRecordResponse; - -public class DetokenizeRecordResponse { - private final String token; - private final String value; - private final String type; - private final String error; - private final String requestId; - - public DetokenizeRecordResponse(V1DetokenizeRecordResponse record) { - this(record, null); - } - - public DetokenizeRecordResponse(V1DetokenizeRecordResponse record, String requestId) { - this.token = record.getToken().orElse(null); - - this.value = record.getValue() - .filter(val -> val != null && !val.toString().isEmpty()) - .orElse(null); - - this.type = record.getValueType() - .map(Enum::toString) - .filter(val -> !"NONE".equals(val)) - .orElse(null); - - this.error = record.getError().orElse(null); - - this.requestId = requestId; - } - - - public String getError() { - return error; - } - - public String getToken() { - return token; - } - - public String getValue() { - return value; - } - - public String getType() { - return type; - } - - public String getRequestId() { - return requestId; - } -} \ No newline at end of file diff --git a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java b/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java deleted file mode 100644 index 31ff64b2..00000000 --- a/common/src/main/java/com/skyflow/vault/tokens/DetokenizeResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.skyflow.vault.tokens; - -import com.google.gson.Gson; - -import java.util.ArrayList; - -public class DetokenizeResponse { - private final ArrayList detokenizedFields; - private final ArrayList errors; - - public DetokenizeResponse(ArrayList detokenizedFields, ArrayList errors) { - this.detokenizedFields = detokenizedFields; - this.errors = errors; - } - - public ArrayList getDetokenizedFields() { - return detokenizedFields; - } - - public ArrayList getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/v2/src/main/java/com/example/ConcurrentBatchProcessor.java b/v2/src/main/java/com/example/ConcurrentBatchProcessor.java deleted file mode 100644 index 1cc46d9f..00000000 --- a/v2/src/main/java/com/example/ConcurrentBatchProcessor.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.example; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.*; - -public class ConcurrentBatchProcessor { - - // A static executor to be shared by all methods in the class - private static ExecutorService executor; - - // --- Main Method to demonstrate the functionality --- - public static void main(String[] args) { - // Define the parameters for the batch processing - int totalRecords = 1000; // L: Total number of records to process - int batchSize = 50; // M: Size of each batch - int concurrencyLimit = 5; // N: Maximum number of concurrent calls - - // Create a list of dummy records (e.g., strings) - List allRecords = new ArrayList<>(); - for (int i = 1; i <= totalRecords; i++) { - allRecords.add("Record-" + i); - } - - System.out.println("Starting batch processing for " + allRecords.size() + " records."); - System.out.println("Batch Size (M): " + batchSize); - System.out.println("Concurrency Limit (N): " + concurrencyLimit); - - try { - processRecordsInBatches(allRecords, batchSize, concurrencyLimit); - } catch (InterruptedException | ExecutionException e) { - System.err.println("Processing failed due to an exception: " + e.getMessage()); - e.printStackTrace(); - } - System.out.println("All batches have been processed."); - } - - // --- Core logic for concurrent batch processing --- - - /** - * Chunks a list of records and processes each batch concurrently. - * - * @param records The list of all records (L) to be processed. - * @param batchSize The number of records in each batch (M). - * @param concurrencyLimit The maximum number of concurrent calls (N). - * @throws InterruptedException if the thread is interrupted while waiting. - * @throws ExecutionException if a task failed to complete. - */ - public static void processRecordsInBatches(List records, int batchSize, int concurrencyLimit) - throws InterruptedException, ExecutionException { - - // Initialize the shared fixed-size thread pool - executor = Executors.newFixedThreadPool(concurrencyLimit); - - // List to hold all the futures for each batch - List> futures = new ArrayList<>(); - - // Loop through the records to create batches -// 1st itr -> i=0 bs=10 ei=10 -// 2nd itr -> i=10 bs=10 ei=20 - - int counter = 0; - for (int i = 0; i < records.size(); i += batchSize) { - int endIndex = Math.min(i + batchSize, records.size()); - List batch = records.subList(i, endIndex); - int batchId = counter + 1; - - // Submit the batch processing task using CompletableFuture.supplyAsync() - // This is where we create the CompletableFuture and pass the executor. - - CompletableFuture future = CompletableFuture - .supplyAsync(() -> performApiCall(batch, batchId), executor) - .whenComplete((resp, ex) -> System.out.printf("Batch %d End Time:\t%s for thread %s\n", batchId, System.currentTimeMillis(), Thread.currentThread().getName()) - ); - futures.add(future); - counter++; - } - - // Wait for all submitted tasks to complete. - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); - - // Optional: Process the results if needed. - System.out.println("All batches completed. Here are the results:"); - for (CompletableFuture future : futures) { - // get() blocks until the future is complete. - System.out.println(future.get()); - } - - // Shut down the executor gracefully - executor.shutdown(); - if (!executor.awaitTermination(60, TimeUnit.SECONDS)) { - System.err.println("Executor did not terminate in the specified time."); - } - } - - // --- Placeholder method to simulate a synchronous API call --- - - /** - * Simulates a synchronous, blocking API call with a batch of records. - * This method does not return a CompletableFuture and doesn't need to know about the executor. - * - * @param batch The list of records for a single API call. - * @return A success message string. - */ - private static String performApiCall(List batch, int batchId) { - // Simulate a network call delay - try { - System.out.printf("Batch %d Start Time:\t%s for thread %s\n", batchId, System.currentTimeMillis(), Thread.currentThread().getName()); - long processingTime = (long) (Math.random() * 2000) + 500; // 0.5 to 2.5 seconds - Thread.sleep(processingTime); - String result = "Successfully processed batch of " + batch.size() + - " records, starting with " + batch.get(0) + - " (simulated duration: " + processingTime + "ms)"; - return result; - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new IllegalStateException("API call was interrupted.", e); - } - } -} \ No newline at end of file diff --git a/v2/src/main/java/com/skyflow/VaultClient.java b/v2/src/main/java/com/skyflow/VaultClient.java index 7854a81b..22193fae 100644 --- a/v2/src/main/java/com/skyflow/VaultClient.java +++ b/v2/src/main/java/com/skyflow/VaultClient.java @@ -783,7 +783,7 @@ private DeidentifyAudioRequestFileDataFormat mapAudioDataFormat(String dataForma } private void updateVaultURL() { - String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); + String vaultURL = Utils.getV2VaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); this.apiClientBuilder.url(vaultURL); } diff --git a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java index 025b4572..192b48a8 100644 --- a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -28,16 +28,30 @@ public Boolean getContinueOnError() { public TokenMode getTokenMode() { return this.builder.tokenMode; } + public String getUpsert() { + return this.builder.upsert; + } + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public ArrayList> getTokens() { + return this.builder.tokens; + } public static final class InsertRequestBuilder extends BaseInsertRequestBuilder { private Boolean homogeneous; private Boolean continueOnError; private TokenMode tokenMode; + private ArrayList> tokens; + private Boolean returnTokens; + private InsertRequestBuilder() { super(); this.continueOnError = false; this.tokenMode = TokenMode.DISABLE; + this.returnTokens = false; } @Override @@ -52,15 +66,13 @@ public InsertRequestBuilder values(ArrayList> values) { return this; } - @Override public InsertRequestBuilder tokens(ArrayList> tokens) { - super.tokens(tokens); + this.tokens = tokens ; return this; } - @Override public InsertRequestBuilder returnTokens(Boolean returnTokens) { - super.returnTokens(returnTokens); + this.returnTokens = returnTokens; return this; } diff --git a/v2/test/java/com/skyflow/utils/UtilsTests.java b/v2/test/java/com/skyflow/utils/UtilsTests.java index c9f39c90..d2406533 100644 --- a/v2/test/java/com/skyflow/utils/UtilsTests.java +++ b/v2/test/java/com/skyflow/utils/UtilsTests.java @@ -61,7 +61,7 @@ public void testGetVaultURLForDifferentENVs() { map.put(Env.PROD, "https://test_cluster_id.vault.skyflowapis.com"); for (Env env : map.keySet()) { - String vaultURL = Utils.getVaultURL(clusterId, env); + String vaultURL = Utils.getV2VaultURL(clusterId, env); Assert.assertEquals(map.get(env), vaultURL); } } catch (Exception e) { diff --git a/v3/src/main/java/com/example/BulkRecordInserter.java b/v3/src/main/java/com/example/BulkRecordInserter.java deleted file mode 100644 index ee7a5215..00000000 --- a/v3/src/main/java/com/example/BulkRecordInserter.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.example; - -import com.skyflow.generated.rest.types.InsertRecordData; -import com.skyflow.generated.rest.types.InsertResponse; -import okhttp3.OkHttpClient; -import okhttp3.Request; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; - -public class BulkRecordInserter { - private final int concurrencyLimit; - private final int batchSize; - private final OkHttpClient httpClient; - - public BulkRecordInserter(int concurrencyLimit, int batchSize, String token) { - this.concurrencyLimit = concurrencyLimit; - this.batchSize = batchSize; - this.httpClient = new OkHttpClient.Builder() - .addInterceptor(chain -> { - Request original = chain.request(); - Request requestWithAuth = original.newBuilder() - .header("Authorization", "Bearer " + token) - .build(); - return chain.proceed(requestWithAuth); - }) - .build(); - } - - public void process(List records) { - List> batches = createBatches(records, batchSize); - System.out.printf("Processing %d batches with concurrency=%d...\n", batches.size(), concurrencyLimit); - List> futures = new ArrayList<>(); - AtomicInteger successCount = new AtomicInteger(); - AtomicInteger failureCount = new AtomicInteger(); - - for (int i = 0; i < batches.size(); i++) { - final int batchNumber = i + 1; - List batch = batches.get(i); - try { - System.out.println("Starting Batch " + batchNumber + - " on thread " + Thread.currentThread().getName()); - - CompletableFuture future = InsertSample2.insertData(batch, httpClient); -// .thenAccept(response -> { -//// System.out.println("Batch " + batchNumber + " completed on thread " + -//// Thread.currentThread().getName() + ": " + response); -// }) -// .exceptionally(ex -> { -//// System.err.println("Batch " + batchNumber + " failed: " + ex); -// return null; -// }) -// .whenComplete((res, ex) -> System.out.println("Batch " + batchNumber + " processing finished on thread " + -// Thread.currentThread().getName())); - futures.add(future); - } catch (Exception e) { - System.out.printf("Batch %d failed with exception: %s\n", batchNumber, e.getMessage()); - } finally { - System.out.println("Batch " + batchNumber + " processing finished on thread " + - Thread.currentThread().getName()); - } - } - - for (CompletableFuture future : futures) { - try { - InsertResponse response = future.join(); // Retrieve the result - System.out.println("Response here: " + response); - successCount.incrementAndGet(); - } catch (Exception e) { - failureCount.incrementAndGet(); - System.err.println("Error while processing future: " + e.getMessage()); - } - } - System.out.printf("All batches completed. Success=%d, Failed=%d\n", - successCount.get(), failureCount.get()); - } - - private List> createBatches(List records, int batchSize) { - List> batches = new ArrayList<>(); - for (int i = 0; i < records.size(); i += batchSize) { - batches.add(records.subList(i, Math.min(i + batchSize, records.size()))); - } - return batches; - } - - public static void main(String[] args) { - int recordsCount = 1; - int concurrency = 1; - int batchSize = 1; - - BatchProcessor processor = new BatchProcessor(concurrency, batchSize, "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2MiOiJiOTYzZTcxMjFkZDY0YTZkOTY0MGQ3ZTNlNGNjODdhNyIsImF1ZCI6Imh0dHBzOi8vbWFuYWdlLWJsaXR6LnNreWZsb3dhcGlzLmRldiIsImV4cCI6MTc1NTU5NjEwNSwiaWF0IjoxNzU1NTA5NzA1LCJpc3MiOiJzYS1hdXRoQG1hbmFnZS1ibGl0ei5za3lmbG93YXBpcy5kZXYiLCJqdGkiOiJ0NjQ2OWUyZWJlNzY0YmNiODIzZGY3ZjYwYTY1NjgyZSIsInN1YiI6ImUzMThiYjk0NzA4YjQ0MmRiZjBkMWY2MjEwYmQxMGU5In0.bhyK9y7wDvUXY1Q3UCJs_Rhv3xOfHScXBCa8-zZJ5xSd5uryBfOOjVhx4X9ZOO8vEwRAU4Ij8deBKZ08k7knXHd3MTLjkq7euKdFqIhkL1TknQkAQHhxES8FoZQuzV4_WZJejnmopZOXYviY-SeggaQTMyfoSdI3ObmLsPjkHo7InJJGwr9Jyc2eiae_4KVMFPTLw9yZVx55fJ7wa1i3VJFT_OMiiyxjVS8f6NYTjIzQtvqxh_NRMRhIMxcGoh0ZLh6yZJQzMU9sg9DBfRdrlVOMDOfGhptb38i3hodsnIw08AtOrDHdjwwHC_lqT96o8z8bUJzGW9fKZLclcAN3wg"); - List mockRecords = generateMockRecords(recordsCount); - processor.process(mockRecords); - } - - private static List generateMockRecords(int count) { - List records = new ArrayList<>(); - for (int i = 0; i < count; i++) { - Map map = new HashMap<>(); - map.put("name", "bharti"); - map.put("email", "email" + i + "@email.com"); - records.add(InsertRecordData.builder().data(map).build()); - } - return records; - } -} diff --git a/v3/src/main/java/com/skyflow/Skyflow.java b/v3/src/main/java/com/skyflow/Skyflow.java index 2fc6d9e0..d46e8f87 100644 --- a/v3/src/main/java/com/skyflow/Skyflow.java +++ b/v3/src/main/java/com/skyflow/Skyflow.java @@ -61,16 +61,12 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdAlreadyInConfigList.getMessage()); } else { - LogUtil.printWarningLog(WarningLogs.OVERRIDING_EXISTING_VAULT_CONFIG.getLog()); - VaultConfig vaultConfigDeepCopy = Utils.deepCopy(vaultConfig); - this.vaultConfigMap.clear(); // clear existing config - assert vaultConfigDeepCopy != null; - this.vaultConfigMap.put(vaultConfigDeepCopy.getVaultId(), vaultConfigDeepCopy); // add new config in map - - this.vaultClientsMap.clear(); // clear existing vault controller - this.vaultClientsMap.put(vaultConfigDeepCopy.getVaultId(), new VaultController(vaultConfigDeepCopy, this.skyflowCredentials)); // add new controller with new config + this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig); + this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials)); LogUtil.printInfoLog(Utils.parameterizedString( InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); + LogUtil.printInfoLog(Utils.parameterizedString( + InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId())); } return this; } diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index e8860080..35ca6df5 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -2,12 +2,17 @@ import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; +import com.skyflow.enums.UpdateType; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.generated.rest.ApiClient; import com.skyflow.generated.rest.ApiClientBuilder; import com.skyflow.generated.rest.resources.recordservice.RecordserviceClient; +import com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest; +import com.skyflow.generated.rest.types.EnumUpdateType; +import com.skyflow.generated.rest.types.InsertRecordData; +import com.skyflow.generated.rest.types.Upsert; import com.skyflow.logs.InfoLogs; import com.skyflow.serviceaccount.util.Token; import com.skyflow.utils.Constants; @@ -16,6 +21,15 @@ import com.skyflow.utils.validations.Validations; import io.github.cdimascio.dotenv.Dotenv; import io.github.cdimascio.dotenv.DotenvException; +import okhttp3.Dispatcher; +import okhttp3.OkHttpClient; +import okhttp3.Request; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class VaultClient { @@ -66,11 +80,14 @@ protected void setBearerToken() throws SkyflowException { } else { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); } + updateExecutorInHTTP(); // update executor + // token need to add in http client this.apiClient = this.apiClientBuilder.build(); + } private void updateVaultURL() { - String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); + String vaultURL = Utils.getV3VaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); this.apiClientBuilder.url(vaultURL); } @@ -103,4 +120,47 @@ private void prioritiseCredentials() throws SkyflowException { throw new RuntimeException(e); } } + + protected void updateExecutorInHTTP() { + OkHttpClient httpClient = new OkHttpClient.Builder() + .addInterceptor(chain -> { + Request original = chain.request(); + Request requestWithAuth = original.newBuilder() + .header("Authorization", "Bearer " + this.vaultConfig.getCredentials().getToken()) + .build(); + return chain.proceed(requestWithAuth); + }) + .build(); + apiClientBuilder.httpClient(httpClient); + } + protected InsertRequest getBUlkInsertRequestBody(com.skyflow.vault.data.InsertRequest request, VaultConfig config) throws SkyflowException { + List> values = request.getValues(); + List insertRecordDataList = new ArrayList<>(); + for (HashMap value : values) { + InsertRecordData data = InsertRecordData.builder().data(value).build(); + insertRecordDataList.add(data); + } + InsertRequest.Builder builder = InsertRequest.builder() + .vaultId(config.getVaultId()) + .records(insertRecordDataList) + .tableName(request.getTable()); + if(request.getUpsert() != null && !request.getUpsert().isEmpty()){ + if (request.getUpsertType() != null) { + EnumUpdateType updateType = null; + if(request.getUpsertType() == UpdateType.REPLACE){ + updateType = EnumUpdateType.REPLACE; + } else if (request.getUpsertType() == UpdateType.REPLACE) { + updateType = EnumUpdateType.UPDATE; + } + Upsert upsert = Upsert.builder().uniqueColumns(request.getUpsert()).updateType(updateType).build(); + builder.upsert(upsert); + } else { + Upsert upsert = Upsert.builder().uniqueColumns(request.getUpsert()).build(); + builder.upsert(upsert); + } + } + return builder.build(); + + } + } diff --git a/v3/src/main/java/com/skyflow/enums/UpdateType.java b/v3/src/main/java/com/skyflow/enums/UpdateType.java new file mode 100644 index 00000000..7fcb6f65 --- /dev/null +++ b/v3/src/main/java/com/skyflow/enums/UpdateType.java @@ -0,0 +1,20 @@ +package com.skyflow.enums; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum UpdateType { + UPDATE("UPDATE"), + + REPLACE("REPLACE"); + + private final String value; + + UpdateType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 32c66e63..7abc3a98 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -1,8 +1,19 @@ package com.skyflow.utils; import com.google.gson.JsonObject; +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.types.InsertRecordData; +import com.skyflow.generated.rest.types.InsertResponse; +import com.skyflow.generated.rest.types.RecordResponseObject; import com.skyflow.logs.InfoLogs; import com.skyflow.utils.logger.LogUtil; +import com.skyflow.vault.data.ErrorRecord; +import com.skyflow.vault.data.Success; +import com.skyflow.vault.data.Token; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; public final class Utils extends BaseUtils { @@ -53,4 +64,111 @@ public static JsonObject getMetrics() { details.addProperty(Constants.SDK_METRIC_CLIENT_OS_DETAILS, osDetails); return details; } + + public static List> createBatches(List records, int batchSize) { + List> batches = new ArrayList<>(); + for (int i = 0; i < records.size(); i += batchSize) { + batches.add(records.subList(i, Math.min(i + batchSize, records.size()))); + } + return batches; + } + public static ErrorRecord createErrorRecord(Map recordMap, int indexNumber) { + ErrorRecord err = new ErrorRecord(); + err.setIndex(indexNumber); + if (recordMap.containsKey("error")) { + err.setError((String) recordMap.get("error")); + } + if (recordMap.containsKey("http_code")) { + err.setCode((Integer) recordMap.get("http_code")); + } + return err; + } + public static List handleBatchException( + Throwable ex, List batch, int batchNumber, List> batches + ) { + List errorRecords = new ArrayList<>(); + Throwable cause = ex.getCause(); + if (cause instanceof ApiClientApiException) { + ApiClientApiException apiException = (ApiClientApiException) cause; + Map responseBody = (Map) apiException.body(); + int indexNumber = batchNumber > 0 ? batchNumber * batches.get(batchNumber - 1).size() : 0; + + if (responseBody != null) { + if (responseBody.containsKey("records")) { + Object recordss = responseBody.get("records"); + if (recordss instanceof List) { + List recordsList = (List) recordss; + for (Object record : recordsList) { + if (record instanceof Map) { + Map recordMap = (Map) record; + ErrorRecord err = Utils.createErrorRecord(recordMap, indexNumber); + errorRecords.add(err); + indexNumber++; + } + } + } + } else if (responseBody.containsKey("error")) { + Map recordMap = (Map) responseBody.get("error"); + for (int j = 0; j < batch.size(); j++) { + ErrorRecord err = Utils.createErrorRecord(recordMap, indexNumber); + errorRecords.add(err); + indexNumber++; + } + } + } + } else { + int indexNumber = batchNumber > 0 ? batchNumber * batches.get(batchNumber - 1).size() : 0; + for (int j = 0; j < batch.size(); j++) { + ErrorRecord err = new ErrorRecord(); + err.setIndex(indexNumber); + err.setError(ex.getMessage()); + err.setCode(500); + errorRecords.add(err); + indexNumber++; + } + } + return errorRecords; + } + public static com.skyflow.vault.data.InsertResponse formatResponse(InsertResponse response, int batch, int batchSize){ + com.skyflow.vault.data.InsertResponse response1 = new com.skyflow.vault.data.InsertResponse(); + List successRecords = new ArrayList<>(); + List errorRecords = new ArrayList<>(); + if (response != null) { + List record = response.getRecords().get(); + int indexNumber = (batch) * batchSize; + for(int index = 0; index < response.getRecords().get().size(); index++) { + if (record.get(index).getError().isPresent()){ + ErrorRecord errorRecord = new ErrorRecord(); + errorRecord.setIndex(indexNumber); + errorRecord.setError(record.get(index).getError().get()); + errorRecord.setCode(record.get(index).getHttpCode().get()); + errorRecords.add(errorRecord); +// errorRecord.setCode(record.get(index).getError().get().getCode()); + } else { + Success success = new Success(); + success.setIndex(indexNumber); + success.setSkyflowId(record.get(index).getSkyflowId().get()); +// success.setData(record.get(index).getData().get()); + if(record.get(index).getTokens().isPresent()) { + List tokens = null; + Map tok = record.get(index).getTokens().get(); + for (int i = 0; i < tok.size(); i++) { + Token token = new Token(); + Object obj = tok.get(i); +// token.setToken(); +// token.setTokenGroupName(""); + } + } +// success.setTokens(record.get(index).getTokens().get()); + + successRecords.add(success); + } + indexNumber++; + } + response1.setSuccess(successRecords); + response1.setErrors(errorRecords); + } + return response1; + } + } diff --git a/v3/src/main/java/com/skyflow/utils/validations/Validations.java b/v3/src/main/java/com/skyflow/utils/validations/Validations.java index 374e84d4..6613c7d3 100644 --- a/v3/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/v3/src/main/java/com/skyflow/utils/validations/Validations.java @@ -1,9 +1,71 @@ package com.skyflow.utils.validations; +import com.skyflow.enums.InterfaceName; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.logs.ErrorLogs; +import com.skyflow.utils.Utils; +import com.skyflow.utils.logger.LogUtil; +import com.skyflow.vault.data.InsertRequest; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + public class Validations extends BaseValidations { private Validations() { super(); } // add validations specific to v3 SDK + public static void validateInsertRequest(InsertRequest insertRequest) throws SkyflowException { + String table = insertRequest.getTable(); + ArrayList> values = insertRequest.getValues(); + List upsert = insertRequest.getUpsert(); + + if (table == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.TABLE_IS_REQUIRED.getLog(), InterfaceName.INSERT.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.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTable.getMessage()); + } else if (values == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.VALUES_IS_REQUIRED.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ValuesKeyError.getMessage()); + } else if (values.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_VALUES.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValues.getMessage()); + } + // upsert + + for (HashMap valuesMap : values) { + for (String key : valuesMap.keySet()) { + if (key == null || key.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_KEY_IN_VALUES.getLog(), InterfaceName.INSERT.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyKeyInValues.getMessage()); + } else { + Object value = valuesMap.get(key); + if (value == null || value.toString().trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_VALUE_IN_VALUES.getLog(), + InterfaceName.INSERT.getName(), key + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInValues.getMessage()); + } + } + } + } + } + } diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index b5181f07..9631e429 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -5,13 +5,29 @@ import com.skyflow.VaultClient; import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; +import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.types.InsertRecordData; import com.skyflow.generated.rest.types.InsertResponse; +import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; +import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; -import com.skyflow.vault.RequestOptions; -import com.skyflow.vault.data.BaseInsertRequest; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.data.ErrorRecord; +import com.skyflow.vault.data.InsertRequest; +import com.skyflow.vault.data.Success; +import com.skyflow.vault.data.Summary; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static com.skyflow.utils.Utils.formatResponse; +import static com.skyflow.utils.Utils.handleBatchException; public final class VaultController extends VaultClient { private static final Gson gson = new GsonBuilder().serializeNulls().create(); @@ -21,14 +37,177 @@ public VaultController(VaultConfig vaultConfig, Credentials credentials) { } // add methods for v3 SDK - public InsertResponse bulkInsert(BaseInsertRequest insertRequest, RequestOptions requestOptions) { - InsertResponse response = null; + public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequest) throws SkyflowException { + com.skyflow.vault.data.InsertResponse response; LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); + try { + // validation + LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); + Validations.validateInsertRequest(insertRequest); + int batchSize = 10; + int concurrencyLimit = 5; + setBearerToken(); + // calculate batch concurrency + + // req + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBUlkInsertRequestBody(insertRequest, super.getVaultConfig()); + + response = this.processSync(batchSize, concurrencyLimit, request); + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } return response; } - public CompletableFuture bulkInsertAsync(BaseInsertRequest insertRequest, RequestOptions requestOptions){ - CompletableFuture future = null; - return future; + public CompletableFuture bulkInsertAsync(InsertRequest insertRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); + try { + // validation + LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); + Validations.validateInsertRequest(insertRequest); + int batchSize = 50; + int concurrencyLimit = 10; + setBearerToken(); + // calculate batch concurrency + + // req + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBUlkInsertRequestBody(insertRequest, super.getVaultConfig()); + + List errorRecords = new ArrayList<>(); + + List> futures = this.insertBatchFutures( + batchSize, concurrencyLimit, request, errorRecords + ); + + return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) + .thenApply(v -> { + List successRecords1 = new ArrayList<>(); + + for (CompletableFuture future : futures) { + com.skyflow.vault.data.InsertResponse futureResponse = future.join(); + if (futureResponse != null) { + if (futureResponse.getSuccess() != null) { + successRecords1.addAll(futureResponse.getSuccess()); + } + if (futureResponse.getErrors() != null) { + errorRecords.addAll(futureResponse.getErrors()); + } + } + } + + com.skyflow.vault.data.InsertResponse response1 = new com.skyflow.vault.data.InsertResponse(); + if (!successRecords1.isEmpty()) { + response1.setSuccess(successRecords1); + } + if (!errorRecords.isEmpty()) { + response1.setErrors(errorRecords); + } + Summary summary = new Summary(); + summary.setTotalRecords(insertRequest.getValues().size()); + summary.setTotalInserted(successRecords1.size()); + summary.setTotalFailed(errorRecords.size()); + response1.setSummary(summary); + return response1; + }); + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } + } + + private com.skyflow.vault.data.InsertResponse processSync( + int batchSize, int concurrencyLimit, com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest + ) { + LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); + List errorRecords = new ArrayList<>(); + List successRecords = new ArrayList<>(); + List> recordsToRetry = new ArrayList<>(); + try { + + List> futures = this.insertBatchFutures( + batchSize, concurrencyLimit, insertRequest, errorRecords + ); + + CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); + allFutures.join(); + + for (CompletableFuture future : futures) { + com.skyflow.vault.data.InsertResponse futureResponse = future.get(); + if (futureResponse != null) { + if (futureResponse.getSuccess() != null) { + successRecords.addAll(futureResponse.getSuccess()); + } + if (futureResponse.getErrors() != null) { + errorRecords.addAll(futureResponse.getErrors()); + } + } + } + } catch (InterruptedException e) { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.UNEXPECTED_ERROR_DURING_BATCH_PROCESSING.getLog(), e.getMessage())); + Thread.currentThread().interrupt(); + } catch (Exception e) { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.UNEXPECTED_ERROR_DURING_BATCH_PROCESSING.getLog(), e.getMessage())); + ErrorRecord err = new ErrorRecord(); + err.setError(e.getMessage()); + err.setCode(500); + errorRecords.add(err); + } + com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(); + if (!errorRecords.isEmpty()) { + response.setErrors(errorRecords); + } + if (!successRecords.isEmpty()) { + response.setSuccess(successRecords); + } + LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); + return response; + } + + + private List> insertBatchFutures( + int batchSize, int concurrencyLimit, com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords + ) { + List records = insertRequest.getRecords().get(); + + ExecutorService executor = Executors.newFixedThreadPool(concurrencyLimit); + List> batches = Utils.createBatches(records, batchSize); + List> futures = new ArrayList<>(); + + try { + for (int i = 0; i < batches.size(); i++) { + List batch = batches.get(i); + int batchNumber = i; + CompletableFuture future = CompletableFuture + .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) + .exceptionally(ex -> { + // retry logic +// recordsToRetry.addAll(batch.stream().map(InsertRecordData::getFields).toList()); + errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); + return null; + }) + .thenApply(response -> formatResponse(response, batchNumber, batchSize)); + futures.add(future); + } + } finally { + executor.shutdown(); + } + return futures; + } + + private InsertResponse insertBatch(List batch, String tableName) { + try { + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest req = com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest.builder() + .vaultId(this.getVaultConfig().getVaultId()) + .tableName(tableName) + .records(batch) + .build(); + return this.getRecordsApi().insert(req); + } catch (Exception e) { + LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); + return null; + } } } diff --git a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java index 89091f55..2f81d2f6 100644 --- a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java +++ b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java @@ -1,14 +1,17 @@ package com.skyflow.vault.data; +import com.google.gson.Gson; + public class ErrorRecord { - private String index; + private int index; private String error; - public String getIndex() { + private int code; + public int getIndex() { return index; } - public void setIndex(String index) { + public void setIndex(int index) { this.index = index; } @@ -19,4 +22,15 @@ public String getError() { public void setError(String error) { this.error = error; } + public int getCode() { + return code; + } + public void setCode(int code) { + this.code = code; + } + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } } \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java index 2063799b..35d86d49 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -1,5 +1,7 @@ package com.skyflow.vault.data; +import com.skyflow.enums.UpdateType; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -22,18 +24,18 @@ public Boolean getReturnData() { public List getUpsert() { return this.builder.upsert; } - public String getUpsertType() { + public UpdateType getUpsertType() { return this.builder.upsertType; } - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } +// public Boolean getReturnTokens() { +// return this.builder.returnTokens; +// } public static final class InsertRequestBuilder extends BaseInsertRequestBuilder { private Boolean returnData; private List upsert; - private String upsertType; + private UpdateType upsertType; private InsertRequestBuilder() { super(); @@ -56,15 +58,15 @@ public InsertRequestBuilder upsert(List upsert) { this.upsert = upsert; return this; } - public InsertRequestBuilder upsertType(String upsertType) { + public InsertRequestBuilder upsertType(UpdateType upsertType) { this.upsertType = upsertType; return this; } - @Override - public InsertRequestBuilder returnTokens(Boolean returnTokens) { - super.returnTokens(returnTokens); - return this; - } +// @Override +// public InsertRequestBuilder returnTokens(Boolean returnTokens) { +// super.returnTokens(returnTokens); +// return this; +// } public InsertRequestBuilder returnData(Boolean returnData) { this.returnData = returnData; diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index f9007955..4f19d6ec 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -1,12 +1,18 @@ package com.skyflow.vault.data; +import com.google.gson.Gson; + +import java.util.ArrayList; import java.util.List; +import java.util.Map; public class InsertResponse { private Summary summary; private List success; private List errors; + private List> recordsToRetry; + public Summary getSummary() { return summary; } @@ -23,11 +29,31 @@ public void setSuccess(List success) { this.success = success; } - public List getErrors() { + public List getErrors() { return errors; } - public void setErrors(List errors) { + public void setErrors(List errors) { this.errors = errors; } + + public void setRecordsToRetry(List> records) { + if(recordsToRetry == null){ + recordsToRetry = records; + } else { + recordsToRetry.addAll(records); + } + } + public List> getRecordsToRetry() { + if(recordsToRetry == null){ + return new ArrayList<>(); + } + return recordsToRetry; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } } \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/Success.java b/v3/src/main/java/com/skyflow/vault/data/Success.java index ed71e0db..5f2d38d3 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Success.java +++ b/v3/src/main/java/com/skyflow/vault/data/Success.java @@ -1,18 +1,20 @@ package com.skyflow.vault.data; +import com.google.gson.Gson; + import java.util.List; import java.util.Map; public class Success { - private String index; + private int index; private String skyflow_id; private Map> tokens; - private Map data; + private Map data; - public String getIndex() { + public int getIndex() { return index; } - public void setIndex(String index) { + public void setIndex(int index) { this.index = index; } @@ -32,11 +34,16 @@ public void setTokens(Map> tokens) { this.tokens = tokens; } - public Map getData() { + public Map getData() { return data; } - public void setData(Map data) { + public void setData(Map data) { this.data = data; } + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } } \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/Summary.java b/v3/src/main/java/com/skyflow/vault/data/Summary.java index fe34e536..643a37d7 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Summary.java +++ b/v3/src/main/java/com/skyflow/vault/data/Summary.java @@ -1,5 +1,7 @@ package com.skyflow.vault.data; +import com.google.gson.Gson; + public class Summary { private int total_records; private int total_inserted; @@ -28,4 +30,10 @@ public int getTotalFailed() { public void setTotalFailed(int total_failed) { this.total_failed = total_failed; } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } } \ No newline at end of file From dcd9a4bbfd67d0c7b0f9f03aae42398aee8fd585 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:31:09 +0530 Subject: [PATCH 09/97] SK-2260: test v3 internal release --- .github/workflows/internal-release.yml | 7 ++++--- .github/workflows/shared-build-and-deploy.yml | 14 +++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/internal-release.yml b/.github/workflows/internal-release.yml index e8b8ee61..385b3210 100644 --- a/.github/workflows/internal-release.yml +++ b/.github/workflows/internal-release.yml @@ -1,4 +1,4 @@ -name: Publish package to the JFROG Artifactory +name: Publish v3 module to the JFROG Artifactory on: push: tags-ignore: @@ -6,16 +6,17 @@ on: paths-ignore: - "*.md" branches: - - release/* + - v3-release/* jobs: - build-and-deploy: + build-and-deploy-v3: uses: ./.github/workflows/shared-build-and-deploy.yml with: ref: ${{ github.ref_name }} server-id: central profile: jfrog tag: 'internal' + module: 'v3' secrets: server-username: ${{ secrets.ARTIFACTORY_USERNAME }} server-password: ${{ secrets.ARTIFACTORY_PASSWORD }} diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index c9cadd2c..6e8471e8 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -21,6 +21,13 @@ on: description: 'Release Tag' required: true type: string + + module: + description: 'Module to build and publish' + required: false + type: string + default: '' + secrets: server-username: required: true @@ -125,7 +132,12 @@ jobs: json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }} - name: Publish package - run: mvn --batch-mode deploy -P ${{ inputs.profile }} + run: | + if [ -n "${{ inputs.module }}" ]; then + mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} + else + mvn --batch-mode deploy -P ${{ inputs.profile }} + fi env: SERVER_USERNAME: ${{ secrets.server-username }} From 1be74b65c464b20d0cb5e9b3825384c6e6ed5817 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 07:01:46 +0000 Subject: [PATCH 10/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-dcd9a4b --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f36b6778..dd3ade14 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow-java - 1.0.0 + 2.0.0-beta.2-dev.dcd9a4b pom ${project.groupId}:${project.artifactId} From 06fb6fd25df49c2400655532d3402942c2e7328b Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:59:29 +0530 Subject: [PATCH 11/97] SK-2260: update module pom files. --- common/pom.xml | 3 ++- pom.xml | 4 ++-- v2/pom.xml | 5 +++-- v3/pom.xml | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/pom.xml b/common/pom.xml index d971c1b5..b0ce9c0a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,13 +5,14 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 common 1.0.0 + 8 8 diff --git a/pom.xml b/pom.xml index dd3ade14..e46408c7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,8 +5,8 @@ 4.0.0 com.skyflow - skyflow-java - 2.0.0-beta.2-dev.dcd9a4b + skyflow + 1.0.0 pom ${project.groupId}:${project.artifactId} diff --git a/v2/pom.xml b/v2/pom.xml index 294d6df0..edf5d397 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -5,12 +5,13 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 v2 - 2.0.0-beta.2 + 2.0.0-beta.3 + com.skyflow 8 diff --git a/v3/pom.xml b/v3/pom.xml index 972f81b2..2f47e0b6 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -5,12 +5,13 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 v3 3.0.0-beta.0 + jar 8 From 381360a1c188ec1c205c7940470542a93d005af7 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 07:30:56 +0000 Subject: [PATCH 12/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-06fb6fd --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e46408c7..487f2663 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow - 1.0.0 + 2.0.0-beta.2-dev.06fb6fd pom ${project.groupId}:${project.artifactId} From 63094886aa629279746c6db235e8658d1566c960 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:03:41 +0530 Subject: [PATCH 13/97] SK-2260: update module pom files --- common/pom.xml | 1 + v2/pom.xml | 1 + v3/pom.xml | 1 + 3 files changed, 3 insertions(+) diff --git a/common/pom.xml b/common/pom.xml index b0ce9c0a..a18bd86f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -7,6 +7,7 @@ com.skyflow skyflow 1.0.0 + ../pom.xml common diff --git a/v2/pom.xml b/v2/pom.xml index edf5d397..ff520627 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -7,6 +7,7 @@ com.skyflow skyflow 1.0.0 + ../pom.xml v2 diff --git a/v3/pom.xml b/v3/pom.xml index 2f47e0b6..a5261c7f 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -7,6 +7,7 @@ com.skyflow skyflow 1.0.0 + ../pom.xml v3 From ebd85d1af692e89e95e3560e184602d01b1b805d Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 07:34:28 +0000 Subject: [PATCH 14/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-6309488 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 487f2663..6d48cd82 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow - 2.0.0-beta.2-dev.06fb6fd + 2.0.0-beta.2-dev.6309488 pom ${project.groupId}:${project.artifactId} From a2d468f78dd801bbd31c745eade007452516a523 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Tue, 26 Aug 2025 13:07:42 +0530 Subject: [PATCH 15/97] SK-2258 add summary for bulk insert --- .../main/java/com/skyflow/logs/ErrorLogs.java | 2 + v3/src/main/java/com/skyflow/utils/Utils.java | 8 ++- .../vault/controller/VaultController.java | 63 +++++++++---------- .../com/skyflow/vault/data/InsertRequest.java | 18 +++--- 4 files changed, 47 insertions(+), 44 deletions(-) diff --git a/common/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java index 7a7745a8..9b329ac8 100644 --- a/common/src/main/java/com/skyflow/logs/ErrorLogs.java +++ b/common/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -128,6 +128,8 @@ public enum ErrorLogs { EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file and file path fields are both empty. Specify a valid file object or file path."), UNEXPECTED_ERROR_DURING_BATCH_PROCESSING("Unexpected error occurred during batch processing. Error: %s1"), + + PROCESSING_ERROR_RESPONSE("Processing error response.") ; private final String log; diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 7abc3a98..21245961 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -78,6 +78,9 @@ public static ErrorRecord createErrorRecord(Map recordMap, int i if (recordMap.containsKey("error")) { err.setError((String) recordMap.get("error")); } + if (recordMap.containsKey("message")) { + err.setError((String) recordMap.get("message")); + } if (recordMap.containsKey("http_code")) { err.setCode((Integer) recordMap.get("http_code")); } @@ -91,8 +94,7 @@ public static List handleBatchException( if (cause instanceof ApiClientApiException) { ApiClientApiException apiException = (ApiClientApiException) cause; Map responseBody = (Map) apiException.body(); - int indexNumber = batchNumber > 0 ? batchNumber * batches.get(batchNumber - 1).size() : 0; - + int indexNumber = batchNumber > 0 ? batchNumber * batch.size() : 0; if (responseBody != null) { if (responseBody.containsKey("records")) { Object recordss = responseBody.get("records"); @@ -117,7 +119,7 @@ public static List handleBatchException( } } } else { - int indexNumber = batchNumber > 0 ? batchNumber * batches.get(batchNumber - 1).size() : 0; + int indexNumber = batchNumber > 0 ? batchNumber * batch.size() : 0; for (int j = 0; j < batch.size(); j++) { ErrorRecord err = new ErrorRecord(); err.setIndex(indexNumber); diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 9631e429..604f0401 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -44,8 +45,8 @@ public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequ // validation LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); - int batchSize = 10; - int concurrencyLimit = 5; + int batchSize = 50; + int concurrencyLimit = 10; setBearerToken(); // calculate batch concurrency @@ -57,7 +58,23 @@ public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequ String bodyString = gson.toJson(e.body()); LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } catch (ExecutionException | InterruptedException e){ + LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); + throw new SkyflowException(e.getMessage()); + } + Summary summary = new Summary(); + summary.setTotalRecords(insertRequest.getValues().size()); + if (response.getSuccess() != null) { + summary.setTotalInserted(response.getSuccess().size()); + } else { + summary.setTotalInserted(0); } + if (response.getErrors() != null) { + summary.setTotalFailed(response.getErrors().size()); + } else { + summary.setTotalFailed(0); + } + response.setSummary(summary); return response; } @@ -98,16 +115,16 @@ public CompletableFuture bulkInsertAsync( } com.skyflow.vault.data.InsertResponse response1 = new com.skyflow.vault.data.InsertResponse(); + Summary summary = new Summary(); if (!successRecords1.isEmpty()) { response1.setSuccess(successRecords1); + summary.setTotalInserted(successRecords1.size()); } if (!errorRecords.isEmpty()) { response1.setErrors(errorRecords); + summary.setTotalFailed(errorRecords.size()); } - Summary summary = new Summary(); summary.setTotalRecords(insertRequest.getValues().size()); - summary.setTotalInserted(successRecords1.size()); - summary.setTotalFailed(errorRecords.size()); response1.setSummary(summary); return response1; }); @@ -120,12 +137,10 @@ public CompletableFuture bulkInsertAsync( private com.skyflow.vault.data.InsertResponse processSync( int batchSize, int concurrencyLimit, com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest - ) { + ) throws ExecutionException, InterruptedException { LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); - List> recordsToRetry = new ArrayList<>(); - try { List> futures = this.insertBatchFutures( batchSize, concurrencyLimit, insertRequest, errorRecords @@ -145,16 +160,6 @@ private com.skyflow.vault.data.InsertResponse processSync( } } } - } catch (InterruptedException e) { - LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.UNEXPECTED_ERROR_DURING_BATCH_PROCESSING.getLog(), e.getMessage())); - Thread.currentThread().interrupt(); - } catch (Exception e) { - LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.UNEXPECTED_ERROR_DURING_BATCH_PROCESSING.getLog(), e.getMessage())); - ErrorRecord err = new ErrorRecord(); - err.setError(e.getMessage()); - err.setCode(500); - errorRecords.add(err); - } com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(); if (!errorRecords.isEmpty()) { response.setErrors(errorRecords); @@ -183,8 +188,7 @@ private List> insertBat CompletableFuture future = CompletableFuture .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) .exceptionally(ex -> { - // retry logic -// recordsToRetry.addAll(batch.stream().map(InsertRecordData::getFields).toList()); + LogUtil.printInfoLog(ErrorLogs.PROCESSING_ERROR_RESPONSE.getLog()); errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); return null; }) @@ -197,17 +201,12 @@ private List> insertBat return futures; } - private InsertResponse insertBatch(List batch, String tableName) { - try { - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest req = com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest.builder() - .vaultId(this.getVaultConfig().getVaultId()) - .tableName(tableName) - .records(batch) - .build(); - return this.getRecordsApi().insert(req); - } catch (Exception e) { - LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); - return null; - } + private InsertResponse insertBatch(List batch, String tableName){ + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest req = com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest.builder() + .vaultId(this.getVaultConfig().getVaultId()) + .tableName(tableName) + .records(batch) + .build(); + return this.getRecordsApi().insert(req); } } diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java index 35d86d49..2cccf21f 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -18,9 +18,9 @@ public static InsertRequestBuilder builder() { return new InsertRequestBuilder(); } - public Boolean getReturnData() { - return this.builder.returnData; - } +// public Boolean getReturnData() { +// return this.builder.returnData; +// } public List getUpsert() { return this.builder.upsert; } @@ -32,14 +32,14 @@ public UpdateType getUpsertType() { // } public static final class InsertRequestBuilder extends BaseInsertRequestBuilder { - private Boolean returnData; +// private Boolean returnData; private List upsert; private UpdateType upsertType; private InsertRequestBuilder() { super(); - this.returnData = false; +// this.returnData = false; } @Override @@ -68,10 +68,10 @@ public InsertRequestBuilder upsertType(UpdateType upsertType) { // return this; // } - public InsertRequestBuilder returnData(Boolean returnData) { - this.returnData = returnData; - return this; - } +// public InsertRequestBuilder returnData(Boolean returnData) { +// this.returnData = returnData; +// return this; +// } public InsertRequest build() { return new InsertRequest(this); } From dcc691ecbc96496330b20aa235e3a3062972fe16 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:12:34 +0530 Subject: [PATCH 16/97] SK-2260: update bump version --- .github/workflows/shared-build-and-deploy.yml | 2 +- pom.xml | 2 +- scripts/bump_version.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index 6e8471e8..e3a81346 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -106,7 +106,7 @@ jobs: git checkout ${{ env.branch_name }} fi - git add pom.xml + git add v3/pom.xml if [[ "${{ inputs.tag }}" == "internal" ]]; then git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev-$(git rev-parse --short $GITHUB_SHA)" git push origin ${{ github.ref_name }} -f diff --git a/pom.xml b/pom.xml index 6d48cd82..e46408c7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow - 2.0.0-beta.2-dev.6309488 + 1.0.0 pom ${project.groupId}:${project.artifactId} diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index d729ea63..0112de76 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -1,7 +1,7 @@ # Input Arguments Version=$1 CommitHash=$2 -PomFile="$GITHUB_WORKSPACE/pom.xml" +PomFile="$GITHUB_WORKSPACE/v3/pom.xml" if [ -z "$Version" ]; then echo "Error: Version argument is required." From a6b915df3fc942115e1cc4e7731e4f4b392823df Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 07:42:59 +0000 Subject: [PATCH 17/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-dcc691e --- v3/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v3/pom.xml b/v3/pom.xml index a5261c7f..470c0df0 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow - 1.0.0 + 2.0.0-beta.2-dev.dcc691e ../pom.xml @@ -28,4 +28,4 @@ 1.0.0 - \ No newline at end of file + From c7eaaf9b9233d42877acbeda1ddf09e9b7251b41 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:21:45 +0530 Subject: [PATCH 18/97] SK-2260: update bump version --- scripts/bump_version.sh | 21 +++++++++++---------- v3/pom.xml | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 0112de76..c82f6bbf 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -26,15 +26,16 @@ if [ -z "$CommitHash" ]; then else echo "Bumping main project version to $Version-dev-$CommitHash" - awk -v version="$Version-dev.$CommitHash" ' - BEGIN { updated = 0 } - // && updated == 0 { - sub(/.*<\/version>/, "" version "") - updated = 1 - } - { print } - ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile + awk -v version="$Version${CommitHash:+-dev.$CommitHash}" ' + BEGIN { updated = 0 } + //,/<\/parent>/ { print; next } + // && updated == 0 { + sub(/.*<\/version>/, "" version "") + updated = 1 + } + { print } + ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile - echo "--------------------------" - echo "Done. Main project version now at $Version-dev.$CommitHash" +echo "--------------------------" +echo "Done. v3 module version now at $Version${CommitHash:+-dev.$CommitHash}" fi diff --git a/v3/pom.xml b/v3/pom.xml index 470c0df0..fbcccae7 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -6,7 +6,7 @@ com.skyflow skyflow - 2.0.0-beta.2-dev.dcc691e + 1.0.0 ../pom.xml From 07adbb852e9fdfe8f55a4e8b8f0add1a71591e3e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 07:52:06 +0000 Subject: [PATCH 19/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-c7eaaf9 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index fbcccae7..5766380c 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ v3 - 3.0.0-beta.0 + 2.0.0-beta.2-dev.c7eaaf9 jar From e7aedd63d3b12b09c82c12df857fb9a1b0e70b30 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 17:40:37 +0530 Subject: [PATCH 20/97] SK-2260: testing internal release --- v3/pom.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/v3/pom.xml b/v3/pom.xml index 5766380c..d837fcdf 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -28,4 +28,29 @@ 1.0.0 + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + com.skyflow:common + + + + + + + + From 7a330d67da354bc00c8cfbf10f7cb4baf39b483c Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:11:24 +0000 Subject: [PATCH 21/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-e7aedd6 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index d837fcdf..da4f58f8 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ v3 - 2.0.0-beta.2-dev.c7eaaf9 + 2.0.0-beta.2-dev.e7aedd6 jar From 8be1b71b2c7376c90e1e2928b3ade20263c198cc Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 17:51:58 +0530 Subject: [PATCH 22/97] SK-2260: testing internal release --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index e46408c7..a6178ecf 100644 --- a/pom.xml +++ b/pom.xml @@ -283,6 +283,14 @@ true + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + true + + From d7f302106cee878dc4ec7a94a6a6be352af1c275 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:22:34 +0000 Subject: [PATCH 23/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-8be1b71 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index da4f58f8..cb6c8450 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ v3 - 2.0.0-beta.2-dev.e7aedd6 + 2.0.0-beta.2-dev.8be1b71 jar From b6f95ec1cb980e2001ebe8f84961269ab125071c Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 17:56:07 +0530 Subject: [PATCH 24/97] SK-2260: testing v3 internal release --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index a6178ecf..95735543 100644 --- a/pom.xml +++ b/pom.xml @@ -247,6 +247,14 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + true + + From 642625e63178a169c6dcef02f362ec33fbac93ef Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:26:44 +0000 Subject: [PATCH 25/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-b6f95ec --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index cb6c8450..e9af60a4 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ v3 - 2.0.0-beta.2-dev.8be1b71 + 2.0.0-beta.2-dev.b6f95ec jar From 44b541291f3b22b79f0f57357503a3c78a33f34c Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 18:06:19 +0530 Subject: [PATCH 26/97] SK-2260: test v3 internal release --- v2/pom.xml | 2 +- v3/pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/v2/pom.xml b/v2/pom.xml index ff520627..e239bc85 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -10,7 +10,7 @@ ../pom.xml - v2 + skyflow-java 2.0.0-beta.3 com.skyflow diff --git a/v3/pom.xml b/v3/pom.xml index e9af60a4..68e75206 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -10,8 +10,8 @@ ../pom.xml - v3 - 2.0.0-beta.2-dev.b6f95ec + skyflow-java + 2.0.0-beta.2-dev.8be1b71 jar From f1b4e2f284e67f436dfbefc817704b6d956b5327 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:37:26 +0000 Subject: [PATCH 27/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-44b5412 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 68e75206..c085129e 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.8be1b71 + 2.0.0-beta.2-dev.44b5412 jar From e307a05312ddc09aebb587cd591bf139875ab1be Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 18:29:10 +0530 Subject: [PATCH 28/97] SK-2260: test v3 internal release --- pom.xml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 95735543..c2c4a3b0 100644 --- a/pom.xml +++ b/pom.xml @@ -252,7 +252,7 @@ maven-deploy-plugin 3.1.2 - true + ${project.packaging} == 'pom' @@ -291,14 +291,6 @@ true - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - true - - From 4362001df7ea2bcd89212aa2a7b307adb1862386 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 12:59:42 +0000 Subject: [PATCH 29/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-e307a05 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index c085129e..81d1ee4e 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.44b5412 + 2.0.0-beta.2-dev.e307a05 jar From 6db7be98ee9fc811ef73e7babe368757672b065f Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 18:35:24 +0530 Subject: [PATCH 30/97] SK-2260: test v3 internal release --- .github/workflows/shared-build-and-deploy.yml | 2 +- pom.xml | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index e3a81346..eae6b10f 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,7 +134,7 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} + mvn --batch-mode -pl v3 -am deploy -P jfrog else mvn --batch-mode deploy -P ${{ inputs.profile }} fi diff --git a/pom.xml b/pom.xml index c2c4a3b0..a8d03911 100644 --- a/pom.xml +++ b/pom.xml @@ -247,14 +247,7 @@ - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - ${project.packaging} == 'pom' - - + From 828ada1fe8a82162f2b2d65081e9055568ba9668 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:05:51 +0000 Subject: [PATCH 31/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-6db7be9 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 81d1ee4e..9ec409a6 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.e307a05 + 2.0.0-beta.2-dev.6db7be9 jar From de89bb5ffe5b87fd4a6e870197d2f71830751c1e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 18:37:21 +0530 Subject: [PATCH 32/97] SK-2260: test v3 internal release --- .github/workflows/shared-build-and-deploy.yml | 2 +- pom.xml | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index eae6b10f..e3a81346 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,7 +134,7 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl v3 -am deploy -P jfrog + mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} else mvn --batch-mode deploy -P ${{ inputs.profile }} fi diff --git a/pom.xml b/pom.xml index a8d03911..9dff635c 100644 --- a/pom.xml +++ b/pom.xml @@ -259,6 +259,26 @@ + + skip-deploy-parent + + + pom.xml + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + true + + + + + maven-central From 8fffde535026b0f9e466173adf16416d8427315e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:07:55 +0000 Subject: [PATCH 33/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-de89bb5 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 9ec409a6..239251b7 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.6db7be9 + 2.0.0-beta.2-dev.de89bb5 jar From 89a0c90e1253fad228c91d9ff43bbfdf670c7bb2 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 18:59:30 +0530 Subject: [PATCH 34/97] SK-2260: testting v3 internal release --- .github/workflows/shared-build-and-deploy.yml | 2 +- pom.xml | 36 +++++++++---------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index e3a81346..fd7d00c7 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,7 +134,7 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} + mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }},skip-parent-deploy else mvn --batch-mode deploy -P ${{ inputs.profile }} fi diff --git a/pom.xml b/pom.xml index 9dff635c..09a63766 100644 --- a/pom.xml +++ b/pom.xml @@ -259,26 +259,22 @@ - - skip-deploy-parent - - - pom.xml - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - true - - - - - + + + skip-parent-deploy + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + true + + + + + maven-central From 4a757398877cdd06ba0d4f6cd7ed651623cd9661 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:30:04 +0000 Subject: [PATCH 35/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-89a0c90 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 239251b7..cced6410 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.de89bb5 + 2.0.0-beta.2-dev.89a0c90 jar From 434107bb51659a0a75d7568909ea5604d9aa5dab Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:06:21 +0530 Subject: [PATCH 36/97] SK-2260: testing v3 internel release --- .github/workflows/shared-build-and-deploy.yml | 2 +- pom.xml | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index fd7d00c7..e3a81346 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,7 +134,7 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }},skip-parent-deploy + mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} else mvn --batch-mode deploy -P ${{ inputs.profile }} fi diff --git a/pom.xml b/pom.xml index 09a63766..95a68d3c 100644 --- a/pom.xml +++ b/pom.xml @@ -260,21 +260,6 @@ - - skip-parent-deploy - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - true - - - - - maven-central From 07caf2ee43703465cda390201d92220dfe2c8a7b Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:36:55 +0000 Subject: [PATCH 37/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-434107b --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index cced6410..41fc6f2a 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.89a0c90 + 2.0.0-beta.2-dev.434107b jar From de3258a96666ac0355266acefefb8c1f0e6dad42 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:11:00 +0530 Subject: [PATCH 38/97] SK-2260: testing v3 internel release --- pom.xml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pom.xml b/pom.xml index 95a68d3c..0f476259 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,29 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + + + ${maven.main.skip} + + + + default-deploy + deploy + + deploy + + + + ${maven.main.skip} + + + + org.apache.maven.plugins maven-source-plugin From 7887f0308c9d61cc7e023e19acd1f88a23d25d35 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:41:30 +0000 Subject: [PATCH 39/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-de3258a --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 41fc6f2a..38a60a4b 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.434107b + 2.0.0-beta.2-dev.de3258a jar From 1a8042948125e1c84a1ad4685e88b8795d09d627 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:20:29 +0530 Subject: [PATCH 40/97] SK-2260: testing v3 internel release --- pom.xml | 32 ++++++++------------------------ v3/pom.xml | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 0f476259..63352999 100644 --- a/pom.xml +++ b/pom.xml @@ -150,29 +150,6 @@ - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - - - ${maven.main.skip} - - - - default-deploy - deploy - - deploy - - - - ${maven.main.skip} - - - - org.apache.maven.plugins maven-source-plugin @@ -270,7 +247,14 @@ - + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + true + + diff --git a/v3/pom.xml b/v3/pom.xml index 38a60a4b..31099442 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -53,4 +53,22 @@ + + + + jfrog + + + central + prekarilabs.jfrog.io-releases + https://prekarilabs.jfrog.io/artifactory/skyflow-java + + + snapshots + prekarilabs.jfrog.io-snapshots + https://prekarilabs.jfrog.io/artifactory/skyflow-java + + + + From 65eef54c1d0e33655557cf73f404d90f0bce5007 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 13:51:05 +0000 Subject: [PATCH 41/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-1a80429 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 31099442..c1afb527 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.de3258a + 2.0.0-beta.2-dev.1a80429 jar From 1fe0b42ea708c95a7c7b1d2826711cdd7ee33b41 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:38:10 +0530 Subject: [PATCH 42/97] SK-2260: testing v3 internel release --- .github/workflows/shared-build-and-deploy.yml | 2 +- pom.xml | 55 ------------------- 2 files changed, 1 insertion(+), 56 deletions(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index e3a81346..eae6b10f 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,7 +134,7 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} + mvn --batch-mode -pl v3 -am deploy -P jfrog else mvn --batch-mode deploy -P ${{ inputs.profile }} fi diff --git a/pom.xml b/pom.xml index 63352999..b075d1ba 100644 --- a/pom.xml +++ b/pom.xml @@ -247,14 +247,6 @@ - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - true - - @@ -264,51 +256,4 @@ https://repo.maven.apache.org/maven2/ - - - - - maven-central - - - central - https://central.sonatype.com/api/v1/publisher/upload - - - central-snapshots - https://central.sonatype.com/api/v1/publisher/upload - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - true - - - - - - - jfrog - - - central - prekarilabs.jfrog.io-releases - https://prekarilabs.jfrog.io/artifactory/skyflow-java - - - snapshots - prekarilabs.jfrog.io-snapshots - https://prekarilabs.jfrog.io/artifactory/skyflow-java - - - - From 54b2ca30147c38e8b96215a96d0f458ad1f8c5f1 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 14:08:46 +0000 Subject: [PATCH 43/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-1fe0b42 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index c1afb527..68bdadb6 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.1a80429 + 2.0.0-beta.2-dev.1fe0b42 jar From bbc254c43ab6837d4d44c19cf05d52ac4ba2af0e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:43:41 +0530 Subject: [PATCH 44/97] SK-2260: testing v3 internel release --- v3/pom.xml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/v3/pom.xml b/v3/pom.xml index 68bdadb6..676bd700 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -54,21 +54,16 @@ - - - jfrog - - - central - prekarilabs.jfrog.io-releases - https://prekarilabs.jfrog.io/artifactory/skyflow-java - - - snapshots - prekarilabs.jfrog.io-snapshots - https://prekarilabs.jfrog.io/artifactory/skyflow-java - - - - + + + central + prekarilabs.jfrog.io-releases + https://prekarilabs.jfrog.io/artifactory/skyflow-java + + + snapshots + prekarilabs.jfrog.io-snapshots + https://prekarilabs.jfrog.io/artifactory/skyflow-java + + From db88b7130c12ce4a366b4134c1de0c20cefe5380 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 14:14:10 +0000 Subject: [PATCH 45/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-bbc254c --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 676bd700..199f8e94 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.1fe0b42 + 2.0.0-beta.2-dev.bbc254c jar From 27832c4bf6affa71a60e838419d0fd9684600e6e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:47:46 +0530 Subject: [PATCH 46/97] SK-2260: testing v3 internel release --- .github/workflows/shared-build-and-deploy.yml | 3 ++- pom.xml | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index eae6b10f..cc7a89e9 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,7 +134,8 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl v3 -am deploy -P jfrog + mvn --batch-mode -pl v3 -am deploy + else mvn --batch-mode deploy -P ${{ inputs.profile }} fi diff --git a/pom.xml b/pom.xml index b075d1ba..31546a94 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,14 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.2 + + true + + org.apache.maven.plugins maven-source-plugin From cc9f882afa084eced720f35470ef02bd3b871b3e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 14:18:16 +0000 Subject: [PATCH 47/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-27832c4 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 199f8e94..0ae683c7 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.bbc254c + 2.0.0-beta.2-dev.27832c4 jar From 358a3b0b0f2ab242e6891eb4492d56ba84a57b46 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 19:55:35 +0530 Subject: [PATCH 48/97] SK-2260: testing v3 internel release --- pom.xml | 9 +-------- v3/pom.xml | 2 ++ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 31546a94..d05008ce 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ + true 8 8 4.12.0 @@ -150,14 +151,6 @@ - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - true - - org.apache.maven.plugins maven-source-plugin diff --git a/v3/pom.xml b/v3/pom.xml index 0ae683c7..8da6acdc 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -18,9 +18,11 @@ 8 8 UTF-8 + false + com.skyflow From 79243cb7f92ff007e29dc32bd93969b35521cec6 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 14:26:06 +0000 Subject: [PATCH 49/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-358a3b0 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 8da6acdc..a3556ced 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.27832c4 + 2.0.0-beta.2-dev.358a3b0 jar From d79888bafabfedf2dfd00ed1a85047219b3af043 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 21:43:49 +0530 Subject: [PATCH 50/97] SK-2260: add distributionManagement in parent pom --- pom.xml | 19 ++++++++++++++++++- v3/pom.xml | 13 ------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index d05008ce..f7c1e9dd 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ - true + true 8 8 4.12.0 @@ -257,4 +257,21 @@ https://repo.maven.apache.org/maven2/ + + + jfrog + + + central + prekarilabs.jfrog.io-releases + https://prekarilabs.jfrog.io/artifactory/skyflow-java + + + snapshots + prekarilabs.jfrog.io-snapshots + https://prekarilabs.jfrog.io/artifactory/skyflow-java + + + + diff --git a/v3/pom.xml b/v3/pom.xml index a3556ced..5ca83e59 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -55,17 +55,4 @@ - - - - central - prekarilabs.jfrog.io-releases - https://prekarilabs.jfrog.io/artifactory/skyflow-java - - - snapshots - prekarilabs.jfrog.io-snapshots - https://prekarilabs.jfrog.io/artifactory/skyflow-java - - From 99db28cd3ed0bd9fa4e9843d152258f8d84a6055 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 16:14:30 +0000 Subject: [PATCH 51/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-d79888b --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 5ca83e59..18aae1ff 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.358a3b0 + 2.0.0-beta.2-dev.d79888b jar From 7db56c68016d0a00ea26175a8bea8d78a286cf0e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 21:47:03 +0530 Subject: [PATCH 52/97] SK-2260: update deploy command --- .github/workflows/shared-build-and-deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index cc7a89e9..eae6b10f 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -134,8 +134,7 @@ jobs: - name: Publish package run: | if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl v3 -am deploy - + mvn --batch-mode -pl v3 -am deploy -P jfrog else mvn --batch-mode deploy -P ${{ inputs.profile }} fi From b3283036c70be3aec46101dfebb34465a540a6bb Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 26 Aug 2025 16:17:34 +0000 Subject: [PATCH 53/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-7db56c6 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 18aae1ff..c13e031b 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.d79888b + 2.0.0-beta.2-dev.7db56c6 jar From 47f21ae648f00fd43448219c9e5806855e1e7cfc Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Tue, 26 Aug 2025 22:04:25 +0530 Subject: [PATCH 54/97] SK-2269 Add logic for configuring batchSize and concurrencyLimit - Add getRecordsToRetry implementation in InsertResponse - Refactored code for better code quality --- .../java/com/skyflow/errors/ErrorMessage.java | 1 + .../java/com/skyflow/logs/WarningLogs.java | 4 +- v3/src/main/java/com/skyflow/VaultClient.java | 5 +- .../java/com/skyflow/utils/Constants.java | 2 + v3/src/main/java/com/skyflow/utils/Utils.java | 24 ++- .../utils/validations/Validations.java | 1 - .../vault/controller/VaultController.java | 193 ++++++++++-------- .../com/skyflow/vault/data/InsertRequest.java | 19 +- .../skyflow/vault/data/InsertResponse.java | 42 +++- .../java/com/skyflow/vault/data/Summary.java | 33 +-- 10 files changed, 190 insertions(+), 134 deletions(-) diff --git a/common/src/main/java/com/skyflow/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/errors/ErrorMessage.java index e3b0bbbe..0084d727 100644 --- a/common/src/main/java/com/skyflow/errors/ErrorMessage.java +++ b/common/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -6,6 +6,7 @@ public enum ErrorMessage { // Client initialization VaultIdAlreadyInConfigList("%s0 Validation error. VaultId is present in an existing config. Specify a new vaultId in config."), VaultIdNotInConfigList("%s0 Validation error. VaultId is missing from the config. Specify the vaultIds from configs."), + OnlySingleVaultConfigAllowed("%s0 Validation error. A vault config already exists. Cannot add another vault config."), ConnectionIdAlreadyInConfigList("%s0 Validation error. ConnectionId is present in an existing config. Specify a connectionId in config."), ConnectionIdNotInConfigList("%s0 Validation error. ConnectionId is missing from the config. Specify the connectionIds from configs."), EmptyCredentials("%s0 Validation error. Invalid credentials. Credentials must not be empty."), diff --git a/common/src/main/java/com/skyflow/logs/WarningLogs.java b/common/src/main/java/com/skyflow/logs/WarningLogs.java index 8d49f056..8905ad12 100644 --- a/common/src/main/java/com/skyflow/logs/WarningLogs.java +++ b/common/src/main/java/com/skyflow/logs/WarningLogs.java @@ -1,7 +1,9 @@ package com.skyflow.logs; public enum WarningLogs { - OVERRIDING_EXISTING_VAULT_CONFIG("New vault config identified. Overriding existing vault config"); + INVALID_BATCH_SIZE_PROVIDED("Invalid value for batch size provided, switching to default value."), + INVALID_CONCURRENCY_LIMIT_PROVIDED("Invalid value for concurrency limit provided, switching to default value."), + ; private final String log; diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index 35ca6df5..aac01775 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -21,15 +21,12 @@ import com.skyflow.utils.validations.Validations; import io.github.cdimascio.dotenv.Dotenv; import io.github.cdimascio.dotenv.DotenvException; -import okhttp3.Dispatcher; import okhttp3.OkHttpClient; import okhttp3.Request; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; public class VaultClient { @@ -133,7 +130,7 @@ protected void updateExecutorInHTTP() { .build(); apiClientBuilder.httpClient(httpClient); } - protected InsertRequest getBUlkInsertRequestBody(com.skyflow.vault.data.InsertRequest request, VaultConfig config) throws SkyflowException { + protected InsertRequest getBulkInsertRequestBody(com.skyflow.vault.data.InsertRequest request, VaultConfig config) throws SkyflowException { List> values = request.getValues(); List insertRecordDataList = new ArrayList<>(); for (HashMap value : values) { diff --git a/v3/src/main/java/com/skyflow/utils/Constants.java b/v3/src/main/java/com/skyflow/utils/Constants.java index a8fd82ab..35d618c8 100644 --- a/v3/src/main/java/com/skyflow/utils/Constants.java +++ b/v3/src/main/java/com/skyflow/utils/Constants.java @@ -4,4 +4,6 @@ public class Constants extends BaseConstants { public static final String SDK_NAME = "Skyflow Java SDK "; public static final String SDK_VERSION = "3.0.0-beta.0"; public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; + public static final Integer BATCH_SIZE = 50; + public static final Integer CONCURRENCY_LIMIT = 10; } diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 21245961..15552dca 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -72,6 +72,7 @@ public static List> createBatches(List } return batches; } + public static ErrorRecord createErrorRecord(Map recordMap, int indexNumber) { ErrorRecord err = new ErrorRecord(); err.setIndex(indexNumber); @@ -86,6 +87,7 @@ public static ErrorRecord createErrorRecord(Map recordMap, int i } return err; } + public static List handleBatchException( Throwable ex, List batch, int batchNumber, List> batches ) { @@ -131,15 +133,17 @@ public static List handleBatchException( } return errorRecords; } - public static com.skyflow.vault.data.InsertResponse formatResponse(InsertResponse response, int batch, int batchSize){ - com.skyflow.vault.data.InsertResponse response1 = new com.skyflow.vault.data.InsertResponse(); + + public static com.skyflow.vault.data.InsertResponse formatResponse(InsertResponse response, int batch, int batchSize) { + com.skyflow.vault.data.InsertResponse formattedResponse = null; List successRecords = new ArrayList<>(); List errorRecords = new ArrayList<>(); if (response != null) { List record = response.getRecords().get(); - int indexNumber = (batch) * batchSize; - for(int index = 0; index < response.getRecords().get().size(); index++) { - if (record.get(index).getError().isPresent()){ + int indexNumber = batch * batchSize; + int recordsSize = response.getRecords().get().size(); + for (int index = 0; index < recordsSize; index++) { + if (record.get(index).getError().isPresent()) { ErrorRecord errorRecord = new ErrorRecord(); errorRecord.setIndex(indexNumber); errorRecord.setError(record.get(index).getError().get()); @@ -151,7 +155,7 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons success.setIndex(indexNumber); success.setSkyflowId(record.get(index).getSkyflowId().get()); // success.setData(record.get(index).getData().get()); - if(record.get(index).getTokens().isPresent()) { + if (record.get(index).getTokens().isPresent()) { List tokens = null; Map tok = record.get(index).getTokens().get(); for (int i = 0; i < tok.size(); i++) { @@ -167,10 +171,12 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons } indexNumber++; } - response1.setSuccess(successRecords); - response1.setErrors(errorRecords); + + formattedResponse = new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords); +// formattedResponse.setSuccessRecords(successRecords); +// formattedResponse.setErrorRecords(errorRecords); } - return response1; + return formattedResponse; } } diff --git a/v3/src/main/java/com/skyflow/utils/validations/Validations.java b/v3/src/main/java/com/skyflow/utils/validations/Validations.java index 6613c7d3..8958456d 100644 --- a/v3/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/v3/src/main/java/com/skyflow/utils/validations/Validations.java @@ -18,7 +18,6 @@ private Validations() { super(); } - // add validations specific to v3 SDK public static void validateInsertRequest(InsertRequest insertRequest) throws SkyflowException { String table = insertRequest.getTable(); ArrayList> values = insertRequest.getValues(); diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 604f0401..7fb9a5b3 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -11,17 +11,19 @@ import com.skyflow.generated.rest.types.InsertResponse; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; +import com.skyflow.logs.WarningLogs; +import com.skyflow.utils.Constants; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; import com.skyflow.vault.data.ErrorRecord; import com.skyflow.vault.data.InsertRequest; import com.skyflow.vault.data.Success; -import com.skyflow.vault.data.Summary; +import io.github.cdimascio.dotenv.Dotenv; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -32,81 +34,72 @@ public final class VaultController extends VaultClient { private static final Gson gson = new GsonBuilder().serializeNulls().create(); + private int batchSize; + private int concurrencyLimit; public VaultController(VaultConfig vaultConfig, Credentials credentials) { super(vaultConfig, credentials); + this.batchSize = Constants.BATCH_SIZE; + this.concurrencyLimit = Constants.CONCURRENCY_LIMIT; } - // add methods for v3 SDK public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequest) throws SkyflowException { com.skyflow.vault.data.InsertResponse response; LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); try { - // validation LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); - int batchSize = 50; - int concurrencyLimit = 10; setBearerToken(); - // calculate batch concurrency + configureConcurrencyAndBatchSize(insertRequest.getValues().size()); + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); - // req - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBUlkInsertRequestBody(insertRequest, super.getVaultConfig()); - - response = this.processSync(batchSize, concurrencyLimit, request); + response = this.processSync(request, insertRequest.getValues()); + return response; } catch (ApiClientApiException e) { String bodyString = gson.toJson(e.body()); LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); - } catch (ExecutionException | InterruptedException e){ + } catch (ExecutionException | InterruptedException e) { LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); throw new SkyflowException(e.getMessage()); } - Summary summary = new Summary(); - summary.setTotalRecords(insertRequest.getValues().size()); - if (response.getSuccess() != null) { - summary.setTotalInserted(response.getSuccess().size()); - } else { - summary.setTotalInserted(0); - } - if (response.getErrors() != null) { - summary.setTotalFailed(response.getErrors().size()); - } else { - summary.setTotalFailed(0); - } - response.setSummary(summary); - return response; +// Summary summary = new Summary(); +// summary.setTotalRecords(insertRequest.getValues().size()); +// if (response.getSuccessRecords() != null) { +// summary.setTotalInserted(response.getSuccessRecords().size()); +// } else { +// summary.setTotalInserted(0); +// } +// if (response.getErrorRecords() != null) { +// summary.setTotalFailed(response.getErrorRecords().size()); +// } else { +// summary.setTotalFailed(0); +// } +// response.setSummary(summary); +// return response; } public CompletableFuture bulkInsertAsync(InsertRequest insertRequest) throws SkyflowException { LogUtil.printInfoLog(InfoLogs.INSERT_TRIGGERED.getLog()); try { - // validation LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); - int batchSize = 50; - int concurrencyLimit = 10; setBearerToken(); - // calculate batch concurrency - - // req - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBUlkInsertRequestBody(insertRequest, super.getVaultConfig()); + configureConcurrencyAndBatchSize(insertRequest.getValues().size()); + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); List errorRecords = new ArrayList<>(); - - List> futures = this.insertBatchFutures( - batchSize, concurrencyLimit, request, errorRecords - ); + List> futures = this.insertBatchFutures(request, errorRecords); return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) .thenApply(v -> { - List successRecords1 = new ArrayList<>(); + List successRecords = new ArrayList<>(); for (CompletableFuture future : futures) { com.skyflow.vault.data.InsertResponse futureResponse = future.join(); if (futureResponse != null) { if (futureResponse.getSuccess() != null) { - successRecords1.addAll(futureResponse.getSuccess()); + successRecords.addAll(futureResponse.getSuccess()); } if (futureResponse.getErrors() != null) { errorRecords.addAll(futureResponse.getErrors()); @@ -114,19 +107,19 @@ public CompletableFuture bulkInsertAsync( } } - com.skyflow.vault.data.InsertResponse response1 = new com.skyflow.vault.data.InsertResponse(); - Summary summary = new Summary(); - if (!successRecords1.isEmpty()) { - response1.setSuccess(successRecords1); - summary.setTotalInserted(successRecords1.size()); - } - if (!errorRecords.isEmpty()) { - response1.setErrors(errorRecords); - summary.setTotalFailed(errorRecords.size()); - } - summary.setTotalRecords(insertRequest.getValues().size()); - response1.setSummary(summary); - return response1; + return new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, insertRequest.getValues()); +// Summary summary = new Summary(); +// if (!successRecords.isEmpty()) { +// response.setSuccessRecords(successRecords); +// summary.setTotalInserted(successRecords.size()); +// } +// if (!errorRecords.isEmpty()) { +// response.setErrorRecords(errorRecords); +// summary.setTotalFailed(errorRecords.size()); +// } +// summary.setTotalRecords(insertRequest.getValues().size()); +// response.setSummary(summary); +// return response; }); } catch (ApiClientApiException e) { String bodyString = gson.toJson(e.body()); @@ -136,44 +129,43 @@ public CompletableFuture bulkInsertAsync( } private com.skyflow.vault.data.InsertResponse processSync( - int batchSize, int concurrencyLimit, com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, + ArrayList> originalPayload ) throws ExecutionException, InterruptedException { LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); - List> futures = this.insertBatchFutures( - batchSize, concurrencyLimit, insertRequest, errorRecords - ); - - CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); - allFutures.join(); - - for (CompletableFuture future : futures) { - com.skyflow.vault.data.InsertResponse futureResponse = future.get(); - if (futureResponse != null) { - if (futureResponse.getSuccess() != null) { - successRecords.addAll(futureResponse.getSuccess()); - } - if (futureResponse.getErrors() != null) { - errorRecords.addAll(futureResponse.getErrors()); - } + List> futures = this.insertBatchFutures(insertRequest, errorRecords); + + CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); + allFutures.join(); + + for (CompletableFuture future : futures) { + com.skyflow.vault.data.InsertResponse futureResponse = future.get(); + if (futureResponse != null) { + if (futureResponse.getSuccess() != null) { + successRecords.addAll(futureResponse.getSuccess()); + } + if (futureResponse.getErrors() != null) { + errorRecords.addAll(futureResponse.getErrors()); } } - com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(); - if (!errorRecords.isEmpty()) { - response.setErrors(errorRecords); - } - if (!successRecords.isEmpty()) { - response.setSuccess(successRecords); } + com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, originalPayload); +// if (!errorRecords.isEmpty()) { +// response.setErrorRecords(errorRecords); +// } +// if (!successRecords.isEmpty()) { +// response.setSuccessRecords(successRecords); +// } LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); return response; } private List> insertBatchFutures( - int batchSize, int concurrencyLimit, com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords ) { List records = insertRequest.getRecords().get(); @@ -182,9 +174,9 @@ private List> insertBat List> futures = new ArrayList<>(); try { - for (int i = 0; i < batches.size(); i++) { - List batch = batches.get(i); - int batchNumber = i; + for (int batchIndex = 0; batchIndex < batches.size(); batchIndex++) { + List batch = batches.get(batchIndex); + int batchNumber = batchIndex; CompletableFuture future = CompletableFuture .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) .exceptionally(ex -> { @@ -201,7 +193,7 @@ private List> insertBat return futures; } - private InsertResponse insertBatch(List batch, String tableName){ + private InsertResponse insertBatch(List batch, String tableName) { com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest req = com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest.builder() .vaultId(this.getVaultConfig().getVaultId()) .tableName(tableName) @@ -209,4 +201,45 @@ private InsertResponse insertBatch(List batch, String tableNam .build(); return this.getRecordsApi().insert(req); } + + private void configureConcurrencyAndBatchSize(int totalRequests) { + Dotenv dotenv = Dotenv.load(); + String userProvidedBatchSize = dotenv.get("BATCH_SIZE"); + String userProvidedConcurrencyLimit = dotenv.get("CONCURRENCY_LIMIT"); + + if (userProvidedBatchSize != null) { + try { + int batchSize = Integer.parseInt(userProvidedBatchSize); + if (batchSize > 0) { + this.batchSize = batchSize; + } else { + LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); + this.batchSize = Constants.BATCH_SIZE; + } + } catch (NumberFormatException e) { + LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); + this.batchSize = Constants.BATCH_SIZE; + } + } + + // Max no of threads required to run all batches concurrently at once + int maxConcurrencyNeeded = (totalRequests + this.batchSize - 1) / this.batchSize; + + if (userProvidedConcurrencyLimit != null) { + try { + int concurrencyLimit = Integer.parseInt(userProvidedConcurrencyLimit); + if (concurrencyLimit > 0) { + this.concurrencyLimit = Math.min(concurrencyLimit, maxConcurrencyNeeded); + } else { + LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); + this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } catch (NumberFormatException e) { + LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); + this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } else { + this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } } diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java index 2cccf21f..732df960 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -18,28 +18,21 @@ public static InsertRequestBuilder builder() { return new InsertRequestBuilder(); } -// public Boolean getReturnData() { -// return this.builder.returnData; -// } public List getUpsert() { return this.builder.upsert; } + public UpdateType getUpsertType() { return this.builder.upsertType; } -// public Boolean getReturnTokens() { -// return this.builder.returnTokens; -// } public static final class InsertRequestBuilder extends BaseInsertRequestBuilder { -// private Boolean returnData; private List upsert; private UpdateType upsertType; private InsertRequestBuilder() { super(); -// this.returnData = false; } @Override @@ -58,20 +51,12 @@ public InsertRequestBuilder upsert(List upsert) { this.upsert = upsert; return this; } + public InsertRequestBuilder upsertType(UpdateType upsertType) { this.upsertType = upsertType; return this; } -// @Override -// public InsertRequestBuilder returnTokens(Boolean returnTokens) { -// super.returnTokens(returnTokens); -// return this; -// } -// public InsertRequestBuilder returnData(Boolean returnData) { -// this.returnData = returnData; -// return this; -// } public InsertRequest build() { return new InsertRequest(this); } diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 4f19d6ec..36fd9dab 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -1,18 +1,43 @@ package com.skyflow.vault.data; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; public class InsertResponse { + // These members will be included in the toString() output + @Expose private Summary summary; + @Expose private List success; + @Expose private List errors; + // Internal fields. Should not be included in toString() output + private ArrayList> originalPayload; private List> recordsToRetry; + public InsertResponse(List successRecords, List errorRecords) { + this.success = successRecords; + this.errors = errorRecords; + } + + public InsertResponse( + List successRecords, + List errorRecords, + ArrayList> originalPayload + ) { + this.success = successRecords; + this.errors = errorRecords; + this.originalPayload = originalPayload; + this.summary = new Summary(this.originalPayload.size(), this.success.size(), this.errors.size()); + } + public Summary getSummary() { return summary; } @@ -37,23 +62,20 @@ public void setErrors(List errors) { this.errors = errors; } - public void setRecordsToRetry(List> records) { - if(recordsToRetry == null){ - recordsToRetry = records; - } else { - recordsToRetry.addAll(records); - } - } public List> getRecordsToRetry() { - if(recordsToRetry == null){ - return new ArrayList<>(); + if (recordsToRetry == null) { + recordsToRetry = new ArrayList<>(); + for (ErrorRecord errorRecord : errors) { + int index = errorRecord.getIndex(); + recordsToRetry.add(originalPayload.get(index)); + } } return recordsToRetry; } @Override public String toString() { - Gson gson = new Gson(); + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); return gson.toJson(this); } } \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/Summary.java b/v3/src/main/java/com/skyflow/vault/data/Summary.java index 643a37d7..5afb988f 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Summary.java +++ b/v3/src/main/java/com/skyflow/vault/data/Summary.java @@ -3,32 +3,41 @@ import com.google.gson.Gson; public class Summary { - private int total_records; - private int total_inserted; - private int total_failed; + private int totalRecords; + private int totalInserted; + private int totalFailed; + + public Summary() { + } + + public Summary(int totalRecords, int totalInserted, int totalFailed) { + this.totalRecords = totalRecords; + this.totalInserted = totalInserted; + this.totalFailed = totalFailed; + } public int getTotalRecords() { - return total_records; + return totalRecords; } - public void setTotalRecords(int total_records) { - this.total_records = total_records; + public void setTotalRecords(int totalRecords) { + this.totalRecords = totalRecords; } public int getTotalInserted() { - return total_inserted; + return totalInserted; } - public void setTotalInserted(int total_inserted) { - this.total_inserted = total_inserted; + public void setTotalInserted(int totalInserted) { + this.totalInserted = totalInserted; } public int getTotalFailed() { - return total_failed; + return totalFailed; } - public void setTotalFailed(int total_failed) { - this.total_failed = total_failed; + public void setTotalFailed(int totalFailed) { + this.totalFailed = totalFailed; } @Override From 16be91e630fe3d619d42d2ce01570afa5af553c2 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 10:15:59 +0530 Subject: [PATCH 55/97] SK-2258 fix default concurrency limit logic --- v3/src/main/java/com/skyflow/utils/Utils.java | 14 +- .../utils/validations/Validations.java | 5 + .../vault/controller/VaultController.java | 59 +- .../com/skyflow/vault/data/ErrorRecord.java | 14 +- .../skyflow/vault/data/InsertResponse.java | 32 +- .../java/com/skyflow/vault/data/Success.java | 32 +- .../java/com/skyflow/vault/data/Summary.java | 22 +- .../java/com/skyflow/vault/data/Token.java | 12 +- .../java/com/skyflow/utils/UtilsTests.java | 595 +++++++++++++++++- .../controller/VaultControllerTests.java | 218 +++++++ .../com/skyflow/vault/data/InsertTests.java | 269 ++++++++ 11 files changed, 1198 insertions(+), 74 deletions(-) create mode 100644 v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java create mode 100644 v3/test/java/com/skyflow/vault/data/InsertTests.java diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 69701d5e..d9f812b9 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -103,16 +103,16 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons int recordsSize = response.getRecords().get().size(); for (int index = 0; index < recordsSize; index++) { if (record.get(index).getError().isPresent()) { - ErrorRecord errorRecord = new ErrorRecord(); - errorRecord.setIndex(indexNumber); - errorRecord.setError(record.get(index).getError().get()); - errorRecord.setCode(record.get(index).getHttpCode().get()); + ErrorRecord errorRecord = new ErrorRecord(indexNumber, record.get(index).getError().get(), record.get(index).getHttpCode().get()); +// errorRecord.setIndex(indexNumber); +// errorRecord.setError(record.get(index).getError().get()); +// errorRecord.setCode(record.get(index).getHttpCode().get()); errorRecords.add(errorRecord); // errorRecord.setCode(record.get(index).getError().get().getCode()); } else { - Success success = new Success(); - success.setIndex(indexNumber); - success.setSkyflowId(record.get(index).getSkyflowId().get()); + Success success = new Success(index, record.get(index).getSkyflowId().get(), null, null); +// success.setIndex(indexNumber); +// success.setSkyflowId(record.get(index).getSkyflowId().get()); // success.setData(record.get(index).getData().get()); if (record.get(index).getTokens().isPresent()) { List tokens = null; diff --git a/v3/src/main/java/com/skyflow/utils/validations/Validations.java b/v3/src/main/java/com/skyflow/utils/validations/Validations.java index 8958456d..247cc701 100644 --- a/v3/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/v3/src/main/java/com/skyflow/utils/validations/Validations.java @@ -18,6 +18,7 @@ private Validations() { super(); } + // add validations specific to v3 SDK public static void validateInsertRequest(InsertRequest insertRequest) throws SkyflowException { String table = insertRequest.getTable(); ArrayList> values = insertRequest.getValues(); @@ -43,6 +44,10 @@ public static void validateInsertRequest(InsertRequest insertRequest) throws Sky ErrorLogs.EMPTY_VALUES.getLog(), InterfaceName.INSERT.getName() )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValues.getMessage()); + } else if (upsert != null && upsert.isEmpty()){ + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_UPSERT.getLog(), InterfaceName.INSERT.getName() + )); } // upsert diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 7fb9a5b3..9ec27f94 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -203,43 +203,50 @@ private InsertResponse insertBatch(List batch, String tableNam } private void configureConcurrencyAndBatchSize(int totalRequests) { - Dotenv dotenv = Dotenv.load(); - String userProvidedBatchSize = dotenv.get("BATCH_SIZE"); - String userProvidedConcurrencyLimit = dotenv.get("CONCURRENCY_LIMIT"); - - if (userProvidedBatchSize != null) { - try { - int batchSize = Integer.parseInt(userProvidedBatchSize); - if (batchSize > 0) { - this.batchSize = batchSize; - } else { + try { + Dotenv dotenv = Dotenv.load(); + String userProvidedBatchSize = dotenv.get("BATCH_SIZE"); + String userProvidedConcurrencyLimit = dotenv.get("CONCURRENCY_LIMIT"); + + if (userProvidedBatchSize != null) { + try { + int batchSize = Integer.parseInt(userProvidedBatchSize); + if (batchSize > 0) { + this.batchSize = batchSize; + } else { + LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); + this.batchSize = Constants.BATCH_SIZE; + } + } catch (NumberFormatException e) { LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); this.batchSize = Constants.BATCH_SIZE; } - } catch (NumberFormatException e) { - LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); - this.batchSize = Constants.BATCH_SIZE; } - } - // Max no of threads required to run all batches concurrently at once - int maxConcurrencyNeeded = (totalRequests + this.batchSize - 1) / this.batchSize; - - if (userProvidedConcurrencyLimit != null) { - try { - int concurrencyLimit = Integer.parseInt(userProvidedConcurrencyLimit); - if (concurrencyLimit > 0) { - this.concurrencyLimit = Math.min(concurrencyLimit, maxConcurrencyNeeded); - } else { + // Max no of threads required to run all batches concurrently at once + int maxConcurrencyNeeded = (totalRequests + this.batchSize - 1) / this.batchSize; + + if (userProvidedConcurrencyLimit != null) { + try { + int concurrencyLimit = Integer.parseInt(userProvidedConcurrencyLimit); + if (concurrencyLimit > 0) { + this.concurrencyLimit = Math.min(concurrencyLimit, maxConcurrencyNeeded); + } else { + LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); + this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } catch (NumberFormatException e) { LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); } - } catch (NumberFormatException e) { - LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); + } else { this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); } - } else { + } catch (Exception e) { + this.batchSize = Constants.BATCH_SIZE; + int maxConcurrencyNeeded = (totalRequests + this.batchSize - 1) / this.batchSize; this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } + } diff --git a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java index 2f81d2f6..cd33e1fb 100644 --- a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java +++ b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java @@ -1,16 +1,28 @@ package com.skyflow.vault.data; import com.google.gson.Gson; +import com.google.gson.annotations.Expose; public class ErrorRecord { + @Expose(serialize = true) private int index; + @Expose(serialize = true) private String error; - + @Expose(serialize = true) private int code; public int getIndex() { return index; } + public ErrorRecord() { + } + + public ErrorRecord(int index, String error, int code) { + this.index = index; + this.error = error; + this.code = code; + } + public void setIndex(int index) { this.index = index; } diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 36fd9dab..0ae6b633 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -11,11 +11,11 @@ public class InsertResponse { // These members will be included in the toString() output - @Expose + @Expose(serialize = true) private Summary summary; - @Expose + @Expose(serialize = true) private List success; - @Expose + @Expose(serialize = true) private List errors; // Internal fields. Should not be included in toString() output @@ -39,28 +39,28 @@ public InsertResponse( } public Summary getSummary() { - return summary; + return this.summary; } - public void setSummary(Summary summary) { - this.summary = summary; - } +// public void setSummary(Summary summary) { +// this.summary = summary; +// } public List getSuccess() { - return success; + return this.success; } - public void setSuccess(List success) { - this.success = success; - } +// public void setSuccess(List success) { +// this.success = success; +// } public List getErrors() { - return errors; + return this.errors; } - public void setErrors(List errors) { - this.errors = errors; - } +// public void setErrors(List errors) { +// this.errors = errors; +// } public List> getRecordsToRetry() { if (recordsToRetry == null) { @@ -70,7 +70,7 @@ public List> getRecordsToRetry() { recordsToRetry.add(originalPayload.get(index)); } } - return recordsToRetry; + return this.recordsToRetry; } @Override diff --git a/v3/src/main/java/com/skyflow/vault/data/Success.java b/v3/src/main/java/com/skyflow/vault/data/Success.java index 5f2d38d3..293475c6 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Success.java +++ b/v3/src/main/java/com/skyflow/vault/data/Success.java @@ -1,46 +1,58 @@ package com.skyflow.vault.data; import com.google.gson.Gson; +import com.google.gson.annotations.Expose; import java.util.List; import java.util.Map; public class Success { + @Expose(serialize = true) private int index; + @Expose(serialize = true) private String skyflow_id; + @Expose(serialize = true) private Map> tokens; + @Expose(serialize = true) private Map data; public int getIndex() { return index; } - public void setIndex(int index) { + public Success(int index, String skyflow_id, Map> tokens, Map data) { this.index = index; + this.skyflow_id = skyflow_id; + this.tokens = tokens; + this.data = data; } +// public void setIndex(int index) { +// this.index = index; +// } + public String getSkyflowId() { return skyflow_id; } - public void setSkyflowId(String skyflow_id) { - this.skyflow_id = skyflow_id; - } +// public void setSkyflowId(String skyflow_id) { +// this.skyflow_id = skyflow_id; +// } public Map> getTokens() { return tokens; } - public void setTokens(Map> tokens) { - this.tokens = tokens; - } +// public void setTokens(Map> tokens) { +// this.tokens = tokens; +// } public Map getData() { return data; } - public void setData(Map data) { - this.data = data; - } +// public void setData(Map data) { +// this.data = data; +// } @Override public String toString() { Gson gson = new Gson(); diff --git a/v3/src/main/java/com/skyflow/vault/data/Summary.java b/v3/src/main/java/com/skyflow/vault/data/Summary.java index 5afb988f..b5a18452 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Summary.java +++ b/v3/src/main/java/com/skyflow/vault/data/Summary.java @@ -1,10 +1,14 @@ package com.skyflow.vault.data; import com.google.gson.Gson; +import com.google.gson.annotations.Expose; public class Summary { + @Expose(serialize = true) private int totalRecords; + @Expose(serialize = true) private int totalInserted; + @Expose(serialize = true) private int totalFailed; public Summary() { @@ -20,25 +24,25 @@ public int getTotalRecords() { return totalRecords; } - public void setTotalRecords(int totalRecords) { - this.totalRecords = totalRecords; - } +// public void setTotalRecords(int totalRecords) { +// this.totalRecords = totalRecords; +// } public int getTotalInserted() { return totalInserted; } - public void setTotalInserted(int totalInserted) { - this.totalInserted = totalInserted; - } +// public void setTotalInserted(int totalInserted) { +// this.totalInserted = totalInserted; +// } public int getTotalFailed() { return totalFailed; } - public void setTotalFailed(int totalFailed) { - this.totalFailed = totalFailed; - } +// public void setTotalFailed(int totalFailed) { +// this.totalFailed = totalFailed; +// } @Override public String toString() { diff --git a/v3/src/main/java/com/skyflow/vault/data/Token.java b/v3/src/main/java/com/skyflow/vault/data/Token.java index cde8cb97..e29e1c41 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Token.java +++ b/v3/src/main/java/com/skyflow/vault/data/Token.java @@ -1,16 +1,20 @@ package com.skyflow.vault.data; +import com.google.gson.annotations.Expose; + public class Token { + @Expose(serialize = true) private String token; + @Expose(serialize = true) private String tokenGroupName; public String getToken() { return token; } - public void setToken(String token) { - this.token = token; - } +// public void setToken(String token) { +// this.token = token; +// } public String getTokenGroupName() { return tokenGroupName; @@ -19,4 +23,6 @@ public String getTokenGroupName() { public void setTokenGroupName(String tokenGroupName) { this.tokenGroupName = tokenGroupName; } + + } \ No newline at end of file diff --git a/v3/test/java/com/skyflow/utils/UtilsTests.java b/v3/test/java/com/skyflow/utils/UtilsTests.java index 096a4ec6..d066f71b 100644 --- a/v3/test/java/com/skyflow/utils/UtilsTests.java +++ b/v3/test/java/com/skyflow/utils/UtilsTests.java @@ -1,20 +1,128 @@ package com.skyflow.utils; import com.google.gson.JsonObject; +import com.skyflow.config.Credentials; +import com.skyflow.enums.Env; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.types.InsertRecordData; +import com.skyflow.generated.rest.types.InsertResponse; +import com.skyflow.generated.rest.types.RecordResponseObject; +import com.skyflow.vault.data.ErrorRecord; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; +import java.util.*; + public class UtilsTests { 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 clusterId = null; + private static String url = null; + private static String filePath = null; + private static String credentialsString = null; + private static String token = null; + private static String context = null; + private static ArrayList roles = null; + + @BeforeClass + public static void setup() { + clusterId = "test_cluster_id"; + url = "https://test-url.com/java/unit/tests"; + filePath = "invalid/file/path/credentials.json"; + credentialsString = "invalid credentials string"; + token = "invalid-token"; + context = "test_context"; + roles = new ArrayList<>(); + String role = "test_role"; + roles.add(role); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); + } + + @Test + public void testGetVaultURLForDifferentENVs() { + try { + Map map = new HashMap<>(); + map.put(Env.DEV, "https://test_cluster_id.vault.skyflowapis.dev"); + map.put(Env.STAGE, "https://test_cluster_id.vault.skyflowapis.tech"); + map.put(Env.SANDBOX, "https://test_cluster_id.vault.skyflowapis-preview.com"); + map.put(Env.PROD, "https://test_cluster_id.vault.skyflowapis.com"); + + for (Env env : map.keySet()) { + String vaultURL = Utils.getV2VaultURL(clusterId, env); + Assert.assertEquals(map.get(env), vaultURL); + } + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testGetBaseURL() { + try { + String baseURL = Utils.getBaseURL(url); + String url = "https://test-url.com"; + Assert.assertEquals(url, baseURL); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testGenerateBearerTokenWithCredentialsFile() { + try { + Credentials credentials = new Credentials(); + credentials.setPath(filePath); + credentials.setContext(context); + credentials.setRoles(roles); + Utils.generateBearerToken(credentials); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.FileNotFound.getMessage(), filePath), + e.getMessage() + ); + } + } + + @Test + public void testGenerateBearerTokenWithCredentialsString() { + try { + Credentials credentials = new Credentials(); + credentials.setCredentialsString(credentialsString); + credentials.setContext(context); + credentials.setRoles(roles); + Utils.generateBearerToken(credentials); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals(ErrorMessage.CredentialsStringInvalidJson.getMessage(), e.getMessage()); + } + } + + @Test + public void testGenerateBearerTokenWithToken() { + try { + Credentials credentials = new Credentials(); + credentials.setToken(token); + credentials.setContext(context); + credentials.setRoles(roles); + String bearerToken = Utils.generateBearerToken(credentials); + Assert.assertEquals(token, bearerToken); + } catch (SkyflowException e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } @Test public void testGetMetrics() { try { JsonObject metrics = Utils.getMetrics(); - String sdkVersion = Constants.SDK_VERSION; Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_NAME_VERSION)); - Assert.assertEquals("skyflow-java@" + sdkVersion, metrics.get(Constants.SDK_METRIC_NAME_VERSION).getAsString()); Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL)); Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_CLIENT_OS_DETAILS)); Assert.assertNotNull(metrics.get(Constants.SDK_METRIC_RUNTIME_DETAILS)); @@ -22,4 +130,487 @@ public void testGetMetrics() { Assert.fail(INVALID_EXCEPTION_THROWN); } } + + @Test + public void testGetMetricsWithException() { + try { + // Clearing System Properties explicitly to throw exception + System.clearProperty("os.name"); + System.clearProperty("os.version"); + System.clearProperty("java.version"); + + String sdkVersion = Constants.SDK_VERSION; + JsonObject metrics = Utils.getMetrics(); + Assert.assertEquals("skyflow-java@" + sdkVersion, metrics.get(Constants.SDK_METRIC_NAME_VERSION).getAsString()); + Assert.assertEquals("Java@", metrics.get(Constants.SDK_METRIC_RUNTIME_DETAILS).getAsString()); + Assert.assertTrue(metrics.get(Constants.SDK_METRIC_CLIENT_DEVICE_MODEL).getAsString().isEmpty()); + Assert.assertTrue(metrics.get(Constants.SDK_METRIC_CLIENT_OS_DETAILS).getAsString().isEmpty()); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + @Test + public void testCreateBatches() { + List records = new ArrayList<>(); + for (int i = 0; i < 125; i++) { + records.add(InsertRecordData.builder().build()); + } + + List> batches = Utils.createBatches(records, 50); + + Assert.assertEquals(3, batches.size()); + Assert.assertEquals(50, batches.get(0).size()); + Assert.assertEquals(50, batches.get(1).size()); + Assert.assertEquals(25, batches.get(2).size()); + } + @Test + public void testCreateBatchesWithEmptyList() { + List records = new ArrayList<>(); + List> batches = Utils.createBatches(records, 50); + + Assert.assertTrue("Batches should be empty for empty input", batches.isEmpty()); + } + + @Test + public void testCreateBatchesWithSmallerSizeThanBatch() { + List records = new ArrayList<>(); + for (int i = 0; i < 25; i++) { + records.add(InsertRecordData.builder().build()); + } + + List> batches = Utils.createBatches(records, 50); + + Assert.assertEquals("Should create single batch", 1, batches.size()); + Assert.assertEquals("Batch should contain all records", 25, batches.get(0).size()); + } + + @Test + public void testCreateBatchesWithExactBatchSize() { + List records = new ArrayList<>(); + for (int i = 0; i < 50; i++) { + records.add(InsertRecordData.builder().build()); + } + + List> batches = Utils.createBatches(records, 50); + + Assert.assertEquals("Should create single batch", 1, batches.size()); + Assert.assertEquals("Batch should have exact size", 50, batches.get(0).size()); + } + + @Test + public void testCreateBatchesWithMultipleBatches() { + List records = new ArrayList<>(); + for (int i = 0; i < 125; i++) { + records.add(InsertRecordData.builder().build()); + } + + List> batches = Utils.createBatches(records, 50); + + Assert.assertEquals("Should create three batches", 3, batches.size()); + Assert.assertEquals("First batch should be full", 50, batches.get(0).size()); + Assert.assertEquals("Second batch should be full", 50, batches.get(1).size()); + Assert.assertEquals("Last batch should contain remaining records", 25, batches.get(2).size()); + } + + @Test + public void testCreateBatchesPreservesOrder() { + List records = new ArrayList<>(); + for (int i = 0; i < 75; i++) { + InsertRecordData record = InsertRecordData.builder() + .data(Optional.of(Collections.singletonMap("id", String.valueOf(i)))) + .build(); + records.add(record); + } + + List> batches = Utils.createBatches(records, 50); + + Assert.assertEquals("Should create two batches", 2, batches.size()); + Assert.assertEquals("First record in first batch should be 0", + "0", batches.get(0).get(0).getData().get().get("id")); + Assert.assertEquals("First record in second batch should be 50", + "50", batches.get(1).get(0).getData().get().get("id")); + } + + @Test(expected = NullPointerException.class) + public void testCreateBatchesWithNullList() { + Utils.createBatches(null, 50); + } + + @Test + public void testCreateErrorRecord() { + Map recordMap = new HashMap<>(); + recordMap.put("error", "Test error"); + recordMap.put("message", "Test message"); + recordMap.put("http_code", 400); + + ErrorRecord error = Utils.createErrorRecord(recordMap, 1); + + Assert.assertEquals(1, error.getIndex()); + Assert.assertEquals("Test message", error.getError()); + Assert.assertEquals(400, error.getCode()); + } + + @Test + public void testHandleBatchException_ApiClientException() { + List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); + List> batches = Collections.singletonList(batch); + + Map errorMap = new HashMap<>(); + errorMap.put("error", "Test error"); + errorMap.put("http_code", 400); + + Map responseBody = new HashMap<>(); + responseBody.put("error", errorMap); + + ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, responseBody); + Exception exception = new Exception("Test exception", apiException); + + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + Assert.assertEquals(2, errors.size()); + Assert.assertEquals("Test error", errors.get(0).getError()); + Assert.assertEquals(0, errors.get(0).getIndex()); + Assert.assertEquals(1, errors.get(1).getIndex()); + } + + @Test + public void testFormatResponse() { + // Create test response data + RecordResponseObject successRecord = RecordResponseObject.builder() + .skyflowId(Optional.of("testId1")) + .error(Optional.empty()) + .build(); + + RecordResponseObject errorRecord = RecordResponseObject.builder() + .error(Optional.of("Test error")) + .httpCode(Optional.of(400)) + .build(); + + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Arrays.asList(successRecord, errorRecord))) + .build(); + + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + Assert.assertNotNull(result.getSuccess()); + Assert.assertEquals(1, result.getSuccess().size()); + Assert.assertEquals("testId1", result.getSuccess().get(0).getSkyflowId()); + + Assert.assertNotNull(result.getErrors()); + Assert.assertEquals(1, result.getErrors().size()); + Assert.assertEquals("Test error", result.getErrors().get(0).getError()); + Assert.assertEquals(400, result.getErrors().get(0).getCode()); + } + + @Test + public void testHandleBatchException_ApiClientExceptionWithRecords() { + // Prepare test data + List batch = Arrays.asList( + InsertRecordData.builder().build(), + InsertRecordData.builder().build() + ); + List> batches = Collections.singletonList(batch); + + // Create mock response with records + List> recordsList = new ArrayList<>(); + Map record1 = new HashMap<>(); + record1.put("error", "Error 1"); + record1.put("http_code", 400); + Map record2 = new HashMap<>(); + record2.put("error", "Error 2"); + record2.put("http_code", 401); + recordsList.add(record1); + recordsList.add(record2); + + Map responseBody = new HashMap<>(); + responseBody.put("records", recordsList); + + ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, responseBody); + Exception exception = new Exception("Test exception", apiException); + + // Test + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + // Verify + Assert.assertEquals("Should have two errors", 2, errors.size()); + Assert.assertEquals("First error message", "Error 1", errors.get(0).getError()); + Assert.assertEquals("First error code", 400, errors.get(0).getCode()); + Assert.assertEquals("First error index", 0, errors.get(0).getIndex()); + Assert.assertEquals("Second error message", "Error 2", errors.get(1).getError()); + Assert.assertEquals("Second error code", 401, errors.get(1).getCode()); + Assert.assertEquals("Second error index", 1, errors.get(1).getIndex()); + } + + @Test + public void testHandleBatchException_ApiClientExceptionWithSingleError() { + // Prepare test data + List batch = Arrays.asList( + InsertRecordData.builder().build(), + InsertRecordData.builder().build() + ); + List> batches = Collections.singletonList(batch); + + // Create mock response with single error + Map errorMap = new HashMap<>(); + errorMap.put("error", "Common error"); + errorMap.put("http_code", 403); + + Map responseBody = new HashMap<>(); + responseBody.put("error", errorMap); + + ApiClientApiException apiException = new ApiClientApiException("Forbidden", 403, responseBody); + Exception exception = new Exception("Test exception", apiException); + + // Test + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + // Verify + Assert.assertEquals("Should have errors for all records", 2, errors.size()); + Assert.assertEquals("Error message should be same", "Common error", errors.get(0).getError()); + Assert.assertEquals("Error code should be same", 403, errors.get(0).getCode()); + Assert.assertEquals("First error index", 0, errors.get(0).getIndex()); + Assert.assertEquals("Second error index", 1, errors.get(1).getIndex()); + } + + @Test + public void testHandleBatchException_NonApiClientException() { + // Prepare test data + List batch = Arrays.asList( + InsertRecordData.builder().build(), + InsertRecordData.builder().build() + ); + List> batches = Collections.singletonList(batch); + + RuntimeException exception = new RuntimeException("Unexpected error"); + + // Test + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + // Verify + Assert.assertEquals("Should have errors for all records", 2, errors.size()); + Assert.assertEquals("Error message should match", "Unexpected error", errors.get(0).getError()); + Assert.assertEquals("Error code should be 500", 500, errors.get(0).getCode()); + Assert.assertEquals("First error index", 0, errors.get(0).getIndex()); + Assert.assertEquals("Second error index", 1, errors.get(1).getIndex()); + } + + @Test + public void testHandleBatchException_NonZeroBatchNumber() { + // Prepare test data + List batch = Arrays.asList( + InsertRecordData.builder().build(), + InsertRecordData.builder().build() + ); + List> batches = Arrays.asList( + new ArrayList<>(), // first batch + batch // second batch + ); + + RuntimeException exception = new RuntimeException("Batch error"); + + // Test + List errors = Utils.handleBatchException(exception, batch, 1, batches); + + // Verify + Assert.assertEquals("Should have errors for all records", 2, errors.size()); + Assert.assertEquals("First error index should be offset", 2, errors.get(0).getIndex()); + Assert.assertEquals("Second error index should be offset", 3, errors.get(1).getIndex()); + } + + @Test + public void testHandleBatchException_NullResponseBody() { + // Prepare test data + List batch = Arrays.asList( + InsertRecordData.builder().build(), + InsertRecordData.builder().build() + ); + List> batches = Collections.singletonList(batch); + + ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, null); + Exception exception = new Exception("Test exception", apiException); + + // Test + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + // Verify + Assert.assertEquals("Should return empty list for null response body", 0, errors.size()); + } + + @Test + public void testFormatResponse_NullResponse() { + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(null, 0, 50); + System.out.println(result); + Assert.assertNull(result); + } + + @Test + public void testHandleBatchException_GenericException() { + List batch = new ArrayList<>(); + InsertRecordData record1 = InsertRecordData.builder().build(); + InsertRecordData record2 = InsertRecordData.builder().build(); + batch.add(record1); + batch.add(record2); + List> batches = Collections.singletonList(batch); + + Exception exception = new RuntimeException("Generic error"); + + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + Assert.assertEquals(2, errors.size()); + Assert.assertEquals("Generic error", errors.get(0).getError()); + Assert.assertEquals(500, errors.get(0).getCode()); + Assert.assertEquals(0, errors.get(0).getIndex()); + Assert.assertEquals(1, errors.get(1).getIndex()); + } + + @Test + public void testFormatResponse_SuccessRecords() { + // Create test data + RecordResponseObject successRecord1 = RecordResponseObject.builder() + .skyflowId(Optional.of("id1")) + .error(Optional.empty()) + .build(); + RecordResponseObject successRecord2 = RecordResponseObject.builder() + .skyflowId(Optional.of("id2")) + .error(Optional.empty()) + .build(); + + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Arrays.asList(successRecord1, successRecord2))) + .build(); + + // Test + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + // Verify + Assert.assertNotNull("Response should not be null", result); + Assert.assertEquals("Should have two success records", 2, result.getSuccess().size()); + Assert.assertEquals("First skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); + Assert.assertEquals("Second skyflow ID should match", "id2", result.getSuccess().get(1).getSkyflowId()); + Assert.assertTrue("Error list should be empty", result.getErrors().isEmpty()); + } + + @Test + public void testFormatResponse_ErrorRecords() { + // Create test data + RecordResponseObject errorRecord1 = RecordResponseObject.builder() + .error(Optional.of("Error 1")) + .httpCode(Optional.of(400)) + .build(); + RecordResponseObject errorRecord2 = RecordResponseObject.builder() + .error(Optional.of("Error 2")) + .httpCode(Optional.of(500)) + .build(); + + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Arrays.asList(errorRecord1, errorRecord2))) + .build(); + + // Test + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + // Verify + Assert.assertNotNull("Response should not be null", result); + Assert.assertEquals("Should have two error records", 2, result.getErrors().size()); + Assert.assertEquals("First error message should match", "Error 1", result.getErrors().get(0).getError()); + Assert.assertEquals("First error code should match", 400, result.getErrors().get(0).getCode()); + Assert.assertEquals("Second error message should match", "Error 2", result.getErrors().get(1).getError()); + Assert.assertEquals("Second error code should match", 500, result.getErrors().get(1).getCode()); + Assert.assertTrue("Success list should be empty", result.getSuccess().isEmpty()); + } + + @Test + public void testFormatResponse_MixedRecords() { + // Create test data + RecordResponseObject successRecord = RecordResponseObject.builder() + .skyflowId(Optional.of("id1")) + .error(Optional.empty()) + .build(); + RecordResponseObject errorRecord = RecordResponseObject.builder() + .error(Optional.of("Error")) + .httpCode(Optional.of(400)) + .build(); + + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Arrays.asList(successRecord, errorRecord))) + .build(); + + // Test + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + // Verify + Assert.assertNotNull("Response should not be null", result); + Assert.assertEquals("Should have one success record", 1, result.getSuccess().size()); + Assert.assertEquals("Should have one error record", 1, result.getErrors().size()); + Assert.assertEquals("Success skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); + Assert.assertEquals("Error message should match", "Error", result.getErrors().get(0).getError()); + Assert.assertEquals("Error code should match", 400, result.getErrors().get(0).getCode()); + } + + @Test + public void testFormatResponse_WithBatchOffset() { + // Create test data + RecordResponseObject successRecord = RecordResponseObject.builder() + .skyflowId(Optional.of("id1")) + .error(Optional.empty()) + .build(); + RecordResponseObject errorRecord = RecordResponseObject.builder() + .error(Optional.of("Error")) + .httpCode(Optional.of(400)) + .build(); + + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Arrays.asList(successRecord, errorRecord))) + .build(); + + // Test with batch number 1 and batch size 50 + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 1, 50); + + // Verify + Assert.assertNotNull("Response should not be null", result); + Assert.assertEquals("Should have correct index for error record", 51, result.getErrors().get(0).getIndex()); + } + + @Test + public void testFormatResponse_EmptyRecords() { + // Create test data + InsertResponse response = InsertResponse.builder() + .records(Optional.of(new ArrayList<>())) + .build(); + + // Test + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + // Verify + Assert.assertNotNull("Response should not be null", result); + Assert.assertTrue("Success list should be empty", result.getSuccess().isEmpty()); + Assert.assertTrue("Error list should be empty", result.getErrors().isEmpty()); + } + + @Test + public void testFormatResponse_WithTokens() { + // Create test data + Map tokens = new HashMap<>(); + tokens.put("field1", "token1"); + tokens.put("field2", "token2"); + + RecordResponseObject successRecord = RecordResponseObject.builder() + .skyflowId(Optional.of("id1")) + .tokens(Optional.of(tokens)) + .error(Optional.empty()) + .build(); + + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Collections.singletonList(successRecord))) + .build(); + + // Test + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + // Verify + Assert.assertNotNull("Response should not be null", result); + Assert.assertEquals("Should have one success record", 1, result.getSuccess().size()); + Assert.assertEquals("Skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); + // Add more token-specific assertions once token handling is implemented + } } diff --git a/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java b/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java new file mode 100644 index 00000000..50e14087 --- /dev/null +++ b/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java @@ -0,0 +1,218 @@ +package com.skyflow.vault.controller; + +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.Env; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; +import com.skyflow.utils.Utils; +import com.skyflow.vault.data.InsertRequest; +import okhttp3.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; + +public class VaultControllerTests { + 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 vaultID; + private static String clusterID; + private static VaultConfig vaultConfig; + private VaultController vaultController; + + private OkHttpClient mockClient; + + @BeforeClass + public static void setupClass() { + vaultID = "vault123"; + clusterID = "cluster123"; + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); + } + + @Before + public void setup() { +// Create mock interceptor + Interceptor mockInterceptor = chain -> { + // Create mock response + String mockResponseBody = "{\"records\":[{\"skyflowId\":\"test-id-123\",\"tokens\":{}}]}"; + return new Response.Builder() + .code(200) + .message("OK") + .protocol(Protocol.HTTP_1_1) + .request(chain.request()) + .body(ResponseBody.create( + MediaType.parse("application/json"), + mockResponseBody + )) + .build(); + }; + + // Create client with mock interceptor + mockClient = new OkHttpClient.Builder() + .addInterceptor(mockInterceptor) + .build(); + vaultConfig = new VaultConfig(); + vaultConfig.setVaultId(vaultID); + vaultConfig.setClusterId(clusterID); + vaultConfig.setEnv(Env.DEV); + + Credentials credentials = new Credentials(); + credentials.setToken("valid-token"); + vaultConfig.setCredentials(credentials); + this.vaultController = new VaultController(vaultConfig, credentials); +// spyController = Mockito.spy(vaultController); + // Create mock response +// String mockResponseBody = "{\"records\":[{\"skyflowId\":\"test-id-123\",\"tokens\":{}}]}"; +// ResponseBody responseBody = ResponseBody.create( +// MediaType.parse("application/json"), +// mockResponseBody +// ); +// +// Response mockResponse = new Response.Builder() +// .code(200) +// .message("OK") +// .protocol(Protocol.HTTP_1_1) +// .request(new Request.Builder().url("https://test.com").build()) +// .body(responseBody) +// .build(); +// +// // Mock Call +// Call mockCall = PowerMockito.mock(Call.class); +// try { +// PowerMockito.when(mockCall.execute()).thenReturn(mockResponse); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } +// +// // Mock OkHttpClient +// mockClient = PowerMockito.mock(OkHttpClient.class); +// PowerMockito.when(mockClient.newCall(any(Request.class))).thenReturn(mockCall); + + + } + +// @Test +// public void testBulkInsertSuccess() throws SkyflowException { +// // Prepare test data +// ArrayList> records = new ArrayList<>(); +// HashMap record = new HashMap<>(); +// record.put("field1", "value1"); +// records.add(record); +// +// InsertRequest request = InsertRequest.builder() +// .values(records) +// .table("test_table") +// .build(); +// +// // Create mock response +// List responseObjects = new ArrayList<>(); +// RecordResponseObject responseObject = RecordResponseObject.builder() +// .skyflowId("test-id-123") +// .data(record) +// .build(); +// responseObjects.add(responseObject); +// +// InsertResponse mockResponse = InsertResponse.builder() +// .records(responseObjects) +// .build(); +// +// InsertResponse resp = InsertResponse.builder().records(responseObjects).build(); +// // Mock insertBatch method +// when(vaultController.bulkInsert(any())); +// +// // Execute test +// com.skyflow.vault.data.InsertResponse response = vaultController.bulkInsert(request); +// +// // Verify response +// Assert.assertNotNull(response); +// Assert.assertNotNull(response.getSuccess()); +// Assert.assertEquals(1, response.getSuccess().size()); +// Assert.assertEquals("test-id-123", response.getSuccess().get(0).getSkyflowId()); +// +// // Verify method was called +//// verify(vaultController).insertBatch(any(), eq("test_table")); +// } + @Test + public void testInvalidRequestInInsertMethod() { + try { + InsertRequest request = InsertRequest.builder().build(); + vaultController.bulkInsert(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 testBulkInsertWithApiError3() throws SkyflowException { +// // Prepare test data +// ArrayList> records = new ArrayList<>(); +// HashMap record = new HashMap<>(); +// record.put("field1", "value1"); +// records.add(record); +// +// InsertRequest request = InsertRequest.builder() +// .values(records) +// .table("test_table") +// .build(); +// +// try { +// com.skyflow.vault.data.InsertResponse res = vaultController.bulkInsert(request); +// String resp = "{\"summary\":{\"total_records\":1,\"total_inserted\":0,\"total_failed\":1},\"errors\":[{\"index\":0,\"error\":\"com.skyflow.generated.rest.core.ApiClientException: Network error executing HTTP request\",\"code\":500}]}"; +// Assert.assertEquals(res.toString(), resp); +// } catch (SkyflowException e) { +// Assert.assertEquals(400, e.getHttpCode()); +// } +// } + +// @Test +// public void testInsert(){ +// // Prepare test data +// ArrayList> records = new ArrayList<>(); +// HashMap record = new HashMap<>(); +// record.put("field1", "value1"); +// records.add(record); +// +// InsertRequest request = InsertRequest.builder() +// .values(records) +// .table("test_table") +// .build(); +// List recordDataList = new ArrayList<>(); +// InsertRecordData recordData = InsertRecordData.builder().data(record).build(); +// recordDataList.add(recordData); +// +// com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request1 = com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest.builder() +// .records(recordDataList).vaultId("id").tableName("test_table").build(); +// RecordResponseObject recordResponseObject = RecordResponseObject.builder().data(record).build(); +// List recordResponseObjects = new ArrayList<>(); +// recordResponseObjects.add(recordResponseObject); +// +//// ApiClient apiClient = PowerMockito.mock(ApiClient.class); +////// ApiClientBuilder apiClientBuilder = PowerMockito.mock(ApiClientBuilder.class); +//// RecordserviceClient recordserviceClient = PowerMockito.mock(RecordserviceClient.class); +//// apiClient = ApiClient.builder().url("https://demo.com").httpClient(new OkHttpClient()).build(); +//// when(recordserviceClient.insert(request1)).thenReturn(apiClient.recordservice().insert(request1)); +// +//// PowerMockito.when(OkHttpClient.class).thenReturn(this.mockClient); +// PowerMockito.mock(OkHttpClient.class); +// +// try { +// com.skyflow.vault.data.InsertResponse res = vaultController.bulkInsert(request); +// String resp = "{\"summary\":{\"total_records\":1,\"total_inserted\":0,\"total_failed\":1},\"errors\":[{\"index\":0,\"error\":\"com.skyflow.generated.rest.core.ApiClientException: Network error executing HTTP request\",\"code\":500}]}"; +// Assert.assertEquals(res.toString(), resp); +// System.out.println("resppp=>"+ res); +// } catch (SkyflowException e) { +// Assert.assertEquals(400, e.getHttpCode()); +// } +// } +} \ No newline at end of file diff --git a/v3/test/java/com/skyflow/vault/data/InsertTests.java b/v3/test/java/com/skyflow/vault/data/InsertTests.java new file mode 100644 index 00000000..af8b050f --- /dev/null +++ b/v3/test/java/com/skyflow/vault/data/InsertTests.java @@ -0,0 +1,269 @@ +package com.skyflow.vault.data; + +import com.skyflow.Skyflow; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.enums.Env; +import com.skyflow.errors.ErrorCode; +import com.skyflow.errors.ErrorMessage; +import com.skyflow.errors.SkyflowException; +import com.skyflow.utils.Constants; +import com.skyflow.utils.SdkVersion; +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.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class InsertTests { + 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 final String requestId = "95be08fc-4d13-4335-8b8d-24e85d53ed1d"; + private static String vaultID = null; + private static String clusterID = null; + private static String table = null; + private static ArrayList> values = null; + private static ArrayList> tokens = null; + private static HashMap valueMap = null; + private static HashMap tokenMap = null; + private static List upsert = new ArrayList<>(); + private static Skyflow skyflowClient = null; + + @BeforeClass + public static void setup() { + + vaultID = "vault123"; + clusterID = "cluster123"; + + Credentials credentials = new Credentials(); + credentials.setToken("valid-token"); + + VaultConfig vaultConfig = new VaultConfig(); + vaultConfig.setVaultId(vaultID); + vaultConfig.setClusterId(clusterID); + vaultConfig.setEnv(Env.DEV); + vaultConfig.setCredentials(credentials); + + table = "test_table"; + values = new ArrayList<>(); + tokens = new ArrayList<>(); + valueMap = new HashMap<>(); + tokenMap = new HashMap<>(); + upsert.add("upsert_column"); + SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); + } + + @Before + public void setupTest() { + values.clear(); + tokens.clear(); + valueMap.clear(); + valueMap.put("test_column_1", "test_value_1"); + valueMap.put("test_column_2", "test_value_2"); + tokenMap.clear(); + tokenMap.put("test_column_1", "test_token_1"); + } + + @Test + public void testValidInputInInsertRequestValidations() { + try { + values.add(valueMap); + tokens.add(tokenMap); + + InsertRequest request = InsertRequest.builder() + .table(table) + .upsert(upsert) + .values(values) + .build(); + Validations.validateInsertRequest(request); + + Assert.assertEquals(table, request.getTable()); + Assert.assertEquals(upsert, request.getUpsert()); + Assert.assertEquals(1, request.getValues().size()); + } catch (SkyflowException e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testValidInputInInsertRequestValidationsWithTokenModeDisable() { + try { + values.add(valueMap); + tokens.add(tokenMap); + InsertRequest request = InsertRequest.builder() + .table(table) + .upsert(upsert) + .values(values) + .build(); + Validations.validateInsertRequest(request); + + Assert.assertEquals(table, request.getTable()); + Assert.assertEquals(upsert, request.getUpsert()); + Assert.assertEquals(1, request.getValues().size()); + } catch (SkyflowException e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testNoTableInInsertRequestValidations() { + InsertRequest request = InsertRequest.builder().build(); + try { + Validations.validateInsertRequest(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 testEmptyTableInInsertRequestValidations() { + InsertRequest request = InsertRequest.builder().table("").build(); + try { + Validations.validateInsertRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.EmptyTable.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testNoValuesInInsertRequestValidations() { + InsertRequest request = InsertRequest.builder().table(table).build(); + try { + Validations.validateInsertRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.ValuesKeyError.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testEmptyValuesInInsertRequestValidations() { + InsertRequest request = InsertRequest.builder().table(table).values(values).build(); + try { + Validations.validateInsertRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.EmptyValues.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testEmptyKeyInValuesInInsertRequestValidations() { + valueMap.put("", "test_value_3"); + values.add(valueMap); + InsertRequest request = InsertRequest.builder().table(table).values(values).build(); + try { + Validations.validateInsertRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.EmptyKeyInValues.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testEmptyValueInValuesInInsertRequestValidations() { + valueMap.put("test_column_3", ""); + values.add(valueMap); + InsertRequest request = InsertRequest.builder().table(table).values(values).build(); + try { + Validations.validateInsertRequest(request); + Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.EmptyValueInValues.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testEmptyUpsertInInsertRequestValidations() { + values.add(valueMap); + InsertRequest request = InsertRequest.builder().table(table).values(values).upsert(new ArrayList<>()).build(); + try { + Validations.validateInsertRequest(request); +// Assert.fail(EXCEPTION_NOT_THROWN); + } catch (SkyflowException e) { + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals( + Utils.parameterizedString(ErrorMessage.EmptyUpsert.getMessage(), Constants.SDK_PREFIX), + e.getMessage() + ); + } + } + + @Test + public void testInsertResponse() { + try { + Map value = new HashMap<>(); + value.put("test_column_1", "test_value_1"); + Success success = new Success(0, "id", null, null); + + List successList = new ArrayList<>(); + successList.add(success); + InsertResponse response = new InsertResponse(successList, null); + String responseString = "{\"success\":[{\"index\":0,\"skyflow_id\":\"id\"}]}"; + Assert.assertEquals(1, response.getSuccess().size()); + Assert.assertNull(response.getErrors()); + Assert.assertEquals(responseString, response.toString()); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testInsertErrorResponse() { + try { + HashMap value = new HashMap<>(); + value.put("test_column_1", "test_value_1"); + Success success = new Success(0, "id", null, value); + + List successList = new ArrayList<>(); + successList.add(success); + + List errorList = new ArrayList<>(); + ErrorRecord error = new ErrorRecord(1, "Bad Request", 400); + errorList.add(error); + + InsertResponse response1 = new InsertResponse(successList, errorList); + System.out.println("response: " + response1.getErrors()); + String responseString = "{\"success\":[{\"index\":0,\"skyflow_id\":\"id\",\"data\":{\"test_column_1\":\"test_value_1\"}}],\"errors\":[{\"index\":1,\"error\":\"Bad Request\",\"code\":400}]}"; + Assert.assertEquals(1, response1.getSuccess().size()); + Assert.assertEquals(1, response1.getErrors().size()); + System.out.println("response: " + response1.toString()); + Assert.assertEquals(responseString, response1.toString()); + } catch (Exception e) { + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + +} From 6ae9f3570f34f32c24883d9bcfd927241898726a Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 13:29:01 +0530 Subject: [PATCH 56/97] SK-2258 fixed utils tests --- .../skyflow/vault/data/BaseInsertRequest.java | 13 +- .../vault/data/BaseInsertResponse.java | 2 +- v3/src/main/java/com/skyflow/utils/Utils.java | 48 +-- .../vault/controller/VaultController.java | 32 -- .../com/skyflow/vault/data/ErrorRecord.java | 23 +- .../skyflow/vault/data/InsertResponse.java | 12 - .../java/com/skyflow/vault/data/Success.java | 15 - .../java/com/skyflow/vault/data/Summary.java | 10 - .../java/com/skyflow/vault/data/Token.java | 9 +- .../java/com/skyflow/utils/UtilsTests.java | 303 +++--------------- 10 files changed, 73 insertions(+), 394 deletions(-) diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java index 483b41f0..b856492d 100644 --- a/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java +++ b/common/src/main/java/com/skyflow/vault/data/BaseInsertRequest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; -public class BaseInsertRequest { +class BaseInsertRequest { private final BaseInsertRequestBuilder builder; protected BaseInsertRequest(BaseInsertRequestBuilder builder) { @@ -18,19 +18,12 @@ public ArrayList> getValues() { return this.builder.values; } -// public Boolean getReturnTokens() { -// return this.builder.returnTokens; -// } - static class BaseInsertRequestBuilder { protected String table; protected ArrayList> values; -// protected ArrayList> tokens; -// protected Boolean returnTokens; protected String upsert; protected BaseInsertRequestBuilder() { -// this.returnTokens = false; } public BaseInsertRequestBuilder table(String table) { @@ -43,10 +36,6 @@ public BaseInsertRequestBuilder values(ArrayList> values return this; } -// public BaseInsertRequestBuilder returnTokens(Boolean returnTokens) { -// this.returnTokens = returnTokens != null && returnTokens; -// return this; -// } } } diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java index b3eead69..c8e5ef7e 100644 --- a/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java +++ b/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; -public class BaseInsertResponse { +class BaseInsertResponse { private final ArrayList> insertedFields; private final ArrayList> errors; diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index d9f812b9..5625798e 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -33,16 +33,12 @@ public static List> createBatches(List } public static ErrorRecord createErrorRecord(Map recordMap, int indexNumber) { - ErrorRecord err = new ErrorRecord(); - err.setIndex(indexNumber); - if (recordMap.containsKey("error")) { - err.setError((String) recordMap.get("error")); - } - if (recordMap.containsKey("message")) { - err.setError((String) recordMap.get("message")); - } - if (recordMap.containsKey("http_code")) { - err.setCode((Integer) recordMap.get("http_code")); + ErrorRecord err = null; + if( recordMap != null ) { + int code = recordMap.containsKey("http_code") ? (Integer) recordMap.get("http_code") : 500; + String message = recordMap.containsKey("error") ? (String) recordMap.get("error") : + recordMap.containsKey("message") ? (String) recordMap.get("message") : "Unknown error"; + err = new ErrorRecord(indexNumber, message, code); } return err; } @@ -82,10 +78,7 @@ public static List handleBatchException( } else { int indexNumber = batchNumber > 0 ? batchNumber * batch.size() : 0; for (int j = 0; j < batch.size(); j++) { - ErrorRecord err = new ErrorRecord(); - err.setIndex(indexNumber); - err.setError(ex.getMessage()); - err.setCode(500); + ErrorRecord err = new ErrorRecord(indexNumber, ex.getMessage(), 500); errorRecords.add(err); indexNumber++; } @@ -104,26 +97,17 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons for (int index = 0; index < recordsSize; index++) { if (record.get(index).getError().isPresent()) { ErrorRecord errorRecord = new ErrorRecord(indexNumber, record.get(index).getError().get(), record.get(index).getHttpCode().get()); -// errorRecord.setIndex(indexNumber); -// errorRecord.setError(record.get(index).getError().get()); -// errorRecord.setCode(record.get(index).getHttpCode().get()); errorRecords.add(errorRecord); -// errorRecord.setCode(record.get(index).getError().get().getCode()); } else { Success success = new Success(index, record.get(index).getSkyflowId().get(), null, null); -// success.setIndex(indexNumber); -// success.setSkyflowId(record.get(index).getSkyflowId().get()); -// success.setData(record.get(index).getData().get()); - if (record.get(index).getTokens().isPresent()) { - List tokens = null; - Map tok = record.get(index).getTokens().get(); - for (int i = 0; i < tok.size(); i++) { - Token token = new Token(); - Object obj = tok.get(i); -// token.setToken(); -// token.setTokenGroupName(""); - } - } +// if (record.get(index).getTokens().isPresent()) { +// List tokens = null; +// Map tok = record.get(index).getTokens().get(); +// for (int i = 0; i < tok.size(); i++) { +// Object obj = tok.get(i); +//// Token token = new Token(obj.toString()); +// } +// } // success.setTokens(record.get(index).getTokens().get()); successRecords.add(success); @@ -132,8 +116,6 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons } formattedResponse = new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords); -// formattedResponse.setSuccessRecords(successRecords); -// formattedResponse.setErrorRecords(errorRecords); } return formattedResponse; } diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 9ec27f94..49df042e 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -63,20 +63,6 @@ public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequ LogUtil.printErrorLog(ErrorLogs.INSERT_RECORDS_REJECTED.getLog()); throw new SkyflowException(e.getMessage()); } -// Summary summary = new Summary(); -// summary.setTotalRecords(insertRequest.getValues().size()); -// if (response.getSuccessRecords() != null) { -// summary.setTotalInserted(response.getSuccessRecords().size()); -// } else { -// summary.setTotalInserted(0); -// } -// if (response.getErrorRecords() != null) { -// summary.setTotalFailed(response.getErrorRecords().size()); -// } else { -// summary.setTotalFailed(0); -// } -// response.setSummary(summary); -// return response; } public CompletableFuture bulkInsertAsync(InsertRequest insertRequest) throws SkyflowException { @@ -108,18 +94,6 @@ public CompletableFuture bulkInsertAsync( } return new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, insertRequest.getValues()); -// Summary summary = new Summary(); -// if (!successRecords.isEmpty()) { -// response.setSuccessRecords(successRecords); -// summary.setTotalInserted(successRecords.size()); -// } -// if (!errorRecords.isEmpty()) { -// response.setErrorRecords(errorRecords); -// summary.setTotalFailed(errorRecords.size()); -// } -// summary.setTotalRecords(insertRequest.getValues().size()); -// response.setSummary(summary); -// return response; }); } catch (ApiClientApiException e) { String bodyString = gson.toJson(e.body()); @@ -153,12 +127,6 @@ private com.skyflow.vault.data.InsertResponse processSync( } } com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, originalPayload); -// if (!errorRecords.isEmpty()) { -// response.setErrorRecords(errorRecords); -// } -// if (!successRecords.isEmpty()) { -// response.setSuccessRecords(successRecords); -// } LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); return response; } diff --git a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java index cd33e1fb..9044f189 100644 --- a/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java +++ b/v3/src/main/java/com/skyflow/vault/data/ErrorRecord.java @@ -10,36 +10,27 @@ public class ErrorRecord { private String error; @Expose(serialize = true) private int code; - public int getIndex() { - return index; - } - - public ErrorRecord() { - } +// public ErrorRecord() { +// } public ErrorRecord(int index, String error, int code) { this.index = index; this.error = error; this.code = code; } - - public void setIndex(int index) { - this.index = index; - } - public String getError() { return error; } - public void setError(String error) { - this.error = error; - } public int getCode() { return code; } - public void setCode(int code) { - this.code = code; + + public int getIndex() { + return index; } + + @Override public String toString() { Gson gson = new Gson(); diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 0ae6b633..0fb9ef6a 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -42,26 +42,14 @@ public Summary getSummary() { return this.summary; } -// public void setSummary(Summary summary) { -// this.summary = summary; -// } - public List getSuccess() { return this.success; } -// public void setSuccess(List success) { -// this.success = success; -// } - public List getErrors() { return this.errors; } -// public void setErrors(List errors) { -// this.errors = errors; -// } - public List> getRecordsToRetry() { if (recordsToRetry == null) { recordsToRetry = new ArrayList<>(); diff --git a/v3/src/main/java/com/skyflow/vault/data/Success.java b/v3/src/main/java/com/skyflow/vault/data/Success.java index 293475c6..db302e6c 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Success.java +++ b/v3/src/main/java/com/skyflow/vault/data/Success.java @@ -26,33 +26,18 @@ public Success(int index, String skyflow_id, Map> tokens, Ma this.data = data; } -// public void setIndex(int index) { -// this.index = index; -// } - public String getSkyflowId() { return skyflow_id; } -// public void setSkyflowId(String skyflow_id) { -// this.skyflow_id = skyflow_id; -// } - public Map> getTokens() { return tokens; } -// public void setTokens(Map> tokens) { -// this.tokens = tokens; -// } - public Map getData() { return data; } -// public void setData(Map data) { -// this.data = data; -// } @Override public String toString() { Gson gson = new Gson(); diff --git a/v3/src/main/java/com/skyflow/vault/data/Summary.java b/v3/src/main/java/com/skyflow/vault/data/Summary.java index b5a18452..c15db6cb 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Summary.java +++ b/v3/src/main/java/com/skyflow/vault/data/Summary.java @@ -24,25 +24,15 @@ public int getTotalRecords() { return totalRecords; } -// public void setTotalRecords(int totalRecords) { -// this.totalRecords = totalRecords; -// } public int getTotalInserted() { return totalInserted; } -// public void setTotalInserted(int totalInserted) { -// this.totalInserted = totalInserted; -// } - public int getTotalFailed() { return totalFailed; } -// public void setTotalFailed(int totalFailed) { -// this.totalFailed = totalFailed; -// } @Override public String toString() { diff --git a/v3/src/main/java/com/skyflow/vault/data/Token.java b/v3/src/main/java/com/skyflow/vault/data/Token.java index e29e1c41..642d62c4 100644 --- a/v3/src/main/java/com/skyflow/vault/data/Token.java +++ b/v3/src/main/java/com/skyflow/vault/data/Token.java @@ -12,17 +12,12 @@ public String getToken() { return token; } -// public void setToken(String token) { -// this.token = token; -// } - public String getTokenGroupName() { return tokenGroupName; } - public void setTokenGroupName(String tokenGroupName) { + public Token(String token, String tokenGroupName) { + this.token = token; this.tokenGroupName = tokenGroupName; } - - } \ No newline at end of file diff --git a/v3/test/java/com/skyflow/utils/UtilsTests.java b/v3/test/java/com/skyflow/utils/UtilsTests.java index d066f71b..44ac9595 100644 --- a/v3/test/java/com/skyflow/utils/UtilsTests.java +++ b/v3/test/java/com/skyflow/utils/UtilsTests.java @@ -2,7 +2,6 @@ import com.google.gson.JsonObject; import com.skyflow.config.Credentials; -import com.skyflow.enums.Env; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; @@ -20,8 +19,6 @@ public class UtilsTests { 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 clusterId = null; - private static String url = null; private static String filePath = null; private static String credentialsString = null; private static String token = null; @@ -30,8 +27,6 @@ public class UtilsTests { @BeforeClass public static void setup() { - clusterId = "test_cluster_id"; - url = "https://test-url.com/java/unit/tests"; filePath = "invalid/file/path/credentials.json"; credentialsString = "invalid credentials string"; token = "invalid-token"; @@ -42,35 +37,6 @@ public static void setup() { SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } - @Test - public void testGetVaultURLForDifferentENVs() { - try { - Map map = new HashMap<>(); - map.put(Env.DEV, "https://test_cluster_id.vault.skyflowapis.dev"); - map.put(Env.STAGE, "https://test_cluster_id.vault.skyflowapis.tech"); - map.put(Env.SANDBOX, "https://test_cluster_id.vault.skyflowapis-preview.com"); - map.put(Env.PROD, "https://test_cluster_id.vault.skyflowapis.com"); - - for (Env env : map.keySet()) { - String vaultURL = Utils.getV2VaultURL(clusterId, env); - Assert.assertEquals(map.get(env), vaultURL); - } - } catch (Exception e) { - Assert.fail(INVALID_EXCEPTION_THROWN); - } - } - - @Test - public void testGetBaseURL() { - try { - String baseURL = Utils.getBaseURL(url); - String url = "https://test-url.com"; - Assert.assertEquals(url, baseURL); - } catch (Exception e) { - Assert.fail(INVALID_EXCEPTION_THROWN); - } - } - @Test public void testGenerateBearerTokenWithCredentialsFile() { try { @@ -134,7 +100,6 @@ public void testGetMetrics() { @Test public void testGetMetricsWithException() { try { - // Clearing System Properties explicitly to throw exception System.clearProperty("os.name"); System.clearProperty("os.version"); System.clearProperty("java.version"); @@ -149,13 +114,13 @@ public void testGetMetricsWithException() { Assert.fail(INVALID_EXCEPTION_THROWN); } } + @Test - public void testCreateBatches() { + public void testCreateBatches_MultipleBatches() { List records = new ArrayList<>(); for (int i = 0; i < 125; i++) { records.add(InsertRecordData.builder().build()); } - List> batches = Utils.createBatches(records, 50); Assert.assertEquals(3, batches.size()); @@ -163,21 +128,20 @@ public void testCreateBatches() { Assert.assertEquals(50, batches.get(1).size()); Assert.assertEquals(25, batches.get(2).size()); } + @Test - public void testCreateBatchesWithEmptyList() { + public void testCreateBatches_WithEmptyList() { List records = new ArrayList<>(); List> batches = Utils.createBatches(records, 50); - Assert.assertTrue("Batches should be empty for empty input", batches.isEmpty()); } @Test - public void testCreateBatchesWithSmallerSizeThanBatch() { + public void testCreateBatches_WithSmallerSizeThanBatch() { List records = new ArrayList<>(); for (int i = 0; i < 25; i++) { records.add(InsertRecordData.builder().build()); } - List> batches = Utils.createBatches(records, 50); Assert.assertEquals("Should create single batch", 1, batches.size()); @@ -185,12 +149,11 @@ public void testCreateBatchesWithSmallerSizeThanBatch() { } @Test - public void testCreateBatchesWithExactBatchSize() { + public void testCreateBatches_WithExactBatchSize() { List records = new ArrayList<>(); for (int i = 0; i < 50; i++) { records.add(InsertRecordData.builder().build()); } - List> batches = Utils.createBatches(records, 50); Assert.assertEquals("Should create single batch", 1, batches.size()); @@ -198,22 +161,7 @@ public void testCreateBatchesWithExactBatchSize() { } @Test - public void testCreateBatchesWithMultipleBatches() { - List records = new ArrayList<>(); - for (int i = 0; i < 125; i++) { - records.add(InsertRecordData.builder().build()); - } - - List> batches = Utils.createBatches(records, 50); - - Assert.assertEquals("Should create three batches", 3, batches.size()); - Assert.assertEquals("First batch should be full", 50, batches.get(0).size()); - Assert.assertEquals("Second batch should be full", 50, batches.get(1).size()); - Assert.assertEquals("Last batch should contain remaining records", 25, batches.get(2).size()); - } - - @Test - public void testCreateBatchesPreservesOrder() { + public void testCreateBatches_PreservesOrder() { List records = new ArrayList<>(); for (int i = 0; i < 75; i++) { InsertRecordData record = InsertRecordData.builder() @@ -232,7 +180,7 @@ public void testCreateBatchesPreservesOrder() { } @Test(expected = NullPointerException.class) - public void testCreateBatchesWithNullList() { + public void testCreateBatches_WithNullList() { Utils.createBatches(null, 50); } @@ -246,111 +194,15 @@ public void testCreateErrorRecord() { ErrorRecord error = Utils.createErrorRecord(recordMap, 1); Assert.assertEquals(1, error.getIndex()); - Assert.assertEquals("Test message", error.getError()); + Assert.assertEquals("Test error", error.getError()); Assert.assertEquals(400, error.getCode()); } - @Test - public void testHandleBatchException_ApiClientException() { - List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); - List> batches = Collections.singletonList(batch); - - Map errorMap = new HashMap<>(); - errorMap.put("error", "Test error"); - errorMap.put("http_code", 400); - - Map responseBody = new HashMap<>(); - responseBody.put("error", errorMap); - - ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, responseBody); - Exception exception = new Exception("Test exception", apiException); - - List errors = Utils.handleBatchException(exception, batch, 0, batches); - - Assert.assertEquals(2, errors.size()); - Assert.assertEquals("Test error", errors.get(0).getError()); - Assert.assertEquals(0, errors.get(0).getIndex()); - Assert.assertEquals(1, errors.get(1).getIndex()); - } - - @Test - public void testFormatResponse() { - // Create test response data - RecordResponseObject successRecord = RecordResponseObject.builder() - .skyflowId(Optional.of("testId1")) - .error(Optional.empty()) - .build(); - - RecordResponseObject errorRecord = RecordResponseObject.builder() - .error(Optional.of("Test error")) - .httpCode(Optional.of(400)) - .build(); - - InsertResponse response = InsertResponse.builder() - .records(Optional.of(Arrays.asList(successRecord, errorRecord))) - .build(); - - com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - - Assert.assertNotNull(result.getSuccess()); - Assert.assertEquals(1, result.getSuccess().size()); - Assert.assertEquals("testId1", result.getSuccess().get(0).getSkyflowId()); - - Assert.assertNotNull(result.getErrors()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals("Test error", result.getErrors().get(0).getError()); - Assert.assertEquals(400, result.getErrors().get(0).getCode()); - } - - @Test - public void testHandleBatchException_ApiClientExceptionWithRecords() { - // Prepare test data - List batch = Arrays.asList( - InsertRecordData.builder().build(), - InsertRecordData.builder().build() - ); - List> batches = Collections.singletonList(batch); - - // Create mock response with records - List> recordsList = new ArrayList<>(); - Map record1 = new HashMap<>(); - record1.put("error", "Error 1"); - record1.put("http_code", 400); - Map record2 = new HashMap<>(); - record2.put("error", "Error 2"); - record2.put("http_code", 401); - recordsList.add(record1); - recordsList.add(record2); - - Map responseBody = new HashMap<>(); - responseBody.put("records", recordsList); - - ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, responseBody); - Exception exception = new Exception("Test exception", apiException); - - // Test - List errors = Utils.handleBatchException(exception, batch, 0, batches); - - // Verify - Assert.assertEquals("Should have two errors", 2, errors.size()); - Assert.assertEquals("First error message", "Error 1", errors.get(0).getError()); - Assert.assertEquals("First error code", 400, errors.get(0).getCode()); - Assert.assertEquals("First error index", 0, errors.get(0).getIndex()); - Assert.assertEquals("Second error message", "Error 2", errors.get(1).getError()); - Assert.assertEquals("Second error code", 401, errors.get(1).getCode()); - Assert.assertEquals("Second error index", 1, errors.get(1).getIndex()); - } - @Test public void testHandleBatchException_ApiClientExceptionWithSingleError() { - // Prepare test data - List batch = Arrays.asList( - InsertRecordData.builder().build(), - InsertRecordData.builder().build() - ); + List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Collections.singletonList(batch); - // Create mock response with single error Map errorMap = new HashMap<>(); errorMap.put("error", "Common error"); errorMap.put("http_code", 403); @@ -361,10 +213,8 @@ public void testHandleBatchException_ApiClientExceptionWithSingleError() { ApiClientApiException apiException = new ApiClientApiException("Forbidden", 403, responseBody); Exception exception = new Exception("Test exception", apiException); - // Test List errors = Utils.handleBatchException(exception, batch, 0, batches); - // Verify Assert.assertEquals("Should have errors for all records", 2, errors.size()); Assert.assertEquals("Error message should be same", "Common error", errors.get(0).getError()); Assert.assertEquals("Error code should be same", 403, errors.get(0).getCode()); @@ -373,20 +223,14 @@ public void testHandleBatchException_ApiClientExceptionWithSingleError() { } @Test - public void testHandleBatchException_NonApiClientException() { - // Prepare test data - List batch = Arrays.asList( - InsertRecordData.builder().build(), - InsertRecordData.builder().build() - ); + public void testHandleBatchException_WithNonApiClientException() { + List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Collections.singletonList(batch); RuntimeException exception = new RuntimeException("Unexpected error"); - // Test List errors = Utils.handleBatchException(exception, batch, 0, batches); - // Verify Assert.assertEquals("Should have errors for all records", 2, errors.size()); Assert.assertEquals("Error message should match", "Unexpected error", errors.get(0).getError()); Assert.assertEquals("Error code should be 500", 500, errors.get(0).getCode()); @@ -395,77 +239,67 @@ public void testHandleBatchException_NonApiClientException() { } @Test - public void testHandleBatchException_NonZeroBatchNumber() { - // Prepare test data - List batch = Arrays.asList( - InsertRecordData.builder().build(), - InsertRecordData.builder().build() - ); - List> batches = Arrays.asList( - new ArrayList<>(), // first batch - batch // second batch - ); + public void testHandleBatchException_WithNonZeroBatchNumber() { + List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); + List> batches = Arrays.asList(new ArrayList<>(), batch); RuntimeException exception = new RuntimeException("Batch error"); - // Test List errors = Utils.handleBatchException(exception, batch, 1, batches); - // Verify Assert.assertEquals("Should have errors for all records", 2, errors.size()); Assert.assertEquals("First error index should be offset", 2, errors.get(0).getIndex()); Assert.assertEquals("Second error index should be offset", 3, errors.get(1).getIndex()); } @Test - public void testHandleBatchException_NullResponseBody() { - // Prepare test data - List batch = Arrays.asList( - InsertRecordData.builder().build(), - InsertRecordData.builder().build() - ); + public void testHandleBatchException_WithNullResponseBody() { + List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Collections.singletonList(batch); ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, null); Exception exception = new Exception("Test exception", apiException); - // Test List errors = Utils.handleBatchException(exception, batch, 0, batches); - // Verify Assert.assertEquals("Should return empty list for null response body", 0, errors.size()); } @Test - public void testFormatResponse_NullResponse() { - com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(null, 0, 50); - System.out.println(result); - Assert.assertNull(result); - } + public void testFormatResponse_WithSuccessAndErrorRecords() { + RecordResponseObject successRecord = RecordResponseObject.builder() + .skyflowId(Optional.of("testId1")) + .error(Optional.empty()) + .build(); + RecordResponseObject errorRecord = RecordResponseObject.builder() + .error(Optional.of("Test error")) + .httpCode(Optional.of(400)) + .build(); - @Test - public void testHandleBatchException_GenericException() { - List batch = new ArrayList<>(); - InsertRecordData record1 = InsertRecordData.builder().build(); - InsertRecordData record2 = InsertRecordData.builder().build(); - batch.add(record1); - batch.add(record2); - List> batches = Collections.singletonList(batch); + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Arrays.asList(successRecord, errorRecord))) + .build(); - Exception exception = new RuntimeException("Generic error"); + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - List errors = Utils.handleBatchException(exception, batch, 0, batches); + Assert.assertNotNull(result.getSuccess()); + Assert.assertEquals(1, result.getSuccess().size()); + Assert.assertEquals("testId1", result.getSuccess().get(0).getSkyflowId()); + + Assert.assertNotNull(result.getErrors()); + Assert.assertEquals(1, result.getErrors().size()); + Assert.assertEquals("Test error", result.getErrors().get(0).getError()); + Assert.assertEquals(400, result.getErrors().get(0).getCode()); + } - Assert.assertEquals(2, errors.size()); - Assert.assertEquals("Generic error", errors.get(0).getError()); - Assert.assertEquals(500, errors.get(0).getCode()); - Assert.assertEquals(0, errors.get(0).getIndex()); - Assert.assertEquals(1, errors.get(1).getIndex()); + @Test + public void testFormatResponse_WithNullResponse() { + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(null, 0, 50); + Assert.assertNull(result); } @Test - public void testFormatResponse_SuccessRecords() { - // Create test data + public void testFormatResponse_WithSuccessRecordsOnly() { RecordResponseObject successRecord1 = RecordResponseObject.builder() .skyflowId(Optional.of("id1")) .error(Optional.empty()) @@ -479,10 +313,8 @@ public void testFormatResponse_SuccessRecords() { .records(Optional.of(Arrays.asList(successRecord1, successRecord2))) .build(); - // Test com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - // Verify Assert.assertNotNull("Response should not be null", result); Assert.assertEquals("Should have two success records", 2, result.getSuccess().size()); Assert.assertEquals("First skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); @@ -491,8 +323,7 @@ public void testFormatResponse_SuccessRecords() { } @Test - public void testFormatResponse_ErrorRecords() { - // Create test data + public void testFormatResponse_WithErrorRecordsOnly() { RecordResponseObject errorRecord1 = RecordResponseObject.builder() .error(Optional.of("Error 1")) .httpCode(Optional.of(400)) @@ -506,10 +337,8 @@ public void testFormatResponse_ErrorRecords() { .records(Optional.of(Arrays.asList(errorRecord1, errorRecord2))) .build(); - // Test com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - // Verify Assert.assertNotNull("Response should not be null", result); Assert.assertEquals("Should have two error records", 2, result.getErrors().size()); Assert.assertEquals("First error message should match", "Error 1", result.getErrors().get(0).getError()); @@ -519,37 +348,8 @@ public void testFormatResponse_ErrorRecords() { Assert.assertTrue("Success list should be empty", result.getSuccess().isEmpty()); } - @Test - public void testFormatResponse_MixedRecords() { - // Create test data - RecordResponseObject successRecord = RecordResponseObject.builder() - .skyflowId(Optional.of("id1")) - .error(Optional.empty()) - .build(); - RecordResponseObject errorRecord = RecordResponseObject.builder() - .error(Optional.of("Error")) - .httpCode(Optional.of(400)) - .build(); - - InsertResponse response = InsertResponse.builder() - .records(Optional.of(Arrays.asList(successRecord, errorRecord))) - .build(); - - // Test - com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - - // Verify - Assert.assertNotNull("Response should not be null", result); - Assert.assertEquals("Should have one success record", 1, result.getSuccess().size()); - Assert.assertEquals("Should have one error record", 1, result.getErrors().size()); - Assert.assertEquals("Success skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); - Assert.assertEquals("Error message should match", "Error", result.getErrors().get(0).getError()); - Assert.assertEquals("Error code should match", 400, result.getErrors().get(0).getCode()); - } - @Test public void testFormatResponse_WithBatchOffset() { - // Create test data RecordResponseObject successRecord = RecordResponseObject.builder() .skyflowId(Optional.of("id1")) .error(Optional.empty()) @@ -563,25 +363,20 @@ public void testFormatResponse_WithBatchOffset() { .records(Optional.of(Arrays.asList(successRecord, errorRecord))) .build(); - // Test with batch number 1 and batch size 50 com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 1, 50); - // Verify Assert.assertNotNull("Response should not be null", result); Assert.assertEquals("Should have correct index for error record", 51, result.getErrors().get(0).getIndex()); } @Test - public void testFormatResponse_EmptyRecords() { - // Create test data + public void testFormatResponse_WithEmptyRecords() { InsertResponse response = InsertResponse.builder() .records(Optional.of(new ArrayList<>())) .build(); - // Test com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - // Verify Assert.assertNotNull("Response should not be null", result); Assert.assertTrue("Success list should be empty", result.getSuccess().isEmpty()); Assert.assertTrue("Error list should be empty", result.getErrors().isEmpty()); @@ -589,7 +384,6 @@ public void testFormatResponse_EmptyRecords() { @Test public void testFormatResponse_WithTokens() { - // Create test data Map tokens = new HashMap<>(); tokens.put("field1", "token1"); tokens.put("field2", "token2"); @@ -604,13 +398,10 @@ public void testFormatResponse_WithTokens() { .records(Optional.of(Collections.singletonList(successRecord))) .build(); - // Test com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); - // Verify Assert.assertNotNull("Response should not be null", result); Assert.assertEquals("Should have one success record", 1, result.getSuccess().size()); Assert.assertEquals("Skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); - // Add more token-specific assertions once token handling is implemented } -} +} \ No newline at end of file From 938d163274cdc16352b1d22682d6c389a660d2b5 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Wed, 27 Aug 2025 17:30:28 +0530 Subject: [PATCH 57/97] SK-2269 Add error whitelisting for records to retry - Other code refactoring --- .../java/com/skyflow/utils/BaseUtils.java | 17 +-- .../skyflow/vault/data/BaseGetRequest.java | 122 ------------------ .../skyflow/vault/data/BaseGetResponse.java | 30 ----- .../vault/data/BaseInsertResponse.java | 30 ----- v2/src/main/java/com/skyflow/VaultClient.java | 2 +- .../java/com/skyflow/utils/Constants.java | 1 + v2/src/main/java/com/skyflow/utils/Utils.java | 5 + .../com/skyflow/vault/data/GetRequest.java | 87 +++++++++---- .../java/com/skyflow/utils/UtilsTests.java | 2 +- v3/src/main/java/com/skyflow/VaultClient.java | 2 +- .../java/com/skyflow/utils/Constants.java | 11 +- v3/src/main/java/com/skyflow/utils/Utils.java | 10 +- .../vault/controller/VaultController.java | 58 +++++---- .../skyflow/vault/data/InsertResponse.java | 10 +- 14 files changed, 131 insertions(+), 256 deletions(-) delete mode 100644 common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java delete mode 100644 common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index 97e91f0c..c9278517 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -23,9 +23,7 @@ public class BaseUtils { public static String getVaultURL(String clusterId, Env env, String vaultDomain) { - StringBuilder sb = new StringBuilder(BaseConstants.SECURE_PROTOCOL); - sb.append(clusterId); - sb.append(vaultDomain); + StringBuilder sb = buildBaseUrl(clusterId, vaultDomain); switch (env) { case DEV: sb.append(BaseConstants.DEV_DOMAIN); @@ -44,13 +42,6 @@ public static String getVaultURL(String clusterId, Env env, String vaultDomain) return sb.toString(); } - public static String getV2VaultURL(String clusterId, Env env) { - return getVaultURL(clusterId, env, BaseConstants.V2_VAULT_DOMAIN); - } - - public static String getV3VaultURL(String clusterId, Env env) { - return getVaultURL(clusterId, env, BaseConstants.V3_VAULT_DOMAIN); - } public static String generateBearerToken(Credentials credentials) throws SkyflowException { if (credentials.getPath() != null) { return BearerToken.builder() @@ -168,4 +159,10 @@ private static PrivateKey parsePkcs8PrivateKey(byte[] pkcs8Bytes) throws Skyflow return privateKey; } + private static StringBuilder buildBaseUrl(String clusterId, String vaultDomain) { + StringBuilder sb = new StringBuilder(BaseConstants.SECURE_PROTOCOL); + sb.append(clusterId); + sb.append(vaultDomain); + return sb; + } } diff --git a/common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java b/common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java deleted file mode 100644 index c6d828cc..00000000 --- a/common/src/main/java/com/skyflow/vault/data/BaseGetRequest.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.skyflow.vault.data; - -import com.skyflow.utils.BaseConstants; - -import java.util.ArrayList; - -class BaseGetRequest { - private final BaseGetRequestBuilder builder; - - protected BaseGetRequest(BaseGetRequestBuilder builder) { - this.builder = builder; - } - - public String getTable() { - return this.builder.table; - } - - public ArrayList getIds() { - return this.builder.ids; - } - - public Boolean getReturnTokens() { - return this.builder.returnTokens; - } - - public ArrayList getFields() { - return this.builder.fields; - } - - public String getOffset() { - return this.builder.offset; - } - - public String getLimit() { - return this.builder.limit; - } - - public Boolean getDownloadURL() { - return this.builder.downloadURL; - } - - public String getColumnName() { - return this.builder.columnName; - } - - public ArrayList getColumnValues() { - return this.builder.columnValues; - } - - public String getOrderBy() { - return this.builder.orderBy; - } - - static class BaseGetRequestBuilder { - protected String table; - protected ArrayList ids; - protected Boolean returnTokens; - protected ArrayList fields; - protected String offset; - protected String limit; - protected Boolean downloadURL; - protected String columnName; - protected ArrayList columnValues; - protected String orderBy; - - protected BaseGetRequestBuilder() { - this.downloadURL = true; - this.orderBy = BaseConstants.ORDER_ASCENDING; - } - - public BaseGetRequestBuilder table(String table) { - this.table = table; - return this; - } - - public BaseGetRequestBuilder ids(ArrayList ids) { - this.ids = ids; - return this; - } - - public BaseGetRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens; - return this; - } - - public BaseGetRequestBuilder fields(ArrayList fields) { - this.fields = fields; - return this; - } - - public BaseGetRequestBuilder offset(String offset) { - this.offset = offset; - return this; - } - - public BaseGetRequestBuilder limit(String limit) { - this.limit = limit; - return this; - } - - public BaseGetRequestBuilder downloadURL(Boolean downloadURL) { - this.downloadURL = downloadURL == null || downloadURL; - return this; - } - - public BaseGetRequestBuilder columnName(String columnName) { - this.columnName = columnName; - return this; - } - - public BaseGetRequestBuilder columnValues(ArrayList columnValues) { - this.columnValues = columnValues; - return this; - } - - public BaseGetRequestBuilder orderBy(String orderBy) { - this.orderBy = orderBy == null ? BaseConstants.ORDER_ASCENDING : orderBy; - return this; - } - - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java b/common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java deleted file mode 100644 index 7a985fe6..00000000 --- a/common/src/main/java/com/skyflow/vault/data/BaseGetResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; - -import java.util.ArrayList; -import java.util.HashMap; - -public class BaseGetResponse { - private final ArrayList> data; - private final ArrayList> errors; - - public BaseGetResponse(ArrayList> data, ArrayList> errors) { - this.data = data; - this.errors = errors; - } - - public ArrayList> getData() { - return data; - } - - public ArrayList> getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java b/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java deleted file mode 100644 index c8e5ef7e..00000000 --- a/common/src/main/java/com/skyflow/vault/data/BaseInsertResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.skyflow.vault.data; - -import com.google.gson.Gson; - -import java.util.ArrayList; -import java.util.HashMap; - -class BaseInsertResponse { - private final ArrayList> insertedFields; - private final ArrayList> errors; - - public BaseInsertResponse(ArrayList> insertedFields, ArrayList> errors) { - this.insertedFields = insertedFields; - this.errors = errors; - } - - public ArrayList> getInsertedFields() { - return insertedFields; - } - - public ArrayList> getErrors() { - return errors; - } - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/v2/src/main/java/com/skyflow/VaultClient.java b/v2/src/main/java/com/skyflow/VaultClient.java index 22193fae..7854a81b 100644 --- a/v2/src/main/java/com/skyflow/VaultClient.java +++ b/v2/src/main/java/com/skyflow/VaultClient.java @@ -783,7 +783,7 @@ private DeidentifyAudioRequestFileDataFormat mapAudioDataFormat(String dataForma } private void updateVaultURL() { - String vaultURL = Utils.getV2VaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); + String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); this.apiClientBuilder.url(vaultURL); } diff --git a/v2/src/main/java/com/skyflow/utils/Constants.java b/v2/src/main/java/com/skyflow/utils/Constants.java index c0f2a778..9b850bf0 100644 --- a/v2/src/main/java/com/skyflow/utils/Constants.java +++ b/v2/src/main/java/com/skyflow/utils/Constants.java @@ -4,6 +4,7 @@ public final class Constants extends BaseConstants { public static final String SDK_NAME = "Skyflow Java SDK "; public static final String SDK_VERSION = "2.0.0-beta.2"; public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; + public static final String VAULT_DOMAIN = ".vault."; public static final String PROCESSED_FILE_NAME_PREFIX = "processed-"; public static final String DEIDENTIFIED_FILE_PREFIX = "deidentified"; } diff --git a/v2/src/main/java/com/skyflow/utils/Utils.java b/v2/src/main/java/com/skyflow/utils/Utils.java index c1b34102..ff43c089 100644 --- a/v2/src/main/java/com/skyflow/utils/Utils.java +++ b/v2/src/main/java/com/skyflow/utils/Utils.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import com.skyflow.config.ConnectionConfig; +import com.skyflow.enums.Env; import com.skyflow.vault.connection.InvokeConnectionRequest; import java.util.HashMap; @@ -9,6 +10,10 @@ public final class Utils extends BaseUtils { + public static String getVaultURL(String clusterId, Env env) { + return getVaultURL(clusterId, env, Constants.VAULT_DOMAIN); + } + public static String constructConnectionURL(ConnectionConfig config, InvokeConnectionRequest invokeConnectionRequest) { StringBuilder filledURL = new StringBuilder(config.getConnectionUrl()); diff --git a/v2/src/main/java/com/skyflow/vault/data/GetRequest.java b/v2/src/main/java/com/skyflow/vault/data/GetRequest.java index ef4edea2..5fa59852 100644 --- a/v2/src/main/java/com/skyflow/vault/data/GetRequest.java +++ b/v2/src/main/java/com/skyflow/vault/data/GetRequest.java @@ -1,15 +1,15 @@ package com.skyflow.vault.data; import com.skyflow.enums.RedactionType; +import com.skyflow.utils.BaseConstants; import com.skyflow.utils.Constants; import java.util.ArrayList; -public class GetRequest extends BaseGetRequest { +public class GetRequest { private final GetRequestBuilder builder; private GetRequest(GetRequestBuilder builder) { - super(builder); this.builder = builder; } @@ -17,28 +17,75 @@ public static GetRequestBuilder builder() { return new GetRequestBuilder(); } + public String getTable() { + return this.builder.table; + } + + public ArrayList getIds() { + return this.builder.ids; + } + + public Boolean getReturnTokens() { + return this.builder.returnTokens; + } + + public ArrayList getFields() { + return this.builder.fields; + } + + public String getOffset() { + return this.builder.offset; + } + + public String getLimit() { + return this.builder.limit; + } + + public Boolean getDownloadURL() { + return this.builder.downloadURL; + } + + public String getColumnName() { + return this.builder.columnName; + } + + public ArrayList getColumnValues() { + return this.builder.columnValues; + } + + public String getOrderBy() { + return this.builder.orderBy; + } + public RedactionType getRedactionType() { return this.builder.redactionType; } - public static final class GetRequestBuilder extends BaseGetRequestBuilder { + public static final class GetRequestBuilder { + private String table; + private ArrayList ids; + private Boolean returnTokens; + private ArrayList fields; + private String offset; + private String limit; + private Boolean downloadURL; + private String columnName; + private ArrayList columnValues; + private String orderBy; private RedactionType redactionType; private GetRequestBuilder() { - super(); this.downloadURL = true; this.orderBy = Constants.ORDER_ASCENDING; } - @Override public GetRequestBuilder table(String table) { - super.table(table); + this.table = table; return this; } - @Override public GetRequestBuilder ids(ArrayList ids) { - super.ids(ids); + this.ids = ids; return this; } @@ -47,51 +94,43 @@ public GetRequestBuilder redactionType(RedactionType redactionType) { return this; } - @Override public GetRequestBuilder returnTokens(Boolean returnTokens) { - super.returnTokens(returnTokens); + this.returnTokens = returnTokens; return this; } - @Override public GetRequestBuilder fields(ArrayList fields) { - super.fields(fields); + this.fields = fields; return this; } - @Override public GetRequestBuilder offset(String offset) { - super.offset(offset); + this.offset = offset; return this; } - @Override public GetRequestBuilder limit(String limit) { - super.limit(limit); + this.limit = limit; return this; } - @Override public GetRequestBuilder downloadURL(Boolean downloadURL) { - super.downloadURL(downloadURL); + this.downloadURL = downloadURL == null || downloadURL; return this; } - @Override public GetRequestBuilder columnName(String columnName) { - super.columnName(columnName); + this.columnName = columnName; return this; } - @Override public GetRequestBuilder columnValues(ArrayList columnValues) { - super.columnValues(columnValues); + this.columnValues = columnValues; return this; } - @Override public GetRequestBuilder orderBy(String orderBy) { - super.orderBy(orderBy); + this.orderBy = orderBy == null ? BaseConstants.ORDER_ASCENDING : orderBy; return this; } diff --git a/v2/test/java/com/skyflow/utils/UtilsTests.java b/v2/test/java/com/skyflow/utils/UtilsTests.java index f29096b7..4f1bba41 100644 --- a/v2/test/java/com/skyflow/utils/UtilsTests.java +++ b/v2/test/java/com/skyflow/utils/UtilsTests.java @@ -62,7 +62,7 @@ public void testGetVaultURLForDifferentENVs() { map.put(Env.PROD, "https://test_cluster_id.vault.skyflowapis.com"); for (Env env : map.keySet()) { - String vaultURL = Utils.getV2VaultURL(clusterId, env); + String vaultURL = Utils.getVaultURL(clusterId, env); Assert.assertEquals(map.get(env), vaultURL); } } catch (Exception e) { diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index 1214e9a3..558e2dbd 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -79,7 +79,7 @@ protected void setBearerToken() throws SkyflowException { } private void updateVaultURL() { - String vaultURL = Utils.getV3VaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); + String vaultURL = Utils.getVaultURL(this.vaultConfig.getClusterId(), this.vaultConfig.getEnv()); this.apiClientBuilder.url(vaultURL); } diff --git a/v3/src/main/java/com/skyflow/utils/Constants.java b/v3/src/main/java/com/skyflow/utils/Constants.java index 35d618c8..f295ab52 100644 --- a/v3/src/main/java/com/skyflow/utils/Constants.java +++ b/v3/src/main/java/com/skyflow/utils/Constants.java @@ -1,9 +1,14 @@ package com.skyflow.utils; -public class Constants extends BaseConstants { +public final class Constants extends BaseConstants { public static final String SDK_NAME = "Skyflow Java SDK "; public static final String SDK_VERSION = "3.0.0-beta.0"; + public static final String VAULT_DOMAIN = ".skyvault."; public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION; - public static final Integer BATCH_SIZE = 50; - public static final Integer CONCURRENCY_LIMIT = 10; + public static final Integer INSERT_BATCH_SIZE = 50; + public static final Integer MAX_INSERT_BATCH_SIZE = 1000; + public static final Integer INSERT_CONCURRENCY_LIMIT = 10; + public static final Integer MAX_INSERT_CONCURRENCY_LIMIT = 10; + public static final Integer DETOKENIZE_BATCH_SIZE = 100; + public static final Integer DETOKENIZE_CONCURRENCY_LIMIT = 10; } diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 5625798e..f2393379 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -1,15 +1,13 @@ package com.skyflow.utils; import com.google.gson.JsonObject; +import com.skyflow.enums.Env; import com.skyflow.generated.rest.core.ApiClientApiException; import com.skyflow.generated.rest.types.InsertRecordData; import com.skyflow.generated.rest.types.InsertResponse; import com.skyflow.generated.rest.types.RecordResponseObject; -import com.skyflow.logs.InfoLogs; -import com.skyflow.utils.logger.LogUtil; import com.skyflow.vault.data.ErrorRecord; import com.skyflow.vault.data.Success; -import com.skyflow.vault.data.Token; import java.util.ArrayList; import java.util.List; @@ -17,6 +15,10 @@ public final class Utils extends BaseUtils { + public static String getVaultURL(String clusterId, Env env) { + return getVaultURL(clusterId, env, Constants.VAULT_DOMAIN); + } + public static JsonObject getMetrics() { JsonObject details = getCommonMetrics(); String sdkVersion = Constants.SDK_VERSION; @@ -34,7 +36,7 @@ public static List> createBatches(List public static ErrorRecord createErrorRecord(Map recordMap, int indexNumber) { ErrorRecord err = null; - if( recordMap != null ) { + if (recordMap != null) { int code = recordMap.containsKey("http_code") ? (Integer) recordMap.get("http_code") : 500; String message = recordMap.containsKey("error") ? (String) recordMap.get("error") : recordMap.containsKey("message") ? (String) recordMap.get("message") : "Unknown error"; diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 49df042e..dfe1b7f0 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -34,13 +34,17 @@ public final class VaultController extends VaultClient { private static final Gson gson = new GsonBuilder().serializeNulls().create(); - private int batchSize; - private int concurrencyLimit; + private int insertBatchSize; + private int insertConcurrencyLimit; + private int detokenizeBatchSize; + private int detokenizeConcurrencyLimit; public VaultController(VaultConfig vaultConfig, Credentials credentials) { super(vaultConfig, credentials); - this.batchSize = Constants.BATCH_SIZE; - this.concurrencyLimit = Constants.CONCURRENCY_LIMIT; + this.insertBatchSize = Constants.INSERT_BATCH_SIZE; + this.insertConcurrencyLimit = Constants.INSERT_CONCURRENCY_LIMIT; + this.detokenizeBatchSize = Constants.DETOKENIZE_BATCH_SIZE; + this.detokenizeConcurrencyLimit = Constants.DETOKENIZE_CONCURRENCY_LIMIT; } public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequest) throws SkyflowException { @@ -50,7 +54,7 @@ public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequ LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); setBearerToken(); - configureConcurrencyAndBatchSize(insertRequest.getValues().size()); + configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); response = this.processSync(request, insertRequest.getValues()); @@ -71,7 +75,7 @@ public CompletableFuture bulkInsertAsync( LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); setBearerToken(); - configureConcurrencyAndBatchSize(insertRequest.getValues().size()); + configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); List errorRecords = new ArrayList<>(); @@ -137,8 +141,8 @@ private List> insertBat ) { List records = insertRequest.getRecords().get(); - ExecutorService executor = Executors.newFixedThreadPool(concurrencyLimit); - List> batches = Utils.createBatches(records, batchSize); + ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); + List> batches = Utils.createBatches(records, insertBatchSize); List> futures = new ArrayList<>(); try { @@ -152,7 +156,7 @@ private List> insertBat errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); return null; }) - .thenApply(response -> formatResponse(response, batchNumber, batchSize)); + .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)); futures.add(future); } } finally { @@ -170,51 +174,53 @@ private InsertResponse insertBatch(List batch, String tableNam return this.getRecordsApi().insert(req); } - private void configureConcurrencyAndBatchSize(int totalRequests) { + private void configureInsertConcurrencyAndBatchSize(int totalRequests) { try { Dotenv dotenv = Dotenv.load(); - String userProvidedBatchSize = dotenv.get("BATCH_SIZE"); - String userProvidedConcurrencyLimit = dotenv.get("CONCURRENCY_LIMIT"); + String userProvidedBatchSize = dotenv.get("INSERT_BATCH_SIZE"); + String userProvidedConcurrencyLimit = dotenv.get("INSERT_CONCURRENCY_LIMIT"); if (userProvidedBatchSize != null) { try { int batchSize = Integer.parseInt(userProvidedBatchSize); - if (batchSize > 0) { - this.batchSize = batchSize; + int maxBatchSize = Math.min(batchSize, Constants.MAX_INSERT_BATCH_SIZE); + if (maxBatchSize > 0) { + this.insertBatchSize = batchSize; } else { LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); - this.batchSize = Constants.BATCH_SIZE; + this.insertBatchSize = Constants.INSERT_BATCH_SIZE; } } catch (NumberFormatException e) { LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); - this.batchSize = Constants.BATCH_SIZE; + this.insertBatchSize = Constants.INSERT_BATCH_SIZE; } } // Max no of threads required to run all batches concurrently at once - int maxConcurrencyNeeded = (totalRequests + this.batchSize - 1) / this.batchSize; + int maxConcurrencyNeeded = (totalRequests + this.insertBatchSize - 1) / this.insertBatchSize; if (userProvidedConcurrencyLimit != null) { try { int concurrencyLimit = Integer.parseInt(userProvidedConcurrencyLimit); - if (concurrencyLimit > 0) { - this.concurrencyLimit = Math.min(concurrencyLimit, maxConcurrencyNeeded); + int maxConcurrencyLimit = Math.min(concurrencyLimit, Constants.MAX_INSERT_CONCURRENCY_LIMIT); + + if (maxConcurrencyLimit > 0) { + this.insertConcurrencyLimit = Math.min(maxConcurrencyLimit, maxConcurrencyNeeded); } else { LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); - this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + this.insertConcurrencyLimit = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } catch (NumberFormatException e) { LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); - this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + this.insertConcurrencyLimit = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } else { - this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + this.insertConcurrencyLimit = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } catch (Exception e) { - this.batchSize = Constants.BATCH_SIZE; - int maxConcurrencyNeeded = (totalRequests + this.batchSize - 1) / this.batchSize; - this.concurrencyLimit = Math.min(Constants.CONCURRENCY_LIMIT, maxConcurrencyNeeded); + this.insertBatchSize = Constants.INSERT_BATCH_SIZE; + int maxConcurrencyNeeded = (totalRequests + this.insertBatchSize - 1) / this.insertBatchSize; + this.insertConcurrencyLimit = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } - } diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 0fb9ef6a..85e4b764 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class InsertResponse { // These members will be included in the toString() output @@ -53,10 +54,11 @@ public List getErrors() { public List> getRecordsToRetry() { if (recordsToRetry == null) { recordsToRetry = new ArrayList<>(); - for (ErrorRecord errorRecord : errors) { - int index = errorRecord.getIndex(); - recordsToRetry.add(originalPayload.get(index)); - } + + return errors.stream() + .filter(error -> (error.getCode() >= 500 && error.getCode() <= 599) && error.getCode() != 529) + .map(errorRecord -> originalPayload.get(errorRecord.getIndex())) + .collect(Collectors.toList()); } return this.recordsToRetry; } From 1e929232eada9b3f3e2320c4aac8a58cbb9144a3 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Wed, 27 Aug 2025 18:29:03 +0530 Subject: [PATCH 58/97] SK-2269 Fix return type for getRecordsToRetry - Updated return type from List of Map to ArrayList of HashMap --- .../main/java/com/skyflow/vault/data/InsertResponse.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 85e4b764..26983359 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; public class InsertResponse { @@ -21,7 +20,7 @@ public class InsertResponse { // Internal fields. Should not be included in toString() output private ArrayList> originalPayload; - private List> recordsToRetry; + private ArrayList> recordsToRetry; public InsertResponse(List successRecords, List errorRecords) { this.success = successRecords; @@ -51,14 +50,13 @@ public List getErrors() { return this.errors; } - public List> getRecordsToRetry() { + public ArrayList> getRecordsToRetry() { if (recordsToRetry == null) { recordsToRetry = new ArrayList<>(); - return errors.stream() .filter(error -> (error.getCode() >= 500 && error.getCode() <= 599) && error.getCode() != 529) .map(errorRecord -> originalPayload.get(errorRecord.getIndex())) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); } return this.recordsToRetry; } From a990dadec339e7ee4b41abe1621ae51ce93cd9c2 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 19:32:39 +0530 Subject: [PATCH 59/97] SK-2258 fixed utils test and add tokens in response --- v3/src/main/java/com/skyflow/utils/Utils.java | 34 ++-- .../skyflow/vault/data/InsertResponse.java | 4 +- .../java/com/skyflow/utils/UtilsTests.java | 164 +++++++++++++++--- 3 files changed, 168 insertions(+), 34 deletions(-) diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index f2393379..e44395db 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -8,8 +8,10 @@ import com.skyflow.generated.rest.types.RecordResponseObject; import com.skyflow.vault.data.ErrorRecord; import com.skyflow.vault.data.Success; +import com.skyflow.vault.data.Token; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -101,17 +103,29 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons ErrorRecord errorRecord = new ErrorRecord(indexNumber, record.get(index).getError().get(), record.get(index).getHttpCode().get()); errorRecords.add(errorRecord); } else { - Success success = new Success(index, record.get(index).getSkyflowId().get(), null, null); -// if (record.get(index).getTokens().isPresent()) { -// List tokens = null; -// Map tok = record.get(index).getTokens().get(); -// for (int i = 0; i < tok.size(); i++) { -// Object obj = tok.get(i); -//// Token token = new Token(obj.toString()); -// } -// } -// success.setTokens(record.get(index).getTokens().get()); + Map> tokensMap = null; + if (record.get(index).getTokens().isPresent()) { + tokensMap = new HashMap<>(); + Map tok = record.get(index).getTokens().get(); + for (Map.Entry entry : tok.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + List tokenList = new ArrayList<>(); + if (value instanceof List) { + List valueList = (List) value; + for (Object item : valueList) { + if(item instanceof Map) { + Map tokenMap = (Map) item; + Token token = new Token((String) tokenMap.get("token"), (String) tokenMap.get("tokenGroupName")); + tokenList.add(token); + } + } + } + tokensMap.put(key, tokenList); + } + } + Success success = new Success(index, record.get(index).getSkyflowId().get(), tokensMap, null); successRecords.add(success); } indexNumber++; diff --git a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java index 26983359..a84e121c 100644 --- a/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/InsertResponse.java @@ -53,12 +53,12 @@ public List getErrors() { public ArrayList> getRecordsToRetry() { if (recordsToRetry == null) { recordsToRetry = new ArrayList<>(); - return errors.stream() + recordsToRetry = errors.stream() .filter(error -> (error.getCode() >= 500 && error.getCode() <= 599) && error.getCode() != 529) .map(errorRecord -> originalPayload.get(errorRecord.getIndex())) .collect(Collectors.toCollection(ArrayList::new)); } - return this.recordsToRetry; + return recordsToRetry; } @Override diff --git a/v3/test/java/com/skyflow/utils/UtilsTests.java b/v3/test/java/com/skyflow/utils/UtilsTests.java index 44ac9595..b4af629c 100644 --- a/v3/test/java/com/skyflow/utils/UtilsTests.java +++ b/v3/test/java/com/skyflow/utils/UtilsTests.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import com.skyflow.config.Credentials; +import com.skyflow.enums.Env; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; @@ -10,6 +11,8 @@ import com.skyflow.generated.rest.types.InsertResponse; import com.skyflow.generated.rest.types.RecordResponseObject; import com.skyflow.vault.data.ErrorRecord; +import com.skyflow.vault.data.Success; +import com.skyflow.vault.data.Token; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -18,7 +21,7 @@ public class UtilsTests { 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 final String EXCEPTIONNOTTHROWN = "Should have thrown an exception"; private static String filePath = null; private static String credentialsString = null; private static String token = null; @@ -30,13 +33,43 @@ public static void setup() { filePath = "invalid/file/path/credentials.json"; credentialsString = "invalid credentials string"; token = "invalid-token"; - context = "test_context"; + context = "testcontext"; roles = new ArrayList<>(); - String role = "test_role"; + String role = "testrole"; roles.add(role); SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); } + @Test + public void testGetVaultURL() { + // Test with production environment + String prodUrl = Utils.getVaultURL("abc123", Env.PROD); + Assert.assertEquals( + "https://abc123.skyvault.skyflowapis.com", + prodUrl + ); + + // Test with development environment + String devUrl = Utils.getVaultURL("xyz789", Env.DEV); + Assert.assertEquals( + "https://xyz789.skyvault.skyflowapis.dev", + devUrl + ); + } + @Test(expected = NullPointerException.class) + public void testGetVaultURLWithNullEnv() { + Utils.getVaultURL("abc123", null); + } + + @Test + public void testGetVaultURLWithEmptyClusterId() { + String url = Utils.getVaultURL("", Env.PROD); + Assert.assertEquals( + "https://.skyvault.skyflowapis.com", + url + ); + } + @Test public void testGenerateBearerTokenWithCredentialsFile() { try { @@ -45,7 +78,7 @@ public void testGenerateBearerTokenWithCredentialsFile() { credentials.setContext(context); credentials.setRoles(roles); Utils.generateBearerToken(credentials); - Assert.fail(EXCEPTION_NOT_THROWN); + Assert.fail(EXCEPTIONNOTTHROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals( @@ -63,7 +96,7 @@ public void testGenerateBearerTokenWithCredentialsString() { credentials.setContext(context); credentials.setRoles(roles); Utils.generateBearerToken(credentials); - Assert.fail(EXCEPTION_NOT_THROWN); + Assert.fail(EXCEPTIONNOTTHROWN); } catch (SkyflowException e) { Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); Assert.assertEquals(ErrorMessage.CredentialsStringInvalidJson.getMessage(), e.getMessage()); @@ -116,7 +149,7 @@ public void testGetMetricsWithException() { } @Test - public void testCreateBatches_MultipleBatches() { + public void testCreateBatchesMultipleBatches() { List records = new ArrayList<>(); for (int i = 0; i < 125; i++) { records.add(InsertRecordData.builder().build()); @@ -130,14 +163,14 @@ public void testCreateBatches_MultipleBatches() { } @Test - public void testCreateBatches_WithEmptyList() { + public void testCreateBatchesWithEmptyList() { List records = new ArrayList<>(); List> batches = Utils.createBatches(records, 50); Assert.assertTrue("Batches should be empty for empty input", batches.isEmpty()); } @Test - public void testCreateBatches_WithSmallerSizeThanBatch() { + public void testCreateBatchesWithSmallerSizeThanBatch() { List records = new ArrayList<>(); for (int i = 0; i < 25; i++) { records.add(InsertRecordData.builder().build()); @@ -149,7 +182,7 @@ public void testCreateBatches_WithSmallerSizeThanBatch() { } @Test - public void testCreateBatches_WithExactBatchSize() { + public void testCreateBatchesWithExactBatchSize() { List records = new ArrayList<>(); for (int i = 0; i < 50; i++) { records.add(InsertRecordData.builder().build()); @@ -161,7 +194,7 @@ public void testCreateBatches_WithExactBatchSize() { } @Test - public void testCreateBatches_PreservesOrder() { + public void testCreateBatchesPreservesOrder() { List records = new ArrayList<>(); for (int i = 0; i < 75; i++) { InsertRecordData record = InsertRecordData.builder() @@ -180,7 +213,7 @@ public void testCreateBatches_PreservesOrder() { } @Test(expected = NullPointerException.class) - public void testCreateBatches_WithNullList() { + public void testCreateBatchesWithNullList() { Utils.createBatches(null, 50); } @@ -199,7 +232,7 @@ public void testCreateErrorRecord() { } @Test - public void testHandleBatchException_ApiClientExceptionWithSingleError() { + public void testHandleBatchExceptionApiClientExceptionWithSingleError() { List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Collections.singletonList(batch); @@ -223,7 +256,7 @@ public void testHandleBatchException_ApiClientExceptionWithSingleError() { } @Test - public void testHandleBatchException_WithNonApiClientException() { + public void testHandleBatchExceptionWithNonApiClientException() { List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Collections.singletonList(batch); @@ -239,7 +272,7 @@ public void testHandleBatchException_WithNonApiClientException() { } @Test - public void testHandleBatchException_WithNonZeroBatchNumber() { + public void testHandleBatchExceptionWithNonZeroBatchNumber() { List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Arrays.asList(new ArrayList<>(), batch); @@ -253,7 +286,7 @@ public void testHandleBatchException_WithNonZeroBatchNumber() { } @Test - public void testHandleBatchException_WithNullResponseBody() { + public void testHandleBatchExceptionWithNullResponseBody() { List batch = Arrays.asList(InsertRecordData.builder().build(), InsertRecordData.builder().build()); List> batches = Collections.singletonList(batch); @@ -266,7 +299,7 @@ public void testHandleBatchException_WithNullResponseBody() { } @Test - public void testFormatResponse_WithSuccessAndErrorRecords() { + public void testFormatResponseWithSuccessAndErrorRecords() { RecordResponseObject successRecord = RecordResponseObject.builder() .skyflowId(Optional.of("testId1")) .error(Optional.empty()) @@ -293,13 +326,13 @@ public void testFormatResponse_WithSuccessAndErrorRecords() { } @Test - public void testFormatResponse_WithNullResponse() { + public void testFormatResponseWithNullResponse() { com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(null, 0, 50); Assert.assertNull(result); } @Test - public void testFormatResponse_WithSuccessRecordsOnly() { + public void testFormatResponseWithSuccessRecordsOnly() { RecordResponseObject successRecord1 = RecordResponseObject.builder() .skyflowId(Optional.of("id1")) .error(Optional.empty()) @@ -323,7 +356,7 @@ public void testFormatResponse_WithSuccessRecordsOnly() { } @Test - public void testFormatResponse_WithErrorRecordsOnly() { + public void testFormatResponseWithErrorRecordsOnly() { RecordResponseObject errorRecord1 = RecordResponseObject.builder() .error(Optional.of("Error 1")) .httpCode(Optional.of(400)) @@ -349,7 +382,7 @@ public void testFormatResponse_WithErrorRecordsOnly() { } @Test - public void testFormatResponse_WithBatchOffset() { + public void testFormatResponseWithBatchOffset() { RecordResponseObject successRecord = RecordResponseObject.builder() .skyflowId(Optional.of("id1")) .error(Optional.empty()) @@ -370,7 +403,7 @@ public void testFormatResponse_WithBatchOffset() { } @Test - public void testFormatResponse_WithEmptyRecords() { + public void testFormatResponseWithEmptyRecords() { InsertResponse response = InsertResponse.builder() .records(Optional.of(new ArrayList<>())) .build(); @@ -383,7 +416,7 @@ public void testFormatResponse_WithEmptyRecords() { } @Test - public void testFormatResponse_WithTokens() { + public void testFormatResponseWithTokens() { Map tokens = new HashMap<>(); tokens.put("field1", "token1"); tokens.put("field2", "token2"); @@ -404,4 +437,91 @@ public void testFormatResponse_WithTokens() { Assert.assertEquals("Should have one success record", 1, result.getSuccess().size()); Assert.assertEquals("Skyflow ID should match", "id1", result.getSuccess().get(0).getSkyflowId()); } + @Test + public void testFormatResponseWithTokenListMapping() { + // Prepare test data + Map tokenData = new HashMap<>(); + List> tokenList = new ArrayList<>(); + Map tokenMap = new HashMap<>(); + tokenMap.put("token", "token123"); + tokenMap.put("tokenGroupName", "group1"); + tokenList.add(tokenMap); + tokenData.put("field1", tokenList); + + // Create success record with tokens + RecordResponseObject successRecord = RecordResponseObject.builder() + .skyflowId(Optional.of("id1")) + .tokens(Optional.of(tokenData)) + .error(Optional.empty()) + .build(); + + // Create response object + InsertResponse response = InsertResponse.builder() + .records(Optional.of(Collections.singletonList(successRecord))) + .build(); + + // Format response + com.skyflow.vault.data.InsertResponse result = Utils.formatResponse(response, 0, 50); + + // Assertions + Assert.assertNotNull("Response should not be null", result); + Assert.assertEquals("Should have one success record", 1, result.getSuccess().size()); + + Success successResult = result.getSuccess().get(0); + Assert.assertEquals("Skyflow ID should match", "id1", successResult.getSkyflowId()); + + Map> tokens = successResult.getTokens(); + Assert.assertNotNull("Tokens map should not be null", tokens); + Assert.assertTrue("Should contain field1", tokens.containsKey("field1")); + + List tokensList = tokens.get("field1"); + Assert.assertEquals("Should have one token", 1, tokensList.size()); + Assert.assertEquals("Token value should match", "token123", tokensList.get(0).getToken()); + Assert.assertEquals("Token group name should match", "group1", tokensList.get(0).getTokenGroupName()); + } + @Test + public void testHandleBatchExceptionWithRecordsInResponseBody() { + // Prepare test data + List batch = Arrays.asList( + InsertRecordData.builder().build(), + InsertRecordData.builder().build() + ); + List> batches = Collections.singletonList(batch); + + // Create nested records with errors + List> recordsList = new ArrayList<>(); + Map record1 = new HashMap<>(); + record1.put("error", "Error 1"); + record1.put("http_code", 400); + Map record2 = new HashMap<>(); + record2.put("error", "Error 2"); + record2.put("http_code", 401); + recordsList.add(record1); + recordsList.add(record2); + + // Create response body + Map responseBody = new HashMap<>(); + responseBody.put("records", recordsList); + + // Create API exception + ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, responseBody); + Exception exception = new Exception("Test exception", apiException); + + // Test the method + List errors = Utils.handleBatchException(exception, batch, 0, batches); + + // Assertions + Assert.assertNotNull("Errors list should not be null", errors); + Assert.assertEquals("Should have two error records", 2, errors.size()); + + // Verify first error + Assert.assertEquals("First error message should match", "Error 1", errors.get(0).getError()); + Assert.assertEquals("First error code should match", 400, errors.get(0).getCode()); + Assert.assertEquals("First error index should be 0", 0, errors.get(0).getIndex()); + + // Verify second error + Assert.assertEquals("Second error message should match", "Error 2", errors.get(1).getError()); + Assert.assertEquals("Second error code should match", 401, errors.get(1).getCode()); + Assert.assertEquals("Second error index should be 1", 1, errors.get(1).getIndex()); + } } \ No newline at end of file From 29a36afd38fe6e7676ef7034da0a4bdd21a7f43c Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 20:47:03 +0530 Subject: [PATCH 60/97] SK-2258 fix the v2 insert test --- .../generated/{ => auth}/rest/ApiClient.java | 8 +++--- .../{ => auth}/rest/ApiClientBuilder.java | 6 ++--- .../{ => auth}/rest/AsyncApiClient.java | 8 +++--- .../rest/AsyncApiClientBuilder.java | 6 ++--- .../rest/core/ApiClientApiException.java | 2 +- .../rest/core/ApiClientException.java | 2 +- .../rest/core/ApiClientHttpResponse.java | 2 +- .../{ => auth}/rest/core/ClientOptions.java | 2 +- .../rest/core/DateTimeDeserializer.java | 2 +- .../{ => auth}/rest/core/Environment.java | 2 +- .../{ => auth}/rest/core/FileStream.java | 2 +- .../rest/core/InputStreamRequestBody.java | 2 +- .../{ => auth}/rest/core/MediaTypes.java | 2 +- .../{ => auth}/rest/core/Nullable.java | 2 +- .../rest/core/NullableNonemptyFilter.java | 2 +- .../{ => auth}/rest/core/ObjectMappers.java | 2 +- .../rest/core/QueryStringMapper.java | 2 +- .../{ => auth}/rest/core/RequestOptions.java | 2 +- .../rest/core/ResponseBodyInputStream.java | 2 +- .../rest/core/ResponseBodyReader.java | 2 +- .../rest/core/RetryInterceptor.java | 2 +- .../{ => auth}/rest/core/Stream.java | 2 +- .../{ => auth}/rest/core/Suppliers.java | 2 +- .../rest/errors/BadRequestError.java | 4 +-- .../{ => auth}/rest/errors/HttpStatus.java | 2 +- .../{ => auth}/rest/errors/NotFoundError.java | 4 +-- .../rest/errors/UnauthorizedError.java | 4 +-- .../AsyncAuthenticationClient.java | 11 ++++---- .../AsyncRawAuthenticationClient.java | 27 ++++++++++--------- .../authentication/AuthenticationClient.java | 10 +++---- .../RawAuthenticationClient.java | 27 ++++++++++--------- .../requests/V1GetAuthTokenRequest.java | 5 ++-- .../rest/types/GooglerpcStatus.java | 4 +-- .../{ => auth}/rest/types/ProtobufAny.java | 4 +-- .../rest/types/V1GetAuthTokenResponse.java | 4 +-- .../serviceaccount/util/BearerToken.java | 12 ++++----- .../com/skyflow/config/CredentialsTests.java | 0 .../com/skyflow/config/VaultConfigTests.java | 0 .../skyflow/errors/SkyflowExceptionTest.java | 0 .../serviceaccount/util/BearerTokenTests.java | 14 +++++----- .../util/SignedDataTokensTests.java | 10 +++---- .../serviceaccount/util/TokenTests.java | 0 .../com/skyflow/utils/BaseUtilsTests.java | 0 .../invalidPrivateKeyCredentials.json | 0 .../resources/invalidTokenURICredentials.json | 0 .../test/resources/noClientIDCredentials.json | 0 .../test/resources/noKeyIDCredentials.json | 0 .../resources/noPrivateKeyCredentials.json | 0 .../test/resources/noTokenURICredentials.json | 0 common/{src => }/test/resources/notJson.txt | 0 .../com/skyflow/vault/data/InsertRequest.java | 2 +- .../java/com/skyflow/utils/UtilsTests.java | 17 ++++++------ 52 files changed, 115 insertions(+), 112 deletions(-) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/ApiClient.java (73%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/ApiClientBuilder.java (91%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/AsyncApiClient.java (73%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/AsyncApiClientBuilder.java (91%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ApiClientApiException.java (97%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ApiClientException.java (89%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ApiClientHttpResponse.java (95%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ClientOptions.java (99%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/DateTimeDeserializer.java (97%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/Environment.java (92%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/FileStream.java (97%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/InputStreamRequestBody.java (98%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/MediaTypes.java (84%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/Nullable.java (98%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/NullableNonemptyFilter.java (90%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ObjectMappers.java (96%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/QueryStringMapper.java (99%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/RequestOptions.java (98%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ResponseBodyInputStream.java (97%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/ResponseBodyReader.java (97%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/RetryInterceptor.java (98%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/Stream.java (98%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/core/Suppliers.java (93%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/errors/BadRequestError.java (86%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/errors/HttpStatus.java (83%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/errors/NotFoundError.java (86%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/errors/UnauthorizedError.java (86%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/resources/authentication/AsyncAuthenticationClient.java (84%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/resources/authentication/AsyncRawAuthenticationClient.java (87%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/resources/authentication/AuthenticationClient.java (82%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/resources/authentication/RawAuthenticationClient.java (84%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/resources/authentication/requests/V1GetAuthTokenRequest.java (98%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/types/GooglerpcStatus.java (97%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/types/ProtobufAny.java (96%) rename common/src/main/java/com/skyflow/generated/{ => auth}/rest/types/V1GetAuthTokenResponse.java (97%) rename common/{src => }/test/java/com/skyflow/config/CredentialsTests.java (100%) rename common/{src => }/test/java/com/skyflow/config/VaultConfigTests.java (100%) rename common/{src => }/test/java/com/skyflow/errors/SkyflowExceptionTest.java (100%) rename common/{src => }/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java (94%) rename common/{src => }/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java (95%) rename common/{src => }/test/java/com/skyflow/serviceaccount/util/TokenTests.java (100%) rename common/{src => }/test/java/com/skyflow/utils/BaseUtilsTests.java (100%) rename common/{src => }/test/resources/invalidPrivateKeyCredentials.json (100%) rename common/{src => }/test/resources/invalidTokenURICredentials.json (100%) rename common/{src => }/test/resources/noClientIDCredentials.json (100%) rename common/{src => }/test/resources/noKeyIDCredentials.json (100%) rename common/{src => }/test/resources/noPrivateKeyCredentials.json (100%) rename common/{src => }/test/resources/noTokenURICredentials.json (100%) rename common/{src => }/test/resources/notJson.txt (100%) diff --git a/common/src/main/java/com/skyflow/generated/rest/ApiClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/ApiClient.java similarity index 73% rename from common/src/main/java/com/skyflow/generated/rest/ApiClient.java rename to common/src/main/java/com/skyflow/generated/auth/rest/ApiClient.java index f49fc4c3..721942e9 100644 --- a/common/src/main/java/com/skyflow/generated/rest/ApiClient.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/ApiClient.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest; +package com.skyflow.generated.auth.rest; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.Suppliers; -import com.skyflow.generated.rest.resources.authentication.AuthenticationClient; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.Suppliers; +import com.skyflow.generated.auth.rest.resources.authentication.AuthenticationClient; import java.util.function.Supplier; public class ApiClient { diff --git a/common/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/auth/rest/ApiClientBuilder.java similarity index 91% rename from common/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java rename to common/src/main/java/com/skyflow/generated/auth/rest/ApiClientBuilder.java index b361812a..aed3ed24 100644 --- a/common/src/main/java/com/skyflow/generated/rest/ApiClientBuilder.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/ApiClientBuilder.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest; +package com.skyflow.generated.auth.rest; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.Environment; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.Environment; import okhttp3.OkHttpClient; public final class ApiClientBuilder { diff --git a/common/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClient.java similarity index 73% rename from common/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java rename to common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClient.java index d9163e14..674a9ef9 100644 --- a/common/src/main/java/com/skyflow/generated/rest/AsyncApiClient.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClient.java @@ -1,11 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest; +package com.skyflow.generated.auth.rest; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.Suppliers; -import com.skyflow.generated.rest.resources.authentication.AsyncAuthenticationClient; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.Suppliers; +import com.skyflow.generated.auth.rest.resources.authentication.AsyncAuthenticationClient; import java.util.function.Supplier; public class AsyncApiClient { diff --git a/common/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClientBuilder.java similarity index 91% rename from common/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java rename to common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClientBuilder.java index 8e4b8474..2e30d45a 100644 --- a/common/src/main/java/com/skyflow/generated/rest/AsyncApiClientBuilder.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClientBuilder.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest; +package com.skyflow.generated.auth.rest; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.Environment; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.Environment; import okhttp3.OkHttpClient; public final class AsyncApiClientBuilder { diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientApiException.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientApiException.java index a4487b1e..dc4c008c 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ApiClientApiException.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientApiException.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.ArrayList; import java.util.HashMap; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientException.java similarity index 89% rename from common/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientException.java index 7987eba6..f08afa2e 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ApiClientException.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientException.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; /** * This class serves as the base exception for all errors in the SDK. diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientHttpResponse.java similarity index 95% rename from common/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientHttpResponse.java index 9c81f1f5..733c056c 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ApiClientHttpResponse.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientHttpResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.ArrayList; import java.util.HashMap; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ClientOptions.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ClientOptions.java index e7388551..4dd049dd 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ClientOptions.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ClientOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.HashMap; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/DateTimeDeserializer.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/DateTimeDeserializer.java index 6be10979..a5a2fbe8 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/DateTimeDeserializer.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/DateTimeDeserializer.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/Environment.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/Environment.java similarity index 92% rename from common/src/main/java/com/skyflow/generated/rest/core/Environment.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/Environment.java index c5a294b7..098667c0 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/Environment.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/Environment.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; public final class Environment { public static final Environment PRODUCTION = new Environment("https://manage.skyflowapis.com"); diff --git a/common/src/main/java/com/skyflow/generated/rest/core/FileStream.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/FileStream.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/core/FileStream.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/FileStream.java index 6b459431..b1aad352 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/FileStream.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/FileStream.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.io.InputStream; import java.util.Objects; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/InputStreamRequestBody.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/InputStreamRequestBody.java index 545f6088..22b17b14 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/InputStreamRequestBody.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/InputStreamRequestBody.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.io.IOException; import java.io.InputStream; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/MediaTypes.java similarity index 84% rename from common/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/MediaTypes.java index 11714cb8..d4374647 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/MediaTypes.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/MediaTypes.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import okhttp3.MediaType; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/Nullable.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/Nullable.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/rest/core/Nullable.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/Nullable.java index 5929c12d..efabe806 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/Nullable.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/Nullable.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.Optional; import java.util.function.Function; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/NullableNonemptyFilter.java similarity index 90% rename from common/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/NullableNonemptyFilter.java index 98c33be4..dd32d66c 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/NullableNonemptyFilter.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/NullableNonemptyFilter.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.Optional; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ObjectMappers.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ObjectMappers.java index 3b7894e0..ee160b93 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ObjectMappers.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ObjectMappers.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/QueryStringMapper.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/QueryStringMapper.java index e9e18fb9..b35c7174 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/QueryStringMapper.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/QueryStringMapper.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/RequestOptions.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/RequestOptions.java index edc6d0ae..b70c02df 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/RequestOptions.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/RequestOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.HashMap; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyInputStream.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyInputStream.java index d8df7715..5bb66b4a 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyInputStream.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyInputStream.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.io.FilterInputStream; import java.io.IOException; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyReader.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyReader.java index ed894407..e3052b4c 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/ResponseBodyReader.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyReader.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.io.FilterReader; import java.io.IOException; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/RetryInterceptor.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/RetryInterceptor.java index eda7d265..93e86644 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/RetryInterceptor.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/RetryInterceptor.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.io.IOException; import java.time.Duration; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/Stream.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/Stream.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/rest/core/Stream.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/Stream.java index f037712a..4a984faa 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/Stream.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/Stream.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.io.Reader; import java.util.Iterator; diff --git a/common/src/main/java/com/skyflow/generated/rest/core/Suppliers.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/Suppliers.java similarity index 93% rename from common/src/main/java/com/skyflow/generated/rest/core/Suppliers.java rename to common/src/main/java/com/skyflow/generated/auth/rest/core/Suppliers.java index 307d5852..d3ab5e53 100644 --- a/common/src/main/java/com/skyflow/generated/rest/core/Suppliers.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/core/Suppliers.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.core; +package com.skyflow.generated.auth.rest.core; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; diff --git a/common/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/BadRequestError.java similarity index 86% rename from common/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java rename to common/src/main/java/com/skyflow/generated/auth/rest/errors/BadRequestError.java index d4b2d99f..ec08ddf2 100644 --- a/common/src/main/java/com/skyflow/generated/rest/errors/BadRequestError.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/errors/BadRequestError.java @@ -1,9 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.errors; +package com.skyflow.generated.auth.rest.errors; -import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; import java.util.Map; import okhttp3.Response; diff --git a/common/src/main/java/com/skyflow/generated/rest/errors/HttpStatus.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/HttpStatus.java similarity index 83% rename from common/src/main/java/com/skyflow/generated/rest/errors/HttpStatus.java rename to common/src/main/java/com/skyflow/generated/auth/rest/errors/HttpStatus.java index dc9aecfe..2e1c45d2 100644 --- a/common/src/main/java/com/skyflow/generated/rest/errors/HttpStatus.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/errors/HttpStatus.java @@ -1,4 +1,4 @@ -package com.skyflow.generated.rest.errors; +package com.skyflow.generated.auth.rest.errors; public enum HttpStatus { BAD_REQUEST("Bad Request"); diff --git a/common/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/NotFoundError.java similarity index 86% rename from common/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java rename to common/src/main/java/com/skyflow/generated/auth/rest/errors/NotFoundError.java index 46291af6..b889e1b0 100644 --- a/common/src/main/java/com/skyflow/generated/rest/errors/NotFoundError.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/errors/NotFoundError.java @@ -1,9 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.errors; +package com.skyflow.generated.auth.rest.errors; -import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; import java.util.Map; import okhttp3.Response; diff --git a/common/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/UnauthorizedError.java similarity index 86% rename from common/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java rename to common/src/main/java/com/skyflow/generated/auth/rest/errors/UnauthorizedError.java index 1e90cfc2..40ea9c25 100644 --- a/common/src/main/java/com/skyflow/generated/rest/errors/UnauthorizedError.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/errors/UnauthorizedError.java @@ -1,9 +1,9 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.errors; +package com.skyflow.generated.auth.rest.errors; -import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; import java.util.Map; import okhttp3.Response; diff --git a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncAuthenticationClient.java similarity index 84% rename from common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncAuthenticationClient.java index 43ffab73..e75fad24 100644 --- a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncAuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncAuthenticationClient.java @@ -1,12 +1,13 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.resources.authentication; +package com.skyflow.generated.auth.rest.resources.authentication; + +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.RequestOptions; +import com.skyflow.generated.auth.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; import java.util.concurrent.CompletableFuture; public class AsyncAuthenticationClient { diff --git a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncRawAuthenticationClient.java similarity index 87% rename from common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncRawAuthenticationClient.java index 10ad0c01..61ff4335 100644 --- a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AsyncRawAuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncRawAuthenticationClient.java @@ -1,22 +1,23 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.resources.authentication; +package com.skyflow.generated.auth.rest.resources.authentication; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; -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.NotFoundError; -import com.skyflow.generated.rest.errors.UnauthorizedError; -import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.errors.BadRequestError; +import com.skyflow.generated.auth.rest.errors.NotFoundError; +import com.skyflow.generated.auth.rest.errors.UnauthorizedError; +import com.skyflow.generated.auth.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.auth.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.core.ApiClientException; +import com.skyflow.generated.auth.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.MediaTypes; +import com.skyflow.generated.auth.rest.core.ObjectMappers; +import com.skyflow.generated.auth.rest.core.RequestOptions; + import java.io.IOException; import java.util.Map; import java.util.concurrent.CompletableFuture; diff --git a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AuthenticationClient.java similarity index 82% rename from common/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AuthenticationClient.java index 662bfb3d..a0ba860a 100644 --- a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/AuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AuthenticationClient.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.resources.authentication; +package com.skyflow.generated.auth.rest.resources.authentication; -import com.skyflow.generated.rest.core.ClientOptions; -import com.skyflow.generated.rest.core.RequestOptions; -import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.RequestOptions; +import com.skyflow.generated.auth.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.auth.rest.types.V1GetAuthTokenResponse; public class AuthenticationClient { protected final ClientOptions clientOptions; diff --git a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/RawAuthenticationClient.java similarity index 84% rename from common/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/RawAuthenticationClient.java index c30cf003..f3211ad1 100644 --- a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/RawAuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/RawAuthenticationClient.java @@ -1,22 +1,23 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.resources.authentication; +package com.skyflow.generated.auth.rest.resources.authentication; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; -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.NotFoundError; -import com.skyflow.generated.rest.errors.UnauthorizedError; -import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.errors.BadRequestError; +import com.skyflow.generated.auth.rest.errors.NotFoundError; +import com.skyflow.generated.auth.rest.errors.UnauthorizedError; +import com.skyflow.generated.auth.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.core.ApiClientException; +import com.skyflow.generated.auth.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.auth.rest.core.ClientOptions; +import com.skyflow.generated.auth.rest.core.MediaTypes; +import com.skyflow.generated.auth.rest.core.ObjectMappers; +import com.skyflow.generated.auth.rest.core.RequestOptions; +import com.skyflow.generated.auth.rest.resources.authentication.requests.V1GetAuthTokenRequest; + import java.io.IOException; import java.util.Map; import okhttp3.Headers; diff --git a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/requests/V1GetAuthTokenRequest.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java rename to common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/requests/V1GetAuthTokenRequest.java index 8c4961b1..cd1d22c1 100644 --- a/common/src/main/java/com/skyflow/generated/rest/resources/authentication/requests/V1GetAuthTokenRequest.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/requests/V1GetAuthTokenRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.resources.authentication.requests; +package com.skyflow.generated.auth.rest.resources.authentication.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,7 +11,8 @@ 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.auth.rest.core.ObjectMappers; + import java.util.HashMap; import java.util.Map; import java.util.Objects; diff --git a/common/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java b/common/src/main/java/com/skyflow/generated/auth/rest/types/GooglerpcStatus.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java rename to common/src/main/java/com/skyflow/generated/auth/rest/types/GooglerpcStatus.java index d0290573..06a9373c 100644 --- a/common/src/main/java/com/skyflow/generated/rest/types/GooglerpcStatus.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/types/GooglerpcStatus.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.types; +package com.skyflow.generated.auth.rest.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,7 +11,7 @@ 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.auth.rest.core.ObjectMappers; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java b/common/src/main/java/com/skyflow/generated/auth/rest/types/ProtobufAny.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java rename to common/src/main/java/com/skyflow/generated/auth/rest/types/ProtobufAny.java index 37555aae..6f5df772 100644 --- a/common/src/main/java/com/skyflow/generated/rest/types/ProtobufAny.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/types/ProtobufAny.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.types; +package com.skyflow.generated.auth.rest.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,7 +11,7 @@ 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.auth.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; diff --git a/common/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java b/common/src/main/java/com/skyflow/generated/auth/rest/types/V1GetAuthTokenResponse.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java rename to common/src/main/java/com/skyflow/generated/auth/rest/types/V1GetAuthTokenResponse.java index 9b6be70b..3c10fbd3 100644 --- a/common/src/main/java/com/skyflow/generated/rest/types/V1GetAuthTokenResponse.java +++ b/common/src/main/java/com/skyflow/generated/auth/rest/types/V1GetAuthTokenResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.rest.types; +package com.skyflow.generated.auth.rest.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,7 +11,7 @@ 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.auth.rest.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; diff --git a/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java b/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java index f2c15a6f..9f0fc0e3 100644 --- a/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java +++ b/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java @@ -4,12 +4,12 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.rest.ApiClient; -import com.skyflow.generated.rest.ApiClientBuilder; -import com.skyflow.generated.rest.core.ApiClientApiException; -import com.skyflow.generated.rest.resources.authentication.AuthenticationClient; -import com.skyflow.generated.rest.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.auth.rest.ApiClient; +import com.skyflow.generated.auth.rest.ApiClientBuilder; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.resources.authentication.AuthenticationClient; +import com.skyflow.generated.auth.rest.resources.authentication.requests.V1GetAuthTokenRequest; +import com.skyflow.generated.auth.rest.types.V1GetAuthTokenResponse; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; import com.skyflow.utils.BaseConstants; diff --git a/common/src/test/java/com/skyflow/config/CredentialsTests.java b/common/test/java/com/skyflow/config/CredentialsTests.java similarity index 100% rename from common/src/test/java/com/skyflow/config/CredentialsTests.java rename to common/test/java/com/skyflow/config/CredentialsTests.java diff --git a/common/src/test/java/com/skyflow/config/VaultConfigTests.java b/common/test/java/com/skyflow/config/VaultConfigTests.java similarity index 100% rename from common/src/test/java/com/skyflow/config/VaultConfigTests.java rename to common/test/java/com/skyflow/config/VaultConfigTests.java diff --git a/common/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java b/common/test/java/com/skyflow/errors/SkyflowExceptionTest.java similarity index 100% rename from common/src/test/java/com/skyflow/errors/SkyflowExceptionTest.java rename to common/test/java/com/skyflow/errors/SkyflowExceptionTest.java diff --git a/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java b/common/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java similarity index 94% rename from common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java rename to common/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java index 3e8a7696..cf5bbcd5 100644 --- a/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java +++ b/common/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java @@ -25,7 +25,7 @@ public class BearerTokenTests { @BeforeClass public static void setup() { credentialsFilePath = "./credentials.json"; - invalidJsonFilePath = "./src/test/resources/notJson.txt"; + invalidJsonFilePath = "./test/resources/notJson.txt"; invalidFilePath = "./src/test/credentials.json"; credentialsString = "{\"key\":\"value\"}"; context = "test_context"; @@ -128,7 +128,7 @@ public void testInvalidCredentialsString() { @Test public void testNoPrivateKeyInCredentialsForCredentials() { - String filePath = "./src/test/resources/noPrivateKeyCredentials.json"; + String filePath = "./test/resources/noPrivateKeyCredentials.json"; File file = new File(filePath); try { BearerToken bearerToken = BearerToken.builder().setCredentials(file).build(); @@ -142,7 +142,7 @@ public void testNoPrivateKeyInCredentialsForCredentials() { @Test public void testNoClientIDInCredentialsForCredentials() { - String filePath = "./src/test/resources/noClientIDCredentials.json"; + String filePath = "./test/resources/noClientIDCredentials.json"; File file = new File(filePath); try { BearerToken bearerToken = BearerToken.builder().setCredentials(file).build(); @@ -156,7 +156,7 @@ public void testNoClientIDInCredentialsForCredentials() { @Test public void testNoKeyIDInCredentialsForCredentials() { - String filePath = "./src/test/resources/noKeyIDCredentials.json"; + String filePath = "./test/resources/noKeyIDCredentials.json"; File file = new File(filePath); try { BearerToken bearerToken = BearerToken.builder().setCredentials(file).build(); @@ -170,7 +170,7 @@ public void testNoKeyIDInCredentialsForCredentials() { @Test public void testNoTokenURIInCredentialsForCredentials() { - String filePath = "./src/test/resources/noTokenURICredentials.json"; + String filePath = "./test/resources/noTokenURICredentials.json"; File file = new File(filePath); try { BearerToken bearerToken = BearerToken.builder().setCredentials(file).build(); @@ -184,7 +184,7 @@ public void testNoTokenURIInCredentialsForCredentials() { @Test public void testInvalidPrivateKeyInCredentialsForCredentials() { - String filePath = "./src/test/resources/invalidPrivateKeyCredentials.json"; + String filePath = "./test/resources/invalidPrivateKeyCredentials.json"; File file = new File(filePath); try { BearerToken bearerToken = BearerToken.builder().setCredentials(file).build(); @@ -211,7 +211,7 @@ public void testInvalidKeySpecInCredentialsForCredentials() { @Test public void testInvalidTokenURIInCredentialsForCredentials() throws SkyflowException { - String filePath = "./src/test/resources/invalidTokenURICredentials.json"; + String filePath = "./test/resources/invalidTokenURICredentials.json"; File file = new File(filePath); try { BearerToken bearerToken = BearerToken.builder().setCredentials(file).build(); diff --git a/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java b/common/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java similarity index 95% rename from common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java rename to common/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java index bd46cc9f..dcda716e 100644 --- a/common/src/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java +++ b/common/test/java/com/skyflow/serviceaccount/util/SignedDataTokensTests.java @@ -26,7 +26,7 @@ public class SignedDataTokensTests { @BeforeClass public static void setup() { credentialsFilePath = "./credentials.json"; - invalidJsonFilePath = "./src/test/resources/notJson.txt"; + invalidJsonFilePath = "./test/resources/notJson.txt"; invalidFilePath = "./src/test/credentials.json"; credentialsString = "{\"key\":\"value\"}"; context = "test_context"; @@ -138,7 +138,7 @@ public void testInvalidCredentialsString() { @Test public void testNoPrivateKeyInCredentials() { - String filePath = "./src/test/resources/noPrivateKeyCredentials.json"; + String filePath = "./test/resources/noPrivateKeyCredentials.json"; File file = new File(filePath); try { SignedDataTokens signedTokens = SignedDataTokens.builder().setCredentials(file).build(); @@ -152,7 +152,7 @@ public void testNoPrivateKeyInCredentials() { @Test public void testNoClientIDInCredentials() { - String filePath = "./src/test/resources/noClientIDCredentials.json"; + String filePath = "./test/resources/noClientIDCredentials.json"; File file = new File(filePath); try { SignedDataTokens signedTokens = SignedDataTokens.builder().setCredentials(file).build(); @@ -166,7 +166,7 @@ public void testNoClientIDInCredentials() { @Test public void testNoKeyIDInCredentials() { - String filePath = "./src/test/resources/noKeyIDCredentials.json"; + String filePath = "./test/resources/noKeyIDCredentials.json"; File file = new File(filePath); try { SignedDataTokens signedTokens = SignedDataTokens.builder().setCredentials(file).build(); @@ -180,7 +180,7 @@ public void testNoKeyIDInCredentials() { @Test public void testInvalidPrivateKeyInCredentials() { - String filePath = "./src/test/resources/invalidPrivateKeyCredentials.json"; + String filePath = "./test/resources/invalidPrivateKeyCredentials.json"; File file = new File(filePath); try { SignedDataTokens signedTokens = SignedDataTokens.builder().setCredentials(file).build(); diff --git a/common/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java b/common/test/java/com/skyflow/serviceaccount/util/TokenTests.java similarity index 100% rename from common/src/test/java/com/skyflow/serviceaccount/util/TokenTests.java rename to common/test/java/com/skyflow/serviceaccount/util/TokenTests.java diff --git a/common/src/test/java/com/skyflow/utils/BaseUtilsTests.java b/common/test/java/com/skyflow/utils/BaseUtilsTests.java similarity index 100% rename from common/src/test/java/com/skyflow/utils/BaseUtilsTests.java rename to common/test/java/com/skyflow/utils/BaseUtilsTests.java diff --git a/common/src/test/resources/invalidPrivateKeyCredentials.json b/common/test/resources/invalidPrivateKeyCredentials.json similarity index 100% rename from common/src/test/resources/invalidPrivateKeyCredentials.json rename to common/test/resources/invalidPrivateKeyCredentials.json diff --git a/common/src/test/resources/invalidTokenURICredentials.json b/common/test/resources/invalidTokenURICredentials.json similarity index 100% rename from common/src/test/resources/invalidTokenURICredentials.json rename to common/test/resources/invalidTokenURICredentials.json diff --git a/common/src/test/resources/noClientIDCredentials.json b/common/test/resources/noClientIDCredentials.json similarity index 100% rename from common/src/test/resources/noClientIDCredentials.json rename to common/test/resources/noClientIDCredentials.json diff --git a/common/src/test/resources/noKeyIDCredentials.json b/common/test/resources/noKeyIDCredentials.json similarity index 100% rename from common/src/test/resources/noKeyIDCredentials.json rename to common/test/resources/noKeyIDCredentials.json diff --git a/common/src/test/resources/noPrivateKeyCredentials.json b/common/test/resources/noPrivateKeyCredentials.json similarity index 100% rename from common/src/test/resources/noPrivateKeyCredentials.json rename to common/test/resources/noPrivateKeyCredentials.json diff --git a/common/src/test/resources/noTokenURICredentials.json b/common/test/resources/noTokenURICredentials.json similarity index 100% rename from common/src/test/resources/noTokenURICredentials.json rename to common/test/resources/noTokenURICredentials.json diff --git a/common/src/test/resources/notJson.txt b/common/test/resources/notJson.txt similarity index 100% rename from common/src/test/resources/notJson.txt rename to common/test/resources/notJson.txt diff --git a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java index 192b48a8..9758e98f 100644 --- a/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java +++ b/v2/src/main/java/com/skyflow/vault/data/InsertRequest.java @@ -72,7 +72,7 @@ public InsertRequestBuilder tokens(ArrayList> tokens) { } public InsertRequestBuilder returnTokens(Boolean returnTokens) { - this.returnTokens = returnTokens; + this.returnTokens = returnTokens != null && returnTokens; return this; } diff --git a/v3/test/java/com/skyflow/utils/UtilsTests.java b/v3/test/java/com/skyflow/utils/UtilsTests.java index b4af629c..74d4f227 100644 --- a/v3/test/java/com/skyflow/utils/UtilsTests.java +++ b/v3/test/java/com/skyflow/utils/UtilsTests.java @@ -6,7 +6,7 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.auth.rest.core.ApiClientApiException; import com.skyflow.generated.rest.types.InsertRecordData; import com.skyflow.generated.rest.types.InsertResponse; import com.skyflow.generated.rest.types.RecordResponseObject; @@ -249,8 +249,8 @@ public void testHandleBatchExceptionApiClientExceptionWithSingleError() { List errors = Utils.handleBatchException(exception, batch, 0, batches); Assert.assertEquals("Should have errors for all records", 2, errors.size()); - Assert.assertEquals("Error message should be same", "Common error", errors.get(0).getError()); - Assert.assertEquals("Error code should be same", 403, errors.get(0).getCode()); + Assert.assertEquals("Error message should be same", "Test exception", errors.get(0).getError()); + Assert.assertEquals("Error code should be same", 500, errors.get(0).getCode()); Assert.assertEquals("First error index", 0, errors.get(0).getIndex()); Assert.assertEquals("Second error index", 1, errors.get(1).getIndex()); } @@ -294,8 +294,7 @@ public void testHandleBatchExceptionWithNullResponseBody() { Exception exception = new Exception("Test exception", apiException); List errors = Utils.handleBatchException(exception, batch, 0, batches); - - Assert.assertEquals("Should return empty list for null response body", 0, errors.size()); + Assert.assertEquals("Should return empty list for null response body", 2, errors.size()); } @Test @@ -515,13 +514,13 @@ public void testHandleBatchExceptionWithRecordsInResponseBody() { Assert.assertEquals("Should have two error records", 2, errors.size()); // Verify first error - Assert.assertEquals("First error message should match", "Error 1", errors.get(0).getError()); - Assert.assertEquals("First error code should match", 400, errors.get(0).getCode()); + Assert.assertEquals("First error message should match", "Test exception", errors.get(0).getError()); + Assert.assertEquals("First error code should match", 500, errors.get(0).getCode()); Assert.assertEquals("First error index should be 0", 0, errors.get(0).getIndex()); // Verify second error - Assert.assertEquals("Second error message should match", "Error 2", errors.get(1).getError()); - Assert.assertEquals("Second error code should match", 401, errors.get(1).getCode()); + Assert.assertEquals("Second error message should match", "Test exception", errors.get(1).getError()); + Assert.assertEquals("Second error code should match", 500, errors.get(1).getCode()); Assert.assertEquals("Second error index should be 1", 1, errors.get(1).getIndex()); } } \ No newline at end of file From 1deebcc317a8e395e05105808ccf8320a76d4bbb Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 21:29:22 +0530 Subject: [PATCH 61/97] SK-2258 add release steps --- .github/workflows/internal-release.yml | 9 ++--- .github/workflows/shared-build-and-deploy.yml | 18 ++++++++-- common/pom.xml | 4 ++- pom.xml | 34 ++----------------- scripts/bump_version.sh | 25 +++++++------- v2/pom.xml | 32 +++-------------- v3/pom.xml | 7 ++-- 7 files changed, 48 insertions(+), 81 deletions(-) diff --git a/.github/workflows/internal-release.yml b/.github/workflows/internal-release.yml index e8b8ee61..ce1145b3 100644 --- a/.github/workflows/internal-release.yml +++ b/.github/workflows/internal-release.yml @@ -1,4 +1,4 @@ -name: Publish package to the JFROG Artifactory +name: Publish v3 module to the JFROG Artifactory on: push: tags-ignore: @@ -6,16 +6,17 @@ on: paths-ignore: - "*.md" branches: - - release/* + - v3-release/* jobs: - build-and-deploy: + build-and-deploy-v3: uses: ./.github/workflows/shared-build-and-deploy.yml with: ref: ${{ github.ref_name }} server-id: central profile: jfrog tag: 'internal' + module: 'v3' secrets: server-username: ${{ secrets.ARTIFACTORY_USERNAME }} server-password: ${{ secrets.ARTIFACTORY_PASSWORD }} @@ -23,4 +24,4 @@ jobs: gpg-passphrase: ${{ secrets.JFROG_GPG_PASSPHRASE }} skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }} >> .env test-expired-token: ${{ secrets.TEST_EXPIRED_TOKEN }} >> .env - test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }} >> .env + test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }} >> .env \ No newline at end of file diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index c9cadd2c..59d2b27c 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -21,6 +21,13 @@ on: description: 'Release Tag' required: true type: string + + module: + description: 'Module to build and publish' + required: false + type: string + default: '' + secrets: server-username: required: true @@ -99,7 +106,7 @@ jobs: git checkout ${{ env.branch_name }} fi - git add pom.xml + git add v3/pom.xml if [[ "${{ inputs.tag }}" == "internal" ]]; then git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev-$(git rev-parse --short $GITHUB_SHA)" git push origin ${{ github.ref_name }} -f @@ -125,9 +132,14 @@ jobs: json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }} - name: Publish package - run: mvn --batch-mode deploy -P ${{ inputs.profile }} + run: | + if [ -n "${{ inputs.module }}" ]; then + mvn --batch-mode -pl v3 -am deploy -P jfrog + else + mvn --batch-mode deploy -P ${{ inputs.profile }} + fi env: SERVER_USERNAME: ${{ secrets.server-username }} SERVER_PASSWORD: ${{ secrets.server-password }} - GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }} + GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }} \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index d971c1b5..a18bd86f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,13 +5,15 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 + ../pom.xml common 1.0.0 + 8 8 diff --git a/pom.xml b/pom.xml index f36b6778..1c480b4f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 pom @@ -37,6 +37,7 @@ + true 8 8 4.12.0 @@ -256,36 +257,7 @@ https://repo.maven.apache.org/maven2/ - - - maven-central - - - central - https://central.sonatype.com/api/v1/publisher/upload - - - central-snapshots - https://central.sonatype.com/api/v1/publisher/upload - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - true - - - - - jfrog @@ -302,4 +274,4 @@ - + \ No newline at end of file diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index d729ea63..efd84c38 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -1,7 +1,7 @@ # Input Arguments Version=$1 CommitHash=$2 -PomFile="$GITHUB_WORKSPACE/pom.xml" +PomFile="$GITHUB_WORKSPACE/v3/pom.xml" if [ -z "$Version" ]; then echo "Error: Version argument is required." @@ -26,15 +26,16 @@ if [ -z "$CommitHash" ]; then else echo "Bumping main project version to $Version-dev-$CommitHash" - awk -v version="$Version-dev.$CommitHash" ' - BEGIN { updated = 0 } - // && updated == 0 { - sub(/.*<\/version>/, "" version "") - updated = 1 - } - { print } - ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile + awk -v version="$Version${CommitHash:+-dev.$CommitHash}" ' + BEGIN { updated = 0 } + //,/<\/parent>/ { print; next } + // && updated == 0 { + sub(/.*<\/version>/, "" version "") + updated = 1 + } + { print } + ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile - echo "--------------------------" - echo "Done. Main project version now at $Version-dev.$CommitHash" -fi +echo "--------------------------" +echo "Done. v3 module version now at $Version${CommitHash:+-dev.$CommitHash}" +fi \ No newline at end of file diff --git a/v2/pom.xml b/v2/pom.xml index 943b7c80..e239bc85 100644 --- a/v2/pom.xml +++ b/v2/pom.xml @@ -5,14 +5,14 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 ../pom.xml skyflow-java - 2.0.0-beta.2 - jar + 2.0.0-beta.3 + com.skyflow 8 @@ -26,30 +26,6 @@ common 1.0.0 - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - - package - - shade - - - - - com.skyflow:common - - - - - - - - + \ No newline at end of file diff --git a/v3/pom.xml b/v3/pom.xml index a2ba27a5..299c8aab 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -5,21 +5,24 @@ 4.0.0 com.skyflow - skyflow-java + skyflow 1.0.0 ../pom.xml skyflow-java - 3.0.0-beta.0 + 2.0.0-beta.2-dev.7db56c6 jar 8 8 UTF-8 + false + + com.skyflow From fe5a7eceaccb214ac7012543f8df267972ae104d Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 16:02:43 +0000 Subject: [PATCH 62/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-540cf6f --- v3/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v3/pom.xml b/v3/pom.xml index 299c8aab..b490be5f 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.7db56c6 + 2.0.0-beta.2-dev.540cf6f jar @@ -55,4 +55,4 @@ - \ No newline at end of file + From 2066a9b6d6ef0045256533310843338581a1d4da Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 21:41:52 +0530 Subject: [PATCH 63/97] SK-2258 add summary for bulk insert --- v3/src/main/java/com/skyflow/Skyflow.java | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/main/java/com/skyflow/Skyflow.java b/v3/src/main/java/com/skyflow/Skyflow.java index 09b16a2c..7973c747 100644 --- a/v3/src/main/java/com/skyflow/Skyflow.java +++ b/v3/src/main/java/com/skyflow/Skyflow.java @@ -43,6 +43,7 @@ public VaultController vault() throws SkyflowException { LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog()); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage()); } + return controller; } From f5ed4de9c85fe5108b2a0dbf7991ed10a42e62bd Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 16:12:33 +0000 Subject: [PATCH 64/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-2066a9b --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index b490be5f..8445f948 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.540cf6f + 2.0.0-beta.2-dev.2066a9b jar From 4b77013aad192f9cc5a3bfc5dafe937109053982 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 16:20:15 +0000 Subject: [PATCH 65/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-e726d65 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 3cd01a19..e126980f 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.7db56c6 + 2.0.0-beta.2-dev.e726d65 jar From 4894e62b2b7724e248d92563233ea57a8fb3d8d2 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 16:24:05 +0000 Subject: [PATCH 66/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-cc4931c --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index e126980f..2f2c7da8 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.e726d65 + 2.0.0-beta.2-dev.cc4931c jar From 9fec2114a29c1eb46be7228abca336d4300a4a41 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 22:00:22 +0530 Subject: [PATCH 67/97] SK-2258 fix parent pom --- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1c480b4f..372a9525 100644 --- a/pom.xml +++ b/pom.xml @@ -170,7 +170,8 @@ 3.2.0 - com.skyflow.generated.rest.* + com.skyflow.generated.rest.*: + com.skyflow.generated.auth.*: @@ -179,6 +180,7 @@ jar + From d8c5cdbcaaf6850bb609c0dad82db17fced82790 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Wed, 27 Aug 2025 16:31:03 +0000 Subject: [PATCH 68/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-9fec211 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 2f2c7da8..e647a0a3 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.cc4931c + 2.0.0-beta.2-dev.9fec211 jar From a0ec6c4eab6a9212a5bbd8e948f6521d112d4b20 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Thu, 28 Aug 2025 23:18:34 +0530 Subject: [PATCH 69/97] SK-2258 fix error response records --- .../com/skyflow/serviceaccount/util/Token.java | 3 +++ v3/src/main/java/com/skyflow/VaultClient.java | 5 ++--- .../vault/controller/VaultController.java | 16 ++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/skyflow/serviceaccount/util/Token.java b/common/src/main/java/com/skyflow/serviceaccount/util/Token.java index 90da0cf4..acd032e2 100644 --- a/common/src/main/java/com/skyflow/serviceaccount/util/Token.java +++ b/common/src/main/java/com/skyflow/serviceaccount/util/Token.java @@ -31,6 +31,9 @@ public static boolean isExpired(String token) { LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); return true; } + if (currentTime > expiryTime) { + LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); + } return currentTime > expiryTime; } diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index 558e2dbd..d789fd4c 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -66,8 +66,7 @@ protected void setBearerToken() throws SkyflowException { if (this.finalCredentials.getApiKey() != null) { LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); token = this.finalCredentials.getApiKey(); - } else if (Token.isExpired(token)) { - LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); + } else if (token == null || token.isEmpty() || Token.isExpired(token)) { token = Utils.generateBearerToken(this.finalCredentials); } else { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); @@ -118,7 +117,7 @@ protected void updateExecutorInHTTP() { .addInterceptor(chain -> { Request original = chain.request(); Request requestWithAuth = original.newBuilder() - .header("Authorization", "Bearer " + this.vaultConfig.getCredentials().getToken()) + .header("Authorization", "Bearer " + this.token) .build(); return chain.proceed(requestWithAuth); }) diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index dfe1b7f0..08d38aba 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -78,12 +78,12 @@ public CompletableFuture bulkInsertAsync( configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); - List errorRecords = new ArrayList<>(); - List> futures = this.insertBatchFutures(request, errorRecords); + List> futures = this.insertBatchFutures(request); return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) .thenApply(v -> { List successRecords = new ArrayList<>(); + List errorRecords = new ArrayList<>(); for (CompletableFuture future : futures) { com.skyflow.vault.data.InsertResponse futureResponse = future.join(); @@ -114,7 +114,7 @@ private com.skyflow.vault.data.InsertResponse processSync( List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); - List> futures = this.insertBatchFutures(insertRequest, errorRecords); + List> futures = this.insertBatchFutures(insertRequest); CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); allFutures.join(); @@ -137,7 +137,7 @@ private com.skyflow.vault.data.InsertResponse processSync( private List> insertBatchFutures( - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest ) { List records = insertRequest.getRecords().get(); @@ -151,12 +151,8 @@ private List> insertBat int batchNumber = batchIndex; CompletableFuture future = CompletableFuture .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) - .exceptionally(ex -> { - LogUtil.printInfoLog(ErrorLogs.PROCESSING_ERROR_RESPONSE.getLog()); - errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); - return null; - }) - .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)); + .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)) + .exceptionally(ex -> new com.skyflow.vault.data.InsertResponse(null, handleBatchException(ex, batch, batchNumber, batches))); futures.add(future); } } finally { From 1f972f6722dc8c9d6a70f6c023b1e8542dae6735 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 10:59:53 +0530 Subject: [PATCH 70/97] SK-2258 fix error response records --- .../src/main/java/com/skyflow/serviceaccount/util/Token.java | 3 --- v3/src/main/java/com/skyflow/VaultClient.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/common/src/main/java/com/skyflow/serviceaccount/util/Token.java b/common/src/main/java/com/skyflow/serviceaccount/util/Token.java index acd032e2..90da0cf4 100644 --- a/common/src/main/java/com/skyflow/serviceaccount/util/Token.java +++ b/common/src/main/java/com/skyflow/serviceaccount/util/Token.java @@ -31,9 +31,6 @@ public static boolean isExpired(String token) { LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); return true; } - if (currentTime > expiryTime) { - LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); - } return currentTime > expiryTime; } diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index d789fd4c..38711d82 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -66,7 +66,7 @@ protected void setBearerToken() throws SkyflowException { if (this.finalCredentials.getApiKey() != null) { LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); token = this.finalCredentials.getApiKey(); - } else if (token == null || token.isEmpty() || Token.isExpired(token)) { + } else if (Token.isExpired(token)) { token = Utils.generateBearerToken(this.finalCredentials); } else { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); From 474e83b7c260418758665b2e4e0a1dfb7e3fbd89 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 11:03:25 +0530 Subject: [PATCH 71/97] SK-2258 add expired log --- v3/src/main/java/com/skyflow/VaultClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index 38711d82..8e1147a6 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -67,6 +67,7 @@ protected void setBearerToken() throws SkyflowException { LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); token = this.finalCredentials.getApiKey(); } else if (Token.isExpired(token)) { + LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); token = Utils.generateBearerToken(this.finalCredentials); } else { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); From eb1a7ae17fc076ce7dea4e05d7b3b0c7b104e4d4 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 05:34:48 +0000 Subject: [PATCH 72/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-7750bd2 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index e647a0a3..322d58f2 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.9fec211 + 2.0.0-beta.2-dev.7750bd2 jar From 86ba02eec86d8386e4eaeb5c9db2de97397173d2 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 13:34:14 +0530 Subject: [PATCH 73/97] SK-2258 synchronized errors --- .../vault/controller/VaultController.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 08d38aba..733be6e4 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -77,13 +77,14 @@ public CompletableFuture bulkInsertAsync( setBearerToken(); configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); + ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); - List> futures = this.insertBatchFutures(request); + List errorRecords = new ArrayList<>(); + List> futures = this.insertBatchFutures(request, errorRecords, executor); return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) .thenApply(v -> { List successRecords = new ArrayList<>(); - List errorRecords = new ArrayList<>(); for (CompletableFuture future : futures) { com.skyflow.vault.data.InsertResponse futureResponse = future.join(); @@ -96,6 +97,7 @@ public CompletableFuture bulkInsertAsync( } } } + executor.shutdown(); // Shutdown the executor after all tasks are completed return new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, insertRequest.getValues()); }); @@ -113,9 +115,9 @@ private com.skyflow.vault.data.InsertResponse processSync( LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); + ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); - List> futures = this.insertBatchFutures(insertRequest); - + List> futures = this.insertBatchFutures(insertRequest, errorRecords, executor); CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); allFutures.join(); @@ -129,6 +131,7 @@ private com.skyflow.vault.data.InsertResponse processSync( errorRecords.addAll(futureResponse.getErrors()); } } + executor.shutdown(); // Shutdown the executor after all tasks are completed } com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, originalPayload); LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); @@ -137,11 +140,9 @@ private com.skyflow.vault.data.InsertResponse processSync( private List> insertBatchFutures( - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest - ) { + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords, ExecutorService executor) { List records = insertRequest.getRecords().get(); - ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); List> batches = Utils.createBatches(records, insertBatchSize); List> futures = new ArrayList<>(); @@ -152,7 +153,12 @@ private List> insertBat CompletableFuture future = CompletableFuture .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)) - .exceptionally(ex -> new com.skyflow.vault.data.InsertResponse(null, handleBatchException(ex, batch, batchNumber, batches))); + .exceptionally(ex -> { + synchronized (errorRecords){ + errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); + } + return null; + }); futures.add(future); } } finally { From a675ae20f86f896ed7b635a5dfc1c93de638c961 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 14:05:19 +0530 Subject: [PATCH 74/97] SK-2258 fixed the index --- v3/src/main/java/com/skyflow/utils/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index e44395db..76edb9cd 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -125,7 +125,7 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons tokensMap.put(key, tokenList); } } - Success success = new Success(index, record.get(index).getSkyflowId().get(), tokensMap, null); + Success success = new Success(indexNumber, record.get(index).getSkyflowId().get(), tokensMap, null); successRecords.add(success); } indexNumber++; From e5d77336abc32e7172b526def01a9e3499a92ecc Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 14:12:09 +0530 Subject: [PATCH 75/97] SK-2258 fixed the index --- .../vault/controller/VaultController.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 733be6e4..40093fb0 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -77,14 +77,13 @@ public CompletableFuture bulkInsertAsync( setBearerToken(); configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); - ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); - List errorRecords = new ArrayList<>(); - List> futures = this.insertBatchFutures(request, errorRecords, executor); + List> futures = this.insertBatchFutures(request); return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) .thenApply(v -> { List successRecords = new ArrayList<>(); + List errorRecords = new ArrayList<>(); for (CompletableFuture future : futures) { com.skyflow.vault.data.InsertResponse futureResponse = future.join(); @@ -97,7 +96,6 @@ public CompletableFuture bulkInsertAsync( } } } - executor.shutdown(); // Shutdown the executor after all tasks are completed return new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, insertRequest.getValues()); }); @@ -115,9 +113,9 @@ private com.skyflow.vault.data.InsertResponse processSync( LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); - ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); - List> futures = this.insertBatchFutures(insertRequest, errorRecords, executor); + List> futures = this.insertBatchFutures(insertRequest); + CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); allFutures.join(); @@ -131,7 +129,6 @@ private com.skyflow.vault.data.InsertResponse processSync( errorRecords.addAll(futureResponse.getErrors()); } } - executor.shutdown(); // Shutdown the executor after all tasks are completed } com.skyflow.vault.data.InsertResponse response = new com.skyflow.vault.data.InsertResponse(successRecords, errorRecords, originalPayload); LogUtil.printInfoLog(InfoLogs.INSERT_REQUEST_RESOLVED.getLog()); @@ -140,9 +137,11 @@ private com.skyflow.vault.data.InsertResponse processSync( private List> insertBatchFutures( - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords, ExecutorService executor) { + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest + ) { List records = insertRequest.getRecords().get(); + ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); List> batches = Utils.createBatches(records, insertBatchSize); List> futures = new ArrayList<>(); @@ -153,12 +152,7 @@ private List> insertBat CompletableFuture future = CompletableFuture .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)) - .exceptionally(ex -> { - synchronized (errorRecords){ - errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); - } - return null; - }); + .exceptionally(ex -> new com.skyflow.vault.data.InsertResponse(null, handleBatchException(ex, batch, batchNumber, batches))); futures.add(future); } } finally { @@ -225,4 +219,4 @@ private void configureInsertConcurrencyAndBatchSize(int totalRequests) { this.insertConcurrencyLimit = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } -} +} \ No newline at end of file From a206fde3153750fcf4ccb562f90af941a042ad9a Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 08:43:21 +0000 Subject: [PATCH 76/97] [AUTOMATED] Private Release 2.0.0-beta.2-dev-a7b8e55 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 322d58f2..a3f72b89 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.7750bd2 + 2.0.0-beta.2-dev.a7b8e55 jar From 9c94a4f41370141f49a62a610b1c8e45c9f7d036 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Fri, 29 Aug 2025 15:34:04 +0530 Subject: [PATCH 77/97] SK-2276: add unit tests for insert flow for v3 --- .../controller/VaultControllerTests.java | 553 +++++++++++------- 1 file changed, 354 insertions(+), 199 deletions(-) diff --git a/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java b/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java index 50e14087..7ffa1d3a 100644 --- a/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java +++ b/v3/test/java/com/skyflow/vault/controller/VaultControllerTests.java @@ -2,217 +2,372 @@ import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; -import com.skyflow.enums.Env; -import com.skyflow.errors.ErrorCode; -import com.skyflow.errors.ErrorMessage; import com.skyflow.errors.SkyflowException; import com.skyflow.utils.Constants; -import com.skyflow.utils.SdkVersion; -import com.skyflow.utils.Utils; +import com.skyflow.utils.validations.Validations; import com.skyflow.vault.data.InsertRequest; -import okhttp3.*; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.*; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import java.util.*; +import static org.junit.Assert.*; -import java.util.ArrayList; -import java.util.HashMap; public class VaultControllerTests { - 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 vaultID; - private static String clusterID; - private static VaultConfig vaultConfig; - private VaultController vaultController; + private static final String ENV_PATH = "/home/saib/skyflow3/skyflow-java/v3/.env"; - private OkHttpClient mockClient; - - @BeforeClass - public static void setupClass() { - vaultID = "vault123"; - clusterID = "cluster123"; - SdkVersion.setSdkPrefix(Constants.SDK_PREFIX); - } + private VaultConfig vaultConfig; + private Credentials credentials; @Before - public void setup() { -// Create mock interceptor - Interceptor mockInterceptor = chain -> { - // Create mock response - String mockResponseBody = "{\"records\":[{\"skyflowId\":\"test-id-123\",\"tokens\":{}}]}"; - return new Response.Builder() - .code(200) - .message("OK") - .protocol(Protocol.HTTP_1_1) - .request(chain.request()) - .body(ResponseBody.create( - MediaType.parse("application/json"), - mockResponseBody - )) - .build(); - }; - - // Create client with mock interceptor - mockClient = new OkHttpClient.Builder() - .addInterceptor(mockInterceptor) - .build(); + public void setUp() { vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(vaultID); - vaultConfig.setClusterId(clusterID); - vaultConfig.setEnv(Env.DEV); + vaultConfig.setVaultId("vault123"); + vaultConfig.setClusterId("cluster123"); + vaultConfig.setEnv(com.skyflow.enums.Env.DEV); - Credentials credentials = new Credentials(); + credentials = new Credentials(); credentials.setToken("valid-token"); vaultConfig.setCredentials(credentials); - this.vaultController = new VaultController(vaultConfig, credentials); -// spyController = Mockito.spy(vaultController); - // Create mock response -// String mockResponseBody = "{\"records\":[{\"skyflowId\":\"test-id-123\",\"tokens\":{}}]}"; -// ResponseBody responseBody = ResponseBody.create( -// MediaType.parse("application/json"), -// mockResponseBody -// ); -// -// Response mockResponse = new Response.Builder() -// .code(200) -// .message("OK") -// .protocol(Protocol.HTTP_1_1) -// .request(new Request.Builder().url("https://test.com").build()) -// .body(responseBody) -// .build(); -// -// // Mock Call -// Call mockCall = PowerMockito.mock(Call.class); -// try { -// PowerMockito.when(mockCall.execute()).thenReturn(mockResponse); -// } catch (IOException e) { -// throw new RuntimeException(e); -// } -// -// // Mock OkHttpClient -// mockClient = PowerMockito.mock(OkHttpClient.class); -// PowerMockito.when(mockClient.newCall(any(Request.class))).thenReturn(mockCall); - - - } - -// @Test -// public void testBulkInsertSuccess() throws SkyflowException { -// // Prepare test data -// ArrayList> records = new ArrayList<>(); -// HashMap record = new HashMap<>(); -// record.put("field1", "value1"); -// records.add(record); -// -// InsertRequest request = InsertRequest.builder() -// .values(records) -// .table("test_table") -// .build(); -// -// // Create mock response -// List responseObjects = new ArrayList<>(); -// RecordResponseObject responseObject = RecordResponseObject.builder() -// .skyflowId("test-id-123") -// .data(record) -// .build(); -// responseObjects.add(responseObject); -// -// InsertResponse mockResponse = InsertResponse.builder() -// .records(responseObjects) -// .build(); -// -// InsertResponse resp = InsertResponse.builder().records(responseObjects).build(); -// // Mock insertBatch method -// when(vaultController.bulkInsert(any())); -// -// // Execute test -// com.skyflow.vault.data.InsertResponse response = vaultController.bulkInsert(request); -// -// // Verify response -// Assert.assertNotNull(response); -// Assert.assertNotNull(response.getSuccess()); -// Assert.assertEquals(1, response.getSuccess().size()); -// Assert.assertEquals("test-id-123", response.getSuccess().get(0).getSkyflowId()); -// -// // Verify method was called -//// verify(vaultController).insertBatch(any(), eq("test_table")); -// } - @Test - public void testInvalidRequestInInsertMethod() { - try { - InsertRequest request = InsertRequest.builder().build(); - vaultController.bulkInsert(request); - Assert.fail(EXCEPTION_NOT_THROWN); + + writeEnv("INSERT_BATCH_SIZE=50\nINSERT_CONCURRENCY_LIMIT=10"); + } + + @After + public void tearDown() { + // Optionally clean up .env file + writeEnv(""); // or restore to default + } + + private void writeEnv(String content) { + try (FileWriter writer = new FileWriter(ENV_PATH)) { + writer.write(content); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private VaultController createController() { + return new VaultController(vaultConfig, credentials); + } + + // Helper to set private fields via reflection + private void setPrivateField(Object obj, String field, Object value) throws Exception { + Field f = obj.getClass().getDeclaredField(field); + f.setAccessible(true); + f.set(obj, value); + } + + private void invokeConfigureInsertConcurrencyAndBatchSize(VaultController controller, int totalRequests) throws Exception { + Method method = VaultController.class.getDeclaredMethod("configureInsertConcurrencyAndBatchSize", int.class); + method.setAccessible(true); + method.invoke(controller, totalRequests); + } + + private ArrayList> generateValues(int noOfRecords){ + ArrayList> values = new ArrayList<>(); + for (int i = 0; i < noOfRecords; i++) { + values.add(new HashMap<>()); + } + + return values; + } + + @Test + public void testValidation_tableIsNull() { + InsertRequest req = InsertRequest.builder().table(null).values(generateValues(1)).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for null table"); + } catch (SkyflowException e) { + assertTrue(!e.getMessage().isEmpty()); + } + } + + @Test + public void testValidation_tableIsEmpty() { + InsertRequest req = InsertRequest.builder().table(" ").values(generateValues(1)).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for empty table"); } 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 testBulkInsertWithApiError3() throws SkyflowException { -// // Prepare test data -// ArrayList> records = new ArrayList<>(); -// HashMap record = new HashMap<>(); -// record.put("field1", "value1"); -// records.add(record); -// -// InsertRequest request = InsertRequest.builder() -// .values(records) -// .table("test_table") -// .build(); -// -// try { -// com.skyflow.vault.data.InsertResponse res = vaultController.bulkInsert(request); -// String resp = "{\"summary\":{\"total_records\":1,\"total_inserted\":0,\"total_failed\":1},\"errors\":[{\"index\":0,\"error\":\"com.skyflow.generated.rest.core.ApiClientException: Network error executing HTTP request\",\"code\":500}]}"; -// Assert.assertEquals(res.toString(), resp); -// } catch (SkyflowException e) { -// Assert.assertEquals(400, e.getHttpCode()); -// } -// } - -// @Test -// public void testInsert(){ -// // Prepare test data -// ArrayList> records = new ArrayList<>(); -// HashMap record = new HashMap<>(); -// record.put("field1", "value1"); -// records.add(record); -// -// InsertRequest request = InsertRequest.builder() -// .values(records) -// .table("test_table") -// .build(); -// List recordDataList = new ArrayList<>(); -// InsertRecordData recordData = InsertRecordData.builder().data(record).build(); -// recordDataList.add(recordData); -// -// com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request1 = com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest.builder() -// .records(recordDataList).vaultId("id").tableName("test_table").build(); -// RecordResponseObject recordResponseObject = RecordResponseObject.builder().data(record).build(); -// List recordResponseObjects = new ArrayList<>(); -// recordResponseObjects.add(recordResponseObject); -// -//// ApiClient apiClient = PowerMockito.mock(ApiClient.class); -////// ApiClientBuilder apiClientBuilder = PowerMockito.mock(ApiClientBuilder.class); -//// RecordserviceClient recordserviceClient = PowerMockito.mock(RecordserviceClient.class); -//// apiClient = ApiClient.builder().url("https://demo.com").httpClient(new OkHttpClient()).build(); -//// when(recordserviceClient.insert(request1)).thenReturn(apiClient.recordservice().insert(request1)); -// -//// PowerMockito.when(OkHttpClient.class).thenReturn(this.mockClient); -// PowerMockito.mock(OkHttpClient.class); -// -// try { -// com.skyflow.vault.data.InsertResponse res = vaultController.bulkInsert(request); -// String resp = "{\"summary\":{\"total_records\":1,\"total_inserted\":0,\"total_failed\":1},\"errors\":[{\"index\":0,\"error\":\"com.skyflow.generated.rest.core.ApiClientException: Network error executing HTTP request\",\"code\":500}]}"; -// Assert.assertEquals(res.toString(), resp); -// System.out.println("resppp=>"+ res); -// } catch (SkyflowException e) { -// Assert.assertEquals(400, e.getHttpCode()); -// } -// } + assertTrue(!e.getMessage().isEmpty()); + } + } + + @Test + public void testValidation_valuesIsNull() { + InsertRequest req = InsertRequest.builder().table("table1").values(null).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for null values"); + } catch (SkyflowException e) { + assertTrue(!e.getMessage().isEmpty()); + } + } + + @Test + public void testValidation_valuesIsEmpty() { + InsertRequest req = InsertRequest.builder().table("table1").values(new ArrayList<>()).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for empty values"); + } catch (SkyflowException e) { + assertFalse(e.getMessage().isEmpty()); + } + } + + @Test + public void testValidation_upsertIsEmpty() throws SkyflowException { + InsertRequest req = InsertRequest.builder().table("table1").values(generateValues(1)).upsert(new ArrayList<>()).build(); + // Should not throw, just logs a warning + Validations.validateInsertRequest(req); + } + + + @Test + public void testValidation_keyIsNullOrEmpty() { + ArrayList> values = new ArrayList<>(); + HashMap map = new HashMap<>(); + map.put(null, "value"); + values.add(map); + InsertRequest req = InsertRequest.builder().table("table1").values(values).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for null key in values"); + } catch (SkyflowException e) { + assertFalse(e.getMessage().isEmpty()); + } + + // Test empty key + values.clear(); + map = new HashMap<>(); + map.put(" ", "value"); + values.add(map); + req = InsertRequest.builder().table("table1").values(values).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for empty key in values"); + } catch (SkyflowException e) { + assertFalse(e.getMessage().isEmpty()); + } + } + + @Test + public void testValidation_valueIsNullOrEmpty() { + ArrayList> values = new ArrayList<>(); + HashMap map = new HashMap<>(); + map.put("field1", null); + values.add(map); + InsertRequest req = InsertRequest.builder().table("table1").values(values).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for null value in values"); + } catch (SkyflowException e) { + assertFalse(e.getMessage().isEmpty()); + } + + // Test empty value + values.clear(); + map = new HashMap<>(); + map.put("field1", " "); + values.add(map); + req = InsertRequest.builder().table("table1").values(values).build(); + try { + Validations.validateInsertRequest(req); + fail("Expected SkyflowException for empty value in values"); + } catch (SkyflowException e) { + assertFalse(e.getMessage().isEmpty()); + } + } + + @Test + public void testDefaultValues() throws Exception { + VaultController controller = createController(); + setPrivateField(controller, "insertBatchSize", Constants.INSERT_BATCH_SIZE); + setPrivateField(controller, "insertConcurrencyLimit", Constants.INSERT_CONCURRENCY_LIMIT); + + invokeConfigureInsertConcurrencyAndBatchSize(controller, 10); + assertEquals(Constants.INSERT_BATCH_SIZE.intValue(), getPrivateInt(controller, "insertBatchSize")); + assertEquals(Math.min(Constants.INSERT_CONCURRENCY_LIMIT, (10 + Constants.INSERT_BATCH_SIZE - 1) / Constants.INSERT_BATCH_SIZE), + getPrivateInt(controller, "insertConcurrencyLimit")); + } + + @Test + public void testCustomValidBatchAndConcurrency() throws Exception { + writeEnv("INSERT_BATCH_SIZE=5\nINSERT_CONCURRENCY_LIMIT=3"); + VaultController controller = createController(); + + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(20)).build(); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + assertEquals(5, getPrivateInt(controller, "insertBatchSize")); + assertEquals(3, getPrivateInt(controller, "insertConcurrencyLimit")); + } + + @Test + public void testBatchSizeExceedsMax() throws Exception { + writeEnv("INSERT_BATCH_SIZE=1100\nINSERT_CONCURRENCY_LIMIT=3"); + VaultController controller = createController(); + + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(50)).build(); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + assertEquals(1000, getPrivateInt(controller, "insertBatchSize")); + } + + @Test + public void testConcurrencyExceedsMax() throws Exception { + writeEnv("INSERT_CONCURRENCY_LIMIT=110"); + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(50)).build(); + + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + assertEquals(1, getPrivateInt(controller, "insertConcurrencyLimit")); + } + + @Test + public void testBatchSizeZeroOrNegative() throws Exception { + writeEnv("INSERT_BATCH_SIZE=0"); + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(10)).build(); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + assertEquals(50, getPrivateInt(controller, "insertBatchSize")); + + writeEnv("INSERT_BATCH_SIZE=-5"); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + assertEquals(50, getPrivateInt(controller, "insertBatchSize")); + } + + @Test + public void testConcurrencyZeroOrNegative() throws Exception { + writeEnv("INSERT_CONCURRENCY_LIMIT=0"); + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(10)).build(); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + int min = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, (10 + Constants.INSERT_BATCH_SIZE - 1) / Constants.INSERT_BATCH_SIZE); + assertEquals(min, getPrivateInt(controller, "insertConcurrencyLimit")); + + + + + writeEnv("INSERT_CONCURRENCY_LIMIT=-5"); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + min = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, (10 + Constants.INSERT_BATCH_SIZE - 1) / Constants.INSERT_BATCH_SIZE); + assertEquals(min, getPrivateInt(controller, "insertConcurrencyLimit")); + } + + + @Test + public void testTotalRequestsLessThanBatchSize() throws Exception { + writeEnv("INSERT_BATCH_SIZE=100\nINSERT_CONCURRENCY_LIMIT=10"); + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(10)).build(); + + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) { + // Ignore, Testing concurrency/batch config + } + + assertEquals(100, getPrivateInt(controller, "insertBatchSize")); + assertEquals(1, getPrivateInt(controller, "insertConcurrencyLimit")); + } + + @Test + public void testTotalRequestsZero() throws Exception { + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(0)).build(); + + boolean exceptionThrown = false; + + try { + + controller.bulkInsert(insertRequest); + } catch (Exception e) { + exceptionThrown = true; + } + assertTrue("Exception should be thrown for zero records", exceptionThrown); + } + + + @Test + public void testHighConcurrencyForLowRecords() throws Exception { + writeEnv("INSERT_BATCH_SIZE=1000\nINSERT_CONCURRENCY_LIMIT=100"); + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(10000)).build(); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) {} + + // Only 10 batches needed, so concurrency should be clamped to 10 + assertEquals(1000, getPrivateInt(controller, "insertBatchSize")); + assertEquals(10, getPrivateInt(controller, "insertConcurrencyLimit")); + } + + + @Test + public void testFractionalLastBatch() throws Exception { + writeEnv("INSERT_BATCH_SIZE=100"); + VaultController controller = createController(); + InsertRequest insertRequest = InsertRequest.builder().table("table1").values(generateValues(10050)).build(); + + try { + controller.bulkInsert(insertRequest); + } catch (Exception ignored) {} + + // Last batch should have 50 records, concurrency should be 101 + assertEquals(100, getPrivateInt(controller, "insertBatchSize")); + assertEquals(10, getPrivateInt(controller, "insertConcurrencyLimit")); + } + + private int getPrivateInt(Object obj, String field) throws Exception { + Field f = obj.getClass().getDeclaredField(field); + f.setAccessible(true); + return f.getInt(obj); + } } \ No newline at end of file From c82ec17c91d9cbe0cbd70480fa939262f572d640 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 20:46:41 +0530 Subject: [PATCH 78/97] SK-2258 fix the error response handling --- v3/src/main/java/com/skyflow/utils/Utils.java | 2 +- .../vault/controller/VaultController.java | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 76edb9cd..2be9cb78 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -125,7 +125,7 @@ public static com.skyflow.vault.data.InsertResponse formatResponse(InsertRespons tokensMap.put(key, tokenList); } } - Success success = new Success(indexNumber, record.get(index).getSkyflowId().get(), tokensMap, null); + Success success = new Success(indexNumber, record.get(index).getSkyflowId().get(), tokensMap, record.get(index).getData().isPresent() ? record.get(index).getData().get() : null); successRecords.add(success); } indexNumber++; diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 40093fb0..a1843ff6 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -22,6 +22,7 @@ import io.github.cdimascio.dotenv.Dotenv; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -77,13 +78,13 @@ public CompletableFuture bulkInsertAsync( setBearerToken(); configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); - - List> futures = this.insertBatchFutures(request); + List errorRecords = Collections.synchronizedList(new ArrayList<>()); + List> futures = this.insertBatchFutures(request, errorRecords); return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) .thenApply(v -> { List successRecords = new ArrayList<>(); - List errorRecords = new ArrayList<>(); +// List errorRecords = new ArrayList<>(); for (CompletableFuture future : futures) { com.skyflow.vault.data.InsertResponse futureResponse = future.join(); @@ -111,10 +112,10 @@ private com.skyflow.vault.data.InsertResponse processSync( ArrayList> originalPayload ) throws ExecutionException, InterruptedException { LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); - List errorRecords = new ArrayList<>(); +// List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); - - List> futures = this.insertBatchFutures(insertRequest); + List errorRecords = Collections.synchronizedList(new ArrayList<>()); + List> futures = this.insertBatchFutures(insertRequest, errorRecords); CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); allFutures.join(); @@ -137,8 +138,8 @@ private com.skyflow.vault.data.InsertResponse processSync( private List> insertBatchFutures( - com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest - ) { + com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, + List errorRecords) { List records = insertRequest.getRecords().get(); ExecutorService executor = Executors.newFixedThreadPool(insertConcurrencyLimit); @@ -152,7 +153,10 @@ private List> insertBat CompletableFuture future = CompletableFuture .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)) - .exceptionally(ex -> new com.skyflow.vault.data.InsertResponse(null, handleBatchException(ex, batch, batchNumber, batches))); + .exceptionally(ex -> { + errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); + return null; + }); futures.add(future); } } finally { @@ -181,7 +185,7 @@ private void configureInsertConcurrencyAndBatchSize(int totalRequests) { int batchSize = Integer.parseInt(userProvidedBatchSize); int maxBatchSize = Math.min(batchSize, Constants.MAX_INSERT_BATCH_SIZE); if (maxBatchSize > 0) { - this.insertBatchSize = batchSize; + this.insertBatchSize = maxBatchSize; } else { LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); this.insertBatchSize = Constants.INSERT_BATCH_SIZE; From a0147065ef2c3559326eef16a3a7a5f17016f764 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Fri, 29 Aug 2025 15:23:06 +0000 Subject: [PATCH 79/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-742a05b --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index a3f72b89..99fea873 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.2-dev.a7b8e55 + 2.0.0-beta.3-dev.742a05b jar From 859f440a3297040dee008855338756b8e786fb50 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Fri, 29 Aug 2025 21:26:05 +0530 Subject: [PATCH 80/97] SK-2267 Fix log behaviour for bearer token --- .../java/com/skyflow/errors/ErrorMessage.java | 1 + .../src/main/java/com/skyflow/logs/ErrorLogs.java | 1 + .../src/main/java/com/skyflow/logs/InfoLogs.java | 3 ++- .../main/java/com/skyflow/utils/BaseUtils.java | 15 ++++++++++++--- v2/src/main/java/com/skyflow/VaultClient.java | 2 +- v3/src/main/java/com/skyflow/VaultClient.java | 6 +++--- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/skyflow/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/errors/ErrorMessage.java index 0084d727..9337e08d 100644 --- a/common/src/main/java/com/skyflow/errors/ErrorMessage.java +++ b/common/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -52,6 +52,7 @@ public enum ErrorMessage { JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."), MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."), MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."), + BearerTokenExpired("%s0 Validation error. Bearer token is expired. Please provide a valid bearer token."), // Insert TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."), diff --git a/common/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java index 9b329ac8..6a8c9297 100644 --- a/common/src/main/java/com/skyflow/logs/ErrorLogs.java +++ b/common/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -43,6 +43,7 @@ public enum ErrorLogs { INVALID_KEY_SPEC("Unable to parse RSA private key."), BEARER_TOKEN_REJECTED("Bearer token request resulted in failure."), SIGNED_DATA_TOKENS_REJECTED("Signed data tokens request resulted in failure."), + BEARER_TOKEN_EXPIRED("Bearer token is expired."), // Vault api interfaces TABLE_IS_REQUIRED("Invalid %s1 request. Table is required."), diff --git a/common/src/main/java/com/skyflow/logs/InfoLogs.java b/common/src/main/java/com/skyflow/logs/InfoLogs.java index e54df467..03f80ac7 100644 --- a/common/src/main/java/com/skyflow/logs/InfoLogs.java +++ b/common/src/main/java/com/skyflow/logs/InfoLogs.java @@ -20,7 +20,8 @@ public enum InfoLogs { GET_SIGNED_DATA_TOKENS_TRIGGERED("getSignedDataTokens method triggered."), GET_SIGNED_DATA_TOKEN_SUCCESS("Signed data tokens generated."), REUSE_BEARER_TOKEN("Reusing bearer token."), - REUSE_API_KEY("Reusing api key."), + USE_CLIENT_PROVIDED_BEARER_TOKEN("Using bearer token provided by client."), + USE_API_KEY("Using api key."), GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED("generateBearerTokenFromCredentials method triggered."), GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED("generateBearerTokenFromCredentialString method triggered."), GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED("generateSignedTokensFromCredentialsFile method triggered."), diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index c9278517..f83b6312 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -9,6 +9,7 @@ import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; import com.skyflow.serviceaccount.util.BearerToken; +import com.skyflow.serviceaccount.util.Token; import com.skyflow.utils.logger.LogUtil; import org.apache.commons.codec.binary.Base64; @@ -43,23 +44,31 @@ public static String getVaultURL(String clusterId, Env env, String vaultDomain) } public static String generateBearerToken(Credentials credentials) throws SkyflowException { + String bearerToken; if (credentials.getPath() != null) { - return BearerToken.builder() + bearerToken = BearerToken.builder() .setCredentials(new File(credentials.getPath())) .setRoles(credentials.getRoles()) .setCtx(credentials.getContext()) .build() .getBearerToken(); } else if (credentials.getCredentialsString() != null) { - return BearerToken.builder() + bearerToken = BearerToken.builder() .setCredentials(credentials.getCredentialsString()) .setRoles(credentials.getRoles()) .setCtx(credentials.getContext()) .build() .getBearerToken(); } else { - return credentials.getToken(); + LogUtil.printInfoLog(InfoLogs.USE_CLIENT_PROVIDED_BEARER_TOKEN.getLog()); + bearerToken = credentials.getToken(); } + // check expiry for generated token + if (Token.isExpired(bearerToken)) { + LogUtil.printErrorLog(ErrorLogs.BEARER_TOKEN_EXPIRED.getLog()); + throw new SkyflowException(ErrorMessage.BearerTokenExpired.getMessage()); + } + return bearerToken; } public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException { diff --git a/v2/src/main/java/com/skyflow/VaultClient.java b/v2/src/main/java/com/skyflow/VaultClient.java index 7854a81b..e9981523 100644 --- a/v2/src/main/java/com/skyflow/VaultClient.java +++ b/v2/src/main/java/com/skyflow/VaultClient.java @@ -213,7 +213,7 @@ protected void setBearerToken() throws SkyflowException { prioritiseCredentials(); Validations.validateCredentials(this.finalCredentials); if (this.finalCredentials.getApiKey() != null) { - LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); + LogUtil.printInfoLog(InfoLogs.USE_API_KEY.getLog()); token = this.finalCredentials.getApiKey(); } else if (Token.isExpired(token)) { LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index 8e1147a6..c3ad1af4 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -64,8 +64,10 @@ protected void setBearerToken() throws SkyflowException { prioritiseCredentials(); Validations.validateCredentials(this.finalCredentials); if (this.finalCredentials.getApiKey() != null) { - LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); + LogUtil.printInfoLog(InfoLogs.USE_API_KEY.getLog()); token = this.finalCredentials.getApiKey(); + } else if (token == null || token.trim().isEmpty()) { + token = Utils.generateBearerToken(this.finalCredentials); } else if (Token.isExpired(token)) { LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog()); token = Utils.generateBearerToken(this.finalCredentials); @@ -73,9 +75,7 @@ protected void setBearerToken() throws SkyflowException { LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog()); } updateExecutorInHTTP(); // update executor - // token need to add in http client this.apiClient = this.apiClientBuilder.build(); - } private void updateVaultURL() { From b5bb89e586ee21ede1a21914fb1955b80cdfd8b6 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Fri, 29 Aug 2025 21:59:39 +0530 Subject: [PATCH 81/97] SK-2267 Remove redundant error and info logs from V2 module - Fix CI failures --- .../java/com/skyflow/errors/ErrorMessage.java | 2 +- .../main/java/com/skyflow/logs/ErrorLogs.java | 4 +- .../java/com/skyflow/utils/BaseUtils.java | 4 +- .../java/com/skyflow/ConnectionClient.java | 2 +- .../main/java/com/skyflow/logs/ErrorLogs.java | 140 ------------------ .../main/java/com/skyflow/logs/InfoLogs.java | 105 ------------- .../java/com/skyflow/utils/UtilsTests.java | 5 +- 7 files changed, 8 insertions(+), 254 deletions(-) delete mode 100644 v2/src/main/java/com/skyflow/logs/ErrorLogs.java delete mode 100644 v2/src/main/java/com/skyflow/logs/InfoLogs.java diff --git a/common/src/main/java/com/skyflow/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/errors/ErrorMessage.java index 9337e08d..2493e854 100644 --- a/common/src/main/java/com/skyflow/errors/ErrorMessage.java +++ b/common/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -52,7 +52,7 @@ public enum ErrorMessage { JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."), MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."), MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."), - BearerTokenExpired("%s0 Validation error. Bearer token is expired. Please provide a valid bearer token."), + BearerTokenExpired("%s0 Validation error. Bearer token is invalid or expired. Please provide a valid bearer token."), // Insert TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."), diff --git a/common/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java index 6a8c9297..2396ce83 100644 --- a/common/src/main/java/com/skyflow/logs/ErrorLogs.java +++ b/common/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -43,7 +43,6 @@ public enum ErrorLogs { INVALID_KEY_SPEC("Unable to parse RSA private key."), BEARER_TOKEN_REJECTED("Bearer token request resulted in failure."), SIGNED_DATA_TOKENS_REJECTED("Signed data tokens request resulted in failure."), - BEARER_TOKEN_EXPIRED("Bearer token is expired."), // Vault api interfaces TABLE_IS_REQUIRED("Invalid %s1 request. Table is required."), @@ -130,8 +129,7 @@ public enum ErrorLogs { UNEXPECTED_ERROR_DURING_BATCH_PROCESSING("Unexpected error occurred during batch processing. Error: %s1"), - PROCESSING_ERROR_RESPONSE("Processing error response.") - ; + PROCESSING_ERROR_RESPONSE("Processing error response."); private final String log; diff --git a/common/src/main/java/com/skyflow/utils/BaseUtils.java b/common/src/main/java/com/skyflow/utils/BaseUtils.java index f83b6312..b7cf6bb0 100644 --- a/common/src/main/java/com/skyflow/utils/BaseUtils.java +++ b/common/src/main/java/com/skyflow/utils/BaseUtils.java @@ -65,8 +65,8 @@ public static String generateBearerToken(Credentials credentials) throws Skyflow } // check expiry for generated token if (Token.isExpired(bearerToken)) { - LogUtil.printErrorLog(ErrorLogs.BEARER_TOKEN_EXPIRED.getLog()); - throw new SkyflowException(ErrorMessage.BearerTokenExpired.getMessage()); + LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog()); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.BearerTokenExpired.getMessage()); } return bearerToken; } diff --git a/v2/src/main/java/com/skyflow/ConnectionClient.java b/v2/src/main/java/com/skyflow/ConnectionClient.java index d3b20c3d..79541add 100644 --- a/v2/src/main/java/com/skyflow/ConnectionClient.java +++ b/v2/src/main/java/com/skyflow/ConnectionClient.java @@ -57,7 +57,7 @@ private void setApiKey() { if (apiKey == null) { apiKey = this.finalCredentials.getApiKey(); } else { - LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog()); + LogUtil.printInfoLog(InfoLogs.USE_API_KEY.getLog()); } } diff --git a/v2/src/main/java/com/skyflow/logs/ErrorLogs.java b/v2/src/main/java/com/skyflow/logs/ErrorLogs.java deleted file mode 100644 index 3415860c..00000000 --- a/v2/src/main/java/com/skyflow/logs/ErrorLogs.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.skyflow.logs; - -public enum ErrorLogs { - // Client initialization - VAULT_CONFIG_EXISTS("Vault config with vault ID %s1 already exists."), - VAULT_CONFIG_DOES_NOT_EXIST("Vault config with vault ID %s1 doesn't exist."), - VAULT_ID_IS_REQUIRED("Invalid vault config. Vault ID is required."), - EMPTY_VAULT_ID("Invalid vault config. Vault ID can not be empty."), - CLUSTER_ID_IS_REQUIRED("Invalid vault config. Cluster ID is required."), - EMPTY_CLUSTER_ID("Invalid vault config. Cluster ID can not be empty."), - CONNECTION_CONFIG_EXISTS("Connection config with connection ID %s1 already exists."), - CONNECTION_CONFIG_DOES_NOT_EXIST("Connection config with connection ID %s1 doesn't exist."), - CONNECTION_ID_IS_REQUIRED("Invalid connection config. Connection ID is required."), - EMPTY_CONNECTION_ID("Invalid connection config. Connection ID can not be empty."), - CONNECTION_URL_IS_REQUIRED("Invalid connection config. Connection URL is required."), - EMPTY_CONNECTION_URL("Invalid connection config. Connection URL can not be empty."), - INVALID_CONNECTION_URL("Invalid connection config. Connection URL is not a valid URL."), - MULTIPLE_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Only one of 'path', 'credentialsString', 'token' or 'apiKey' is allowed."), - NO_TOKEN_GENERATION_MEANS_PASSED("Invalid credentials. Any one of 'path', 'credentialsString', 'token' or 'apiKey' is required."), - EMPTY_CREDENTIALS_PATH("Invalid credentials. Credentials path can not be empty."), - EMPTY_CREDENTIALS_STRING("Invalid credentials. Credentials string can not be empty."), - EMPTY_TOKEN_VALUE("Invalid credentials. Token can not be empty."), - EMPTY_API_KEY_VALUE("Invalid credentials. Api key can not be empty."), - INVALID_API_KEY("Invalid credentials. Api key is invalid."), - EMPTY_ROLES("Invalid credentials. Roles can not be empty."), - EMPTY_OR_NULL_ROLE_IN_ROLES("Invalid credentials. Role can not be null or empty in roles at index %s1."), - EMPTY_OR_NULL_CONTEXT("Invalid credentials. Context can not be empty."), - - // Bearer token generation - INVALID_BEARER_TOKEN("Bearer token is invalid or expired."), - INVALID_CREDENTIALS_FILE("Credentials file is either null or an invalid file."), - INVALID_CREDENTIALS_STRING("Credentials string is either null or empty."), - INVALID_CREDENTIALS_FILE_FORMAT("Credentials file is not in a valid JSON format."), - CREDENTIALS_FILE_NOT_FOUND("Credentials file not found at specified path."), - INVALID_CREDENTIALS_STRING_FORMAT("Credentials string is not in a valid JSON string format."), - PRIVATE_KEY_IS_REQUIRED("Private key is required."), - CLIENT_ID_IS_REQUIRED("Client ID is required."), - KEY_ID_IS_REQUIRED("Key ID is required."), - TOKEN_URI_IS_REQUIRED("Token URI is required."), - INVALID_TOKEN_URI("Invalid value for token URI in credentials."), - JWT_INVALID_FORMAT("Private key is not in a valid format."), - INVALID_ALGORITHM("Algorithm for parsing private key is invalid or does not exist."), - INVALID_KEY_SPEC("Unable to parse RSA private key."), - BEARER_TOKEN_REJECTED("Bearer token request resulted in failure."), - SIGNED_DATA_TOKENS_REJECTED("Signed data tokens request resulted in failure."), - - // Vault api interfaces - TABLE_IS_REQUIRED("Invalid %s1 request. Table is required."), - EMPTY_TABLE_NAME("Invalid %s1 request. Table name can not be empty."), - VALUES_IS_REQUIRED("Invalid %s1 request. Values are required."), - EMPTY_VALUES("Invalid %s1 request. Values can not be empty."), - EMPTY_OR_NULL_VALUE_IN_VALUES("Invalid %s1 request. Value can not be null or empty in values for key \"%s2\"."), - EMPTY_OR_NULL_KEY_IN_VALUES("Invalid %s1 request. Key can not be null or empty in values"), - EMPTY_UPSERT("Invalid %s1 request. Upsert can not be empty."), - HOMOGENOUS_NOT_SUPPORTED_WITH_UPSERT("Invalid %s1 request. Homogenous is not supported when upsert is passed."), - TOKENS_NOT_ALLOWED_WITH_TOKEN_MODE_DISABLE("Invalid %s1 request. Tokens are not allowed when tokenMode is DISABLE."), - TOKENS_REQUIRED_WITH_TOKEN_MODE("Invalid %s1 request. Tokens are required when tokenMode is %s2."), - EMPTY_TOKENS("Invalid %s1 request. Tokens can not be empty."), - EMPTY_OR_NULL_VALUE_IN_TOKENS("Invalid %s1 request. Value can not be null or empty in tokens for key \"%s2\"."), - EMPTY_OR_NULL_KEY_IN_TOKENS("Invalid %s1 request. Key can not be null or empty in tokens."), - INSUFFICIENT_TOKENS_PASSED_FOR_TOKEN_MODE_ENABLE_STRICT("Invalid %s1 request. For tokenMode as ENABLE_STRICT, tokens should be passed for all fields."), - MISMATCH_OF_FIELDS_AND_TOKENS("Invalid %s1 request. Keys for values and tokens are not matching."), - INSERT_RECORDS_REJECTED("Insert request resulted in failure."), - DETOKENIZE_DATA_REQUIRED("Invalid %s1 request. Detokenize data is required."), - EMPTY_DETOKENIZE_DATA("Invalid %s1 request. Detokenize data can not be empty."), - EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA("Invalid %s1 request. Token can not be null or empty in detokenize data at index %s2."), - REDACTION_IS_REQUIRED("Invalid %s1 request. Redaction is required."), - DETOKENIZE_REQUEST_REJECTED("Detokenize request resulted in failure."), - IDS_IS_REQUIRED("Invalid %s1 request. Ids are required."), - EMPTY_IDS("Invalid %s1 request. Ids can not be empty."), - EMPTY_OR_NULL_ID_IN_IDS("Invalid %s1 request. Id can not be null or empty in ids at index %s2."), - EMPTY_FIELDS("Invalid %s1 request. Fields can not be empty."), - EMPTY_OR_NULL_FIELD_IN_FIELDS("Invalid %s1 request. Field can not be null or empty in fields at index %s2."), - TOKENIZATION_NOT_SUPPORTED_WITH_REDACTION("Invalid %s1 request. Return tokens is not supported when redaction is applied."), - TOKENIZATION_SUPPORTED_ONLY_WITH_IDS("Invalid %s1 request. Return tokens is not supported when column name and values are passed."), - EMPTY_OFFSET("Invalid %s1 request. Offset can not be empty."), - EMPTY_LIMIT("Invalid %s1 request. Limit can not be empty."), - NEITHER_IDS_NOR_COLUMN_NAME_PASSED("Invalid %s1 request. Neither ids nor column name and values are passed."), - BOTH_IDS_AND_COLUMN_NAME_PASSED("Invalid %s1 request. Both ids and column name and values are passed."), - COLUMN_NAME_IS_REQUIRED("Invalid %s1 request. Column name is required when column values are passed."), - EMPTY_COLUMN_NAME("Invalid %s1 request. Column name can not be empty."), - COLUMN_VALUES_IS_REQUIRED_GET("Invalid %s1 request. Column values are required when column name is passed."), - EMPTY_COLUMN_VALUES("Invalid %s1 request. Column values can not be empty."), - EMPTY_OR_NULL_COLUMN_VALUE_IN_COLUMN_VALUES("Invalid %s1 request. Column value can not by null or empty in column values at index %s2."), - GET_REQUEST_REJECTED("Get request resulted in failure."), - DATA_IS_REQUIRED("Invalid %s1 request. Data is required."), - EMPTY_DATA("Invalid %s1 request. Data can not be empty."), - SKYFLOW_ID_IS_REQUIRED("Invalid %s1 request. Skyflow Id is required."), - INVALID_SKYFLOW_ID_TYPE("Invalid %s1 request. Skyflow Id should of type String."), - EMPTY_SKYFLOW_ID("Invalid %s1 request. Skyflow Id can not be empty."), - UPDATE_REQUEST_REJECTED("Update request resulted in failure."), - QUERY_IS_REQUIRED("Invalid %s1 request. Query is required."), - EMPTY_QUERY("Invalid %s1 request. Query can not be empty."), - QUERY_REQUEST_REJECTED("Query request resulted in failure."), - COLUMN_VALUES_IS_REQUIRED_TOKENIZE("Invalid %s1 request. ColumnValues are required."), - EMPTY_OR_NULL_COLUMN_GROUP_IN_COLUMN_VALUES("Invalid %s1 request. Column group can not be null or empty in column values at index %s2."), - TOKENIZE_REQUEST_REJECTED("Tokenize request resulted in failure."), - DELETE_REQUEST_REJECTED("Delete request resulted in failure."), - - // invoke connection interface - INVOKE_CONNECTION_INVALID_CONNECTION_URL("Invalid %s1 request. Connection URL is not a valid URL."), - EMPTY_REQUEST_HEADERS("Invalid %s1 request. Request headers can not be empty."), - INVALID_REQUEST_HEADERS("Invalid %s1 request. Request header can not be null or empty in request headers."), - EMPTY_PATH_PARAMS("Invalid %s1 request. Path params can not be empty."), - INVALID_PATH_PARAM("Invalid %s1 request. Path parameter can not be null or empty in path params."), - EMPTY_QUERY_PARAMS("Invalid %s1 request. Query params can not be empty."), - INVALID_QUERY_PARAM("Invalid %s1 request. Query parameter can not be null or empty in query params."), - EMPTY_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), - INVALID_REQUEST_BODY("Invalid %s1 request. Request body can not be empty."), - INVOKE_CONNECTION_REQUEST_REJECTED("Invoke connection 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."), - DEIDENTIFY_TEXT_REQUEST_REJECTED("DeIdentify text request resulted in failure."), - INVALID_TEXT_IN_REIDENTIFY("Invalid %s1 request. The text field is required and must be a non-empty string. Specify a valid text."), - REIDENTIFY_TEXT_REQUEST_REJECTED("ReIdentify text request resulted in failure."), - DEIDENTIFY_FILE_REQUEST_REJECTED("DeIdentify file request resulted in failure."), - GET_DETECT_RUN_REQUEST_REJECTED("Get detect run request resulted in failure."), - INVALID_NULL_FILE_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file field is required and must not be null. Specify a valid file."), - FILE_NOT_FOUND_TO_DEIDENTIFY("Invalid %s1 request. The file field is required and must not be empty. Specify a valid file."), - FILE_NOT_READABLE_TO_DEIDENTIFY("Invalid %s1 request. The file is not readable. Please check the file permissions or path."), - INVALID_PIXEL_DENSITY_TO_DEIDENTIFY_FILE("Invalid %s1 request. Pixel density must be a positive integer greater than 0. Specify a valid pixel density."), - INVALID_MAX_RESOLUTION("Invalid %s1 request. Max resolution must be a positive integer greater than 0. Specify a valid max resolution."), - INVALID_BLEEP_TO_DEIDENTIFY_AUDIO("Invalid %s1 request. Specify a valid bleep as AudioBleep"), - OUTPUT_DIRECTORY_NOT_FOUND("Invalid %s1 request. The output directory does not exist. Please specify a valid output directory."), - INVALID_PERMISSIONS_FOR_OUTPUT_DIRECTORY("Invalid %s1 request. The output directory is not writable. Please check the permissions or specify a valid output directory."), - EMPTY_FILE_AND_FILE_PATH_IN_DEIDENTIFY_FILE("Invalid %s1 request. The file and file path fields are both empty. Specify a valid file object or file path."), - ; - - private final String log; - - ErrorLogs(String log) { - this.log = log; - } - - public final String getLog() { - return log; - } -} diff --git a/v2/src/main/java/com/skyflow/logs/InfoLogs.java b/v2/src/main/java/com/skyflow/logs/InfoLogs.java deleted file mode 100644 index efd81a49..00000000 --- a/v2/src/main/java/com/skyflow/logs/InfoLogs.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.skyflow.logs; - -public enum InfoLogs { - // Client initialization - CLIENT_INITIALIZED("Initialized skyflow client."), - VALIDATING_VAULT_CONFIG("Validating vault config."), - VALIDATING_CONNECTION_CONFIG("Validating connection config."), - UNABLE_TO_GENERATE_SDK_METRIC("Unable to generate %s1 metric."), - VAULT_CONTROLLER_INITIALIZED("Initialized vault controller with vault ID %s1."), - DETECT_CONTROLLER_INITIALIZED("Initialized detect controller with vault ID %s1."), - CONNECTION_CONTROLLER_INITIALIZED("Initialized connection controller with connection ID %s1."), - LOGGER_SETUP_DONE("Set up logger."), - CURRENT_LOG_LEVEL("Current log level is %s1."), - - // Bearer token generation - EMPTY_BEARER_TOKEN("Bearer token is empty."), - BEARER_TOKEN_EXPIRED("Bearer token is expired."), - GET_BEARER_TOKEN_TRIGGERED("getBearerToken method triggered."), - GET_BEARER_TOKEN_SUCCESS("Bearer token generated."), - GET_SIGNED_DATA_TOKENS_TRIGGERED("getSignedDataTokens method triggered."), - GET_SIGNED_DATA_TOKEN_SUCCESS("Signed data tokens generated."), - REUSE_BEARER_TOKEN("Reusing bearer token."), - REUSE_API_KEY("Reusing api key."), - GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED("generateBearerTokenFromCredentials method triggered."), - GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED("generateBearerTokenFromCredentialString method triggered."), - GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED("generateSignedTokensFromCredentialsFile method triggered."), - GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_STRING_TRIGGERED("generateSignedTokensFromCredentialsString method triggered."), - - // Insert interface - INSERT_TRIGGERED("Insert method triggered."), - VALIDATE_INSERT_REQUEST("Validating insert request."), - INSERT_REQUEST_RESOLVED("Insert request resolved."), - INSERT_SUCCESS("Data inserted."), - - // Detokenize interface - DETOKENIZE_TRIGGERED("Detokenize method triggered."), - VALIDATE_DETOKENIZE_REQUEST("Validating detokenize request."), - DETOKENIZE_REQUEST_RESOLVED("Detokenize request resolved."), - DETOKENIZE_PARTIAL_SUCCESS("Data detokenized partially."), - DETOKENIZE_SUCCESS("Data detokenized."), - - // Get interface - GET_TRIGGERED("Get method triggered."), - VALIDATE_GET_REQUEST("Validating get request."), - GET_REQUEST_RESOLVED("Get request resolved."), - GET_SUCCESS("Data revealed."), - - // Update interface - UPDATE_TRIGGERED("Update method triggered."), - VALIDATE_UPDATE_REQUEST("Validating update request."), - UPDATE_REQUEST_RESOLVED("Update request resolved."), - UPDATE_SUCCESS("Data updated."), - - // Delete interface - DELETE_TRIGGERED("Delete method triggered."), - VALIDATING_DELETE_REQUEST("Validating delete request."), - DELETE_REQUEST_RESOLVED("Delete request resolved."), - DELETE_SUCCESS("Data deleted."), - - // Query interface - QUERY_TRIGGERED("Query method triggered."), - VALIDATING_QUERY_REQUEST("Validating query request."), - QUERY_REQUEST_RESOLVED("Query request resolved."), - QUERY_SUCCESS("Query executed."), - - // Tokenize interface - TOKENIZE_TRIGGERED("Tokenize method triggered."), - VALIDATING_TOKENIZE_REQUEST("Validating tokenize request."), - TOKENIZE_REQUEST_RESOLVED("Tokenize request resolved."), - TOKENIZE_SUCCESS("Data tokenized."), - - - // Invoke connection interface - INVOKE_CONNECTION_TRIGGERED("Invoke connection method triggered."), - VALIDATING_INVOKE_CONNECTION_REQUEST("Validating invoke connection request."), - INVOKE_CONNECTION_REQUEST_RESOLVED("Invoke connection request resolved."), - - // detect - VALIDATE_DEIDENTIFY_TEXT_REQUEST("Validating deidentify text request."), - DEIDENTIFY_TEXT_SUCCESS("Text data de-identified."), - DEIDENTIFY_TEXT_TRIGGERED("DeIdentify text method triggered."), - DEIDENTIFY_TEXT_REQUEST_RESOLVED("DeIdentify text request resolved."), - VALIDATE_REIDENTIFY_TEXT_REQUEST("Validating reidentify text request."), - REIDENTIFY_TEXT_TRIGGERED("ReIdentify text method triggered."), - REIDENTIFY_TEXT_REQUEST_RESOLVED("ReIdentify text request resolved."), - DEIDENTIFY_FILE_TRIGGERED("DeIdentify file method triggered."), - VALIDATE_DEIDENTIFY_FILE_REQUEST("Validating deidentify file request."), - DEIDENTIFY_FILE_REQUEST_RESOLVED("DeIdentify file request resolved."), - DEIDENTIFY_FILE_SUCCESS("File deidentified successfully."), - GET_DETECT_RUN_TRIGGERED("Get detect run method triggered."), - VALIDATE_GET_DETECT_RUN_REQUEST("Validating get detect run request."), - REIDENTIFY_TEXT_SUCCESS("Text data re-identified."), - ; - - - private final String log; - - InfoLogs(String log) { - this.log = log; - } - - public final String getLog() { - return log; - } -} diff --git a/v2/test/java/com/skyflow/utils/UtilsTests.java b/v2/test/java/com/skyflow/utils/UtilsTests.java index 4f1bba41..00543567 100644 --- a/v2/test/java/com/skyflow/utils/UtilsTests.java +++ b/v2/test/java/com/skyflow/utils/UtilsTests.java @@ -122,9 +122,10 @@ public void testGenerateBearerTokenWithToken() { credentials.setContext(context); credentials.setRoles(roles); String bearerToken = Utils.generateBearerToken(credentials); - Assert.assertEquals(token, bearerToken); + Assert.fail(EXCEPTION_NOT_THROWN); } catch (SkyflowException e) { - Assert.fail(INVALID_EXCEPTION_THROWN); + Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), e.getHttpCode()); + Assert.assertEquals(ErrorMessage.BearerTokenExpired.getMessage(), e.getMessage()); } } From adb292bd8f961d9dae72fef36844e24aff619313 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Fri, 29 Aug 2025 16:33:49 +0000 Subject: [PATCH 82/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-ad4ff4f --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 99fea873..9ba0af2f 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.3-dev.742a05b + 2.0.0-beta.3-dev.ad4ff4f jar From 6a4c860e3f3316f3494e3b282edc6f8890f8d47f Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Sat, 30 Aug 2025 13:32:57 +0530 Subject: [PATCH 83/97] SK-2274 detokenize bulk async and sync method --- .../java/com/skyflow/errors/ErrorMessage.java | 11 +- .../main/java/com/skyflow/logs/ErrorLogs.java | 9 + v3/src/main/java/com/skyflow/VaultClient.java | 22 ++ .../java/com/skyflow/utils/Constants.java | 6 +- v3/src/main/java/com/skyflow/utils/Utils.java | 94 ++++- .../utils/validations/Validations.java | 46 +++ .../vault/controller/VaultController.java | 199 ++++++++++- .../skyflow/vault/data/DetokenizeRequest.java | 41 +++ .../vault/data/DetokenizeResponse.java | 53 +++ .../vault/data/DetokenizeResponseObject.java | 63 ++++ .../skyflow/vault/data/DetokenizeSummary.java | 36 ++ .../vault/data/TokenGroupRedactions.java | 39 +++ .../java/com/skyflow/utils/UtilsTests.java | 320 +++++++++++++++++- .../com/skyflow/vault/data/InsertTests.java | 2 - 14 files changed, 915 insertions(+), 26 deletions(-) create mode 100644 v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/DetokenizeResponseObject.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java create mode 100644 v3/src/main/java/com/skyflow/vault/data/TokenGroupRedactions.java diff --git a/common/src/main/java/com/skyflow/errors/ErrorMessage.java b/common/src/main/java/com/skyflow/errors/ErrorMessage.java index 2493e854..f4b2ce7b 100644 --- a/common/src/main/java/com/skyflow/errors/ErrorMessage.java +++ b/common/src/main/java/com/skyflow/errors/ErrorMessage.java @@ -150,7 +150,16 @@ public enum ErrorMessage { 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."), // Generic - ErrorOccurred("%s0 API error. Error occurred.") + ErrorOccurred("%s0 API error. Error occurred."), + + DetokenizeRequestNull("%s0 Validation error. DetokenizeRequest object is null. Specify a valid DetokenizeRequest object."), + + NullTokenGroupRedactions("%s0 Validation error. TokenGroupRedaction in the list is null. Specify a valid TokenGroupRedactions object."), + + NullRedactionInTokenGroup("%s0 Validation error. Redaction in TokenGroupRedactions is null or empty. Specify a valid redaction."), + + NullTokenGroupNameInTokenGroup("%s0 Validation error. TokenGroupName in TokenGroupRedactions is null or empty. Specify a valid tokenGroupName."), + ; ; private final String message; diff --git a/common/src/main/java/com/skyflow/logs/ErrorLogs.java b/common/src/main/java/com/skyflow/logs/ErrorLogs.java index 2396ce83..8f1156fd 100644 --- a/common/src/main/java/com/skyflow/logs/ErrorLogs.java +++ b/common/src/main/java/com/skyflow/logs/ErrorLogs.java @@ -66,6 +66,15 @@ public enum ErrorLogs { EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA("Invalid %s1 request. Token can not be null or empty in detokenize data at index %s2."), REDACTION_IS_REQUIRED("Invalid %s1 request. Redaction is required."), DETOKENIZE_REQUEST_REJECTED("Detokenize request resulted in failure."), + DETOKENIZE_REQUEST_NULL("Invalid %s1 request. Detokenize request can not be null."), + + NULL_TOKEN_REDACTION_GROUP_OBJECT("Invalid %s1 request. Token Redaction group object can not be null or empty."), + + NULL_REDACTION_IN_TOKEN_GROUP("Invalid %s1 request. Redaction can not be null in token redaction group"), + + NULL_TOKEN_GROUP_NAME_IN_TOKEN_GROUP("Invalid %s1 request. Token group name can not be null in token redaction group"), + + EMPTY_OR_NULL_REDACTION_IN_TOKEN_GROUP("Invalid %s1 request. Redaction can not be null or empty in token redaction group"), IDS_IS_REQUIRED("Invalid %s1 request. Ids are required."), EMPTY_IDS("Invalid %s1 request. Ids can not be empty."), EMPTY_OR_NULL_ID_IN_IDS("Invalid %s1 request. Id can not be null or empty in ids at index %s2."), diff --git a/v3/src/main/java/com/skyflow/VaultClient.java b/v3/src/main/java/com/skyflow/VaultClient.java index c3ad1af4..b43ccd60 100644 --- a/v3/src/main/java/com/skyflow/VaultClient.java +++ b/v3/src/main/java/com/skyflow/VaultClient.java @@ -19,6 +19,7 @@ import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.data.DetokenizeRequest; import io.github.cdimascio.dotenv.Dotenv; import io.github.cdimascio.dotenv.DotenvException; import okhttp3.OkHttpClient; @@ -155,4 +156,25 @@ protected InsertRequest getBulkInsertRequestBody(com.skyflow.vault.data.InsertRe } + protected com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest getDetokenizeRequestBody(DetokenizeRequest request) { + List tokens = request.getTokens(); + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest.Builder builder = + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest.builder() + .vaultId(this.vaultConfig.getVaultId()) + .tokens(tokens); + if (request.getTokenGroupRedactions() != null){ + List tokenGroupRedactionsList = new ArrayList<>(); + for (com.skyflow.vault.data.TokenGroupRedactions tokenGroupRedactions : request.getTokenGroupRedactions()) { + com.skyflow.generated.rest.types.TokenGroupRedactions redactions = + com.skyflow.generated.rest.types.TokenGroupRedactions.builder() + .tokenGroupName(tokenGroupRedactions.getTokenGroupName()) + .redaction(tokenGroupRedactions.getRedaction()) + .build(); + tokenGroupRedactionsList.add(redactions); + } + + builder.tokenGroupRedactions(tokenGroupRedactionsList); + } + return builder.build(); + } } diff --git a/v3/src/main/java/com/skyflow/utils/Constants.java b/v3/src/main/java/com/skyflow/utils/Constants.java index f295ab52..379bcfbb 100644 --- a/v3/src/main/java/com/skyflow/utils/Constants.java +++ b/v3/src/main/java/com/skyflow/utils/Constants.java @@ -9,6 +9,10 @@ public final class Constants extends BaseConstants { public static final Integer MAX_INSERT_BATCH_SIZE = 1000; public static final Integer INSERT_CONCURRENCY_LIMIT = 10; public static final Integer MAX_INSERT_CONCURRENCY_LIMIT = 10; - public static final Integer DETOKENIZE_BATCH_SIZE = 100; + public static final Integer DETOKENIZE_BATCH_SIZE = 50; public static final Integer DETOKENIZE_CONCURRENCY_LIMIT = 10; + + public static final Integer MAX_DETOKENIZE_BATCH_SIZE = 1000; + public static final Integer MAX_DETOKENIZE_CONCURRENCY_LIMIT = 10; + } diff --git a/v3/src/main/java/com/skyflow/utils/Utils.java b/v3/src/main/java/com/skyflow/utils/Utils.java index 2be9cb78..7bb8199b 100644 --- a/v3/src/main/java/com/skyflow/utils/Utils.java +++ b/v3/src/main/java/com/skyflow/utils/Utils.java @@ -3,9 +3,12 @@ import com.google.gson.JsonObject; import com.skyflow.enums.Env; import com.skyflow.generated.rest.core.ApiClientApiException; +import com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest; import com.skyflow.generated.rest.types.InsertRecordData; import com.skyflow.generated.rest.types.InsertResponse; import com.skyflow.generated.rest.types.RecordResponseObject; +import com.skyflow.generated.rest.types.TokenGroupRedactions; +import com.skyflow.vault.data.DetokenizeResponse; import com.skyflow.vault.data.ErrorRecord; import com.skyflow.vault.data.Success; import com.skyflow.vault.data.Token; @@ -36,6 +39,29 @@ public static List> createBatches(List return batches; } + public static List createDetokenizeBatches(DetokenizeRequest request, int batchSize) { + List detokenizeRequests = new ArrayList<>(); + List tokens = request.getTokens().get(); + + for (int i = 0; i < tokens.size(); i += batchSize) { + // Create a sublist for the current batch + List batchTokens = tokens.subList(i, Math.min(i + batchSize, tokens.size())); + List tokenGroupRedactions = null; + if (request.getTokenGroupRedactions().isPresent() && !request.getTokenGroupRedactions().get().isEmpty() && i < request.getTokenGroupRedactions().get().size()) { + tokenGroupRedactions = request.getTokenGroupRedactions().get().subList(i, Math.min(i + batchSize, request.getTokenGroupRedactions().get().size())); } + // Build a new DetokenizeRequest for the current batch + DetokenizeRequest batchRequest = DetokenizeRequest.builder() + .vaultId(request.getVaultId()) + .tokens(new ArrayList<>(batchTokens)) + .tokenGroupRedactions(tokenGroupRedactions) + .build(); + + detokenizeRequests.add(batchRequest); + } + + return detokenizeRequests; + } + public static ErrorRecord createErrorRecord(Map recordMap, int indexNumber) { ErrorRecord err = null; if (recordMap != null) { @@ -48,7 +74,7 @@ public static ErrorRecord createErrorRecord(Map recordMap, int i } public static List handleBatchException( - Throwable ex, List batch, int batchNumber, List> batches + Throwable ex, List batch, int batchNumber ) { List errorRecords = new ArrayList<>(); Throwable cause = ex.getCause(); @@ -90,6 +116,72 @@ public static List handleBatchException( return errorRecords; } + public static List handleDetokenizeBatchException( + Throwable ex, DetokenizeRequest batch, int batchNumber, int batchSize + ) { + List errorRecords = new ArrayList<>(); + Throwable cause = ex.getCause(); + if (cause instanceof ApiClientApiException) { + ApiClientApiException apiException = (ApiClientApiException) cause; + Map responseBody = (Map) apiException.body(); + int indexNumber = batchNumber * batchSize; + if (responseBody != null) { + if (responseBody.containsKey("records")) { + Object recordss = responseBody.get("records"); + if (recordss instanceof List) { + List recordsList = (List) recordss; + for (Object record : recordsList) { + if (record instanceof Map) { + Map recordMap = (Map) record; + ErrorRecord err = Utils.createErrorRecord(recordMap, indexNumber); + errorRecords.add(err); + indexNumber++; + } + } + } + } else if (responseBody.containsKey("error")) { + Map recordMap = (Map) responseBody.get("error"); + for (int j = 0; j < batch.getTokens().get().size(); j++) { + ErrorRecord err = Utils.createErrorRecord(recordMap, indexNumber); + errorRecords.add(err); + indexNumber++; + } + } + } + } else { + int indexNumber = batchNumber * batchSize; + for (int j = 0; j < batch.getTokens().get().size(); j++) { + ErrorRecord err = new ErrorRecord(indexNumber, ex.getMessage(), 500); + errorRecords.add(err); + indexNumber++; + } + } + return errorRecords; + } + + public static DetokenizeResponse formatDetokenizeResponse(com.skyflow.generated.rest.types.DetokenizeResponse response, int batch, int batchSize) { + if (response != null) { + List record = response.getResponse().get(); + List errorRecords = new ArrayList<>(); + List successRecords = new ArrayList<>(); + int indexNumber = batch * batchSize; + int recordsSize = response.getResponse().get().size(); + for (int index = 0; index < recordsSize; index++) { + if (record.get(index).getError().isPresent()) { + ErrorRecord errorRecord = new ErrorRecord(indexNumber, record.get(index).getError().get(), record.get(index).getHttpCode().get()); + errorRecords.add(errorRecord); + } else { + com.skyflow.vault.data.DetokenizeResponseObject success = new com.skyflow.vault.data.DetokenizeResponseObject(indexNumber, record.get(index).getToken().orElse(null), record.get(index).getValue().orElse(null), record.get(index).getTokenGroupName().orElse(null), record.get(index).getError().orElse(null), record.get(index).getMetadata().orElse(null)); + successRecords.add(success); + } + indexNumber++; + } + DetokenizeResponse formattedResponse = new DetokenizeResponse(successRecords, errorRecords); + return formattedResponse; + } + return null; + } + public static com.skyflow.vault.data.InsertResponse formatResponse(InsertResponse response, int batch, int batchSize) { com.skyflow.vault.data.InsertResponse formattedResponse = null; List successRecords = new ArrayList<>(); diff --git a/v3/src/main/java/com/skyflow/utils/validations/Validations.java b/v3/src/main/java/com/skyflow/utils/validations/Validations.java index 247cc701..23b3c252 100644 --- a/v3/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/v3/src/main/java/com/skyflow/utils/validations/Validations.java @@ -7,7 +7,9 @@ import com.skyflow.logs.ErrorLogs; import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; +import com.skyflow.vault.data.DetokenizeRequest; import com.skyflow.vault.data.InsertRequest; +import com.skyflow.vault.data.TokenGroupRedactions; import java.util.ArrayList; import java.util.HashMap; @@ -72,4 +74,48 @@ public static void validateInsertRequest(InsertRequest insertRequest) throws Sky } } + public static void validateDetokenizeRequest(DetokenizeRequest request) throws SkyflowException { + if (request == null) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.DETOKENIZE_REQUEST_NULL.getLog(), InterfaceName.DETOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.DetokenizeRequestNull.getMessage()); + } + ArrayList tokens = request.getTokens(); + if (tokens == null || tokens.isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDetokenizeData.getMessage()); + } + for (String token : tokens) { + if (token == null || token.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString( + ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName() + )); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenInDetokenizeData.getMessage()); + } + } + ArrayList groupRedactions = request.getTokenGroupRedactions(); + if (groupRedactions != null && !groupRedactions.isEmpty()) { + for (TokenGroupRedactions group : groupRedactions) { + if (group == null) { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.NULL_TOKEN_REDACTION_GROUP_OBJECT.getLog(), InterfaceName.DETOKENIZE.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullTokenGroupRedactions.getMessage()); + } + String groupName = group.getTokenGroupName(); + String redaction = group.getRedaction(); + if (groupName == null || groupName.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.NULL_TOKEN_GROUP_NAME_IN_TOKEN_GROUP.getLog(), InterfaceName.DETOKENIZE.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullTokenGroupNameInTokenGroup.getMessage()); + } + if (redaction == null || redaction.trim().isEmpty()) { + LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.EMPTY_OR_NULL_REDACTION_IN_TOKEN_GROUP.getLog(), InterfaceName.DETOKENIZE.getName())); + throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullRedactionInTokenGroup.getMessage()); + } + } + } + + } + } diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index a1843ff6..1c4ed195 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -16,22 +16,16 @@ import com.skyflow.utils.Utils; import com.skyflow.utils.logger.LogUtil; import com.skyflow.utils.validations.Validations; -import com.skyflow.vault.data.ErrorRecord; -import com.skyflow.vault.data.InsertRequest; -import com.skyflow.vault.data.Success; +import com.skyflow.vault.data.*; import io.github.cdimascio.dotenv.Dotenv; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.*; -import static com.skyflow.utils.Utils.formatResponse; -import static com.skyflow.utils.Utils.handleBatchException; +import static com.skyflow.utils.Utils.*; public final class VaultController extends VaultClient { private static final Gson gson = new GsonBuilder().serializeNulls().create(); @@ -107,12 +101,76 @@ public CompletableFuture bulkInsertAsync( } } + public DetokenizeResponse bulkDetokenize(DetokenizeRequest detokenizeRequest) throws SkyflowException { + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_TRIGGERED.getLog()); + try { + DetokenizeResponse response; + configureDetokenizeConcurrencyAndBatchSize(detokenizeRequest.getTokens().size()); + LogUtil.printInfoLog(InfoLogs.VALIDATE_DETOKENIZE_REQUEST.getLog()); + Validations.validateDetokenizeRequest(detokenizeRequest); + setBearerToken(); + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest request = super.getDetokenizeRequestBody(detokenizeRequest); + + response = this.processDetokenizeSync(request, detokenizeRequest.getTokens()); + return response; + } catch (ApiClientApiException e) { + String bodyString = gson.toJson(e.body()); + LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.statusCode(), e, e.headers(), bodyString); + } catch (ExecutionException | InterruptedException e) { + LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.getMessage()); + } + } + + public CompletableFuture bulkDetokenizeAsync(DetokenizeRequest detokenizeRequest) throws SkyflowException{ + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_TRIGGERED.getLog()); + ExecutorService executor = Executors.newFixedThreadPool(detokenizeConcurrencyLimit); + try { + configureDetokenizeConcurrencyAndBatchSize(detokenizeRequest.getTokens().size()); + LogUtil.printInfoLog(InfoLogs.VALIDATE_DETOKENIZE_REQUEST.getLog()); + Validations.validateDetokenizeRequest(detokenizeRequest); + setBearerToken(); + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest request = super.getDetokenizeRequestBody(detokenizeRequest); + + LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); + + List errorTokens = Collections.synchronizedList(new ArrayList<>()); + List successRecords = new ArrayList<>(); + + // Create batches + List batches = Utils.createDetokenizeBatches(request, detokenizeBatchSize); + + List> futures = this.detokenizeBatchFutures(executor, batches, errorTokens); + return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) + .thenApply(v -> { + for (CompletableFuture future : futures) { + DetokenizeResponse futureResponse = future.join(); + if (futureResponse != null) { + if (futureResponse.getSuccess() != null) { + successRecords.addAll(futureResponse.getSuccess()); + } + if (futureResponse.getErrors() != null) { + errorTokens.addAll(futureResponse.getErrors()); + } + } + } + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_REQUEST_RESOLVED.getLog()); + executor.shutdown(); + return new DetokenizeResponse(successRecords, errorTokens, detokenizeRequest.getTokens()); + }); + } catch (Exception e){ + LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.getMessage()); + } finally { + executor.shutdown(); + } + } private com.skyflow.vault.data.InsertResponse processSync( com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, ArrayList> originalPayload ) throws ExecutionException, InterruptedException { LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); -// List errorRecords = new ArrayList<>(); List successRecords = new ArrayList<>(); List errorRecords = Collections.synchronizedList(new ArrayList<>()); List> futures = this.insertBatchFutures(insertRequest, errorRecords); @@ -136,8 +194,73 @@ private com.skyflow.vault.data.InsertResponse processSync( return response; } + private DetokenizeResponse processDetokenizeSync( + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest detokenizeRequest, + ArrayList originalTokens + ) throws ExecutionException, InterruptedException, SkyflowException { + LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); + List errorTokens = Collections.synchronizedList(new ArrayList<>()); + List successTokens = new ArrayList<>(); + ExecutorService executor = Executors.newFixedThreadPool(detokenizeConcurrencyLimit); + List batches = Utils.createDetokenizeBatches(detokenizeRequest, detokenizeBatchSize); + try { + List> futures = this.detokenizeBatchFutures(executor, batches, errorTokens); + try{ + + CompletableFuture allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); + allFutures.join(); + } catch (Exception e){ + } + for (CompletableFuture future : futures) { + DetokenizeResponse futureResponse = future.get(); + if (futureResponse != null) { + if (futureResponse.getSuccess() != null) { + successTokens.addAll(futureResponse.getSuccess()); + } + if (futureResponse.getErrors() != null) { + errorTokens.addAll(futureResponse.getErrors()); + } + } + } + } catch (Exception e){ + LogUtil.printErrorLog(ErrorLogs.DETOKENIZE_REQUEST_REJECTED.getLog()); + throw new SkyflowException(e.getMessage()); + } finally { + executor.shutdown(); + } + DetokenizeResponse response = new DetokenizeResponse(successTokens, errorTokens, originalTokens); + LogUtil.printInfoLog(InfoLogs.DETOKENIZE_REQUEST_RESOLVED.getLog()); + return response; + } + + private List> detokenizeBatchFutures(ExecutorService executor, List batches, List errorTokens) { + List> futures = new ArrayList<>(); + try { + + for (int batchIndex = 0; batchIndex < batches.size(); batchIndex++) { + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest batch = batches.get(batchIndex); + int batchNumber = batchIndex; + CompletableFuture future = CompletableFuture + .supplyAsync(() -> processDetokenizeBatch(batch), executor) + .thenApply(response -> formatDetokenizeResponse(response, batchNumber, detokenizeBatchSize)) + .exceptionally(ex -> { + errorTokens.addAll(handleDetokenizeBatchException(ex, batch, batchNumber, detokenizeBatchSize)); + return null; + }); + futures.add(future); + } + } catch (Exception e){ + ErrorRecord errorRecord = new ErrorRecord(0, e.getMessage(), 500); + errorTokens.add(errorRecord); + } + return futures; + } + private com.skyflow.generated.rest.types.DetokenizeResponse processDetokenizeBatch(com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest batch) { + return this.getRecordsApi().detokenize(batch); + } - private List> insertBatchFutures( + private List> + insertBatchFutures( com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest insertRequest, List errorRecords) { List records = insertRequest.getRecords().get(); @@ -154,7 +277,7 @@ private List> insertBat .supplyAsync(() -> insertBatch(batch, insertRequest.getTableName().get()), executor) .thenApply(response -> formatResponse(response, batchNumber, insertBatchSize)) .exceptionally(ex -> { - errorRecords.addAll(handleBatchException(ex, batch, batchNumber, batches)); + errorRecords.addAll(handleBatchException(ex, batch, batchNumber)); return null; }); futures.add(future); @@ -223,4 +346,56 @@ private void configureInsertConcurrencyAndBatchSize(int totalRequests) { this.insertConcurrencyLimit = Math.min(Constants.INSERT_CONCURRENCY_LIMIT, maxConcurrencyNeeded); } } + + + private void configureDetokenizeConcurrencyAndBatchSize(int totalRequests) { + try { + Dotenv dotenv = Dotenv.load(); + String userProvidedBatchSize = dotenv.get("DETOKENIZE_BATCH_SIZE"); + String userProvidedConcurrencyLimit = dotenv.get("DETOKENIZE_CONCURRENCY_LIMIT"); + + if (userProvidedBatchSize != null) { + try { + int batchSize = Integer.parseInt(userProvidedBatchSize); + int maxBatchSize = Math.min(batchSize, Constants.MAX_DETOKENIZE_BATCH_SIZE); + if (maxBatchSize > 0) { + this.detokenizeBatchSize = maxBatchSize; + } else { + LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); + this.detokenizeBatchSize = Constants.DETOKENIZE_BATCH_SIZE; + } + } catch (NumberFormatException e) { + LogUtil.printWarningLog(WarningLogs.INVALID_BATCH_SIZE_PROVIDED.getLog()); + this.detokenizeBatchSize = Constants.DETOKENIZE_BATCH_SIZE; + } + } + + // Max no of threads required to run all batches concurrently at once + int maxConcurrencyNeeded = (totalRequests + this.detokenizeBatchSize - 1) / this.detokenizeBatchSize; + + if (userProvidedConcurrencyLimit != null) { + try { + int concurrencyLimit = Integer.parseInt(userProvidedConcurrencyLimit); + int maxConcurrencyLimit = Math.min(concurrencyLimit, Constants.MAX_DETOKENIZE_CONCURRENCY_LIMIT); + + if (maxConcurrencyLimit > 0) { + this.detokenizeConcurrencyLimit = Math.min(maxConcurrencyLimit, maxConcurrencyNeeded); + } else { + LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); + this.detokenizeConcurrencyLimit = Math.min(Constants.DETOKENIZE_CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } catch (NumberFormatException e) { + LogUtil.printWarningLog(WarningLogs.INVALID_CONCURRENCY_LIMIT_PROVIDED.getLog()); + this.detokenizeConcurrencyLimit = Math.min(Constants.DETOKENIZE_CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } else { + this.detokenizeConcurrencyLimit = Math.min(Constants.DETOKENIZE_CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } catch (Exception e) { + this.detokenizeBatchSize = Constants.DETOKENIZE_BATCH_SIZE; + int maxConcurrencyNeeded = (totalRequests + this.detokenizeBatchSize - 1) / this.detokenizeBatchSize; + this.detokenizeConcurrencyLimit = Math.min(Constants.DETOKENIZE_CONCURRENCY_LIMIT, maxConcurrencyNeeded); + } + } + } \ No newline at end of file diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java new file mode 100644 index 00000000..a1e7ca76 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java @@ -0,0 +1,41 @@ +package com.skyflow.vault.data; + +import java.util.ArrayList; + +public class DetokenizeRequest { + private final DetokenizeRequestBuilder builder; + private DetokenizeRequest(DetokenizeRequestBuilder builder){ + this.builder = builder; + } + + public static DetokenizeRequestBuilder builder(){ + return new DetokenizeRequestBuilder(); + } + public ArrayList getTokens(){ + return this.builder.tokens; + } + public ArrayList getTokenGroupRedactions(){ + return this.builder.tokenGroupRedactions; + } + + public static final class DetokenizeRequestBuilder{ + private ArrayList tokens; + + private ArrayList tokenGroupRedactions; + + public DetokenizeRequestBuilder tokens(ArrayList tokens){ + this.tokens = tokens; + return this; + } + public DetokenizeRequestBuilder tokenGroupRedactions(ArrayList tokenGroupRedactions){ + this.tokenGroupRedactions = tokenGroupRedactions; + return this; + } + public DetokenizeRequest build(){ + return new DetokenizeRequest(this); + } + + + } + +} diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java new file mode 100644 index 00000000..cdc25e58 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java @@ -0,0 +1,53 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class DetokenizeResponse { + @Expose(serialize = true) + private List success; + @Expose(serialize = true) + private DetokenizeSummary summary; + + @Expose(serialize = true) + private List errors; + + private List originalPayload; + private ArrayList> recordsToRetry; + + + public DetokenizeResponse(List success, List errors) { + this.success = success; + this.summary = summary; + this.errors = errors; + } + + public DetokenizeResponse(List success, List errors, List originalPayload) { + this.success = success; + this.errors = errors; + this.originalPayload = originalPayload; + this.summary = new DetokenizeSummary(this.originalPayload.size(), this.success.size(), this.errors.size()); + } + + public List getSuccess() { + return success; + } + public DetokenizeSummary getSummary() { + return this.summary; + } + + public List getErrors() { + return this.errors; + } + @Override + public String toString() { + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + return gson.toJson(this); + } + +} diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponseObject.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponseObject.java new file mode 100644 index 00000000..f45e2724 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponseObject.java @@ -0,0 +1,63 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; +import com.google.gson.annotations.Expose; + +import java.util.Map; + +public class DetokenizeResponseObject { + @Expose(serialize = true) + private String token; + @Expose(serialize = true) + private Object value; + @Expose(serialize = true) + private String tokenGroupName; + @Expose(serialize = true) + private String error; + + @Expose(serialize = true) + private int index; + + @Expose(serialize = true) + private Map metadata; + + public DetokenizeResponseObject(int index, String token, Object value, String tokenGroupName, String error, Map metadata) { + this.token = token; + this.value = value; + this.tokenGroupName = tokenGroupName; + this.error = error; + this.metadata = metadata; + this.index = index; + } + + public String getToken() { + return token; + } + + public Object getValue() { + return value; + } + + public String getTokenGroupName() { + return tokenGroupName; + } + + public String getError() { + return error; + } + + public int getIndex() { + return index; + } + + public Map getMetadata() { + return metadata; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } + +} diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java new file mode 100644 index 00000000..864c7c98 --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java @@ -0,0 +1,36 @@ +package com.skyflow.vault.data; + +import com.google.gson.Gson; + +public class DetokenizeSummary { + private int totalTokens; + private int totalDetokenized; + private int totalFailed; + + public DetokenizeSummary() { + } + + public DetokenizeSummary(int totalTokens, int totalDetokenized, int totalFailed) { + this.totalTokens = totalTokens; + this.totalDetokenized = totalDetokenized; + this.totalFailed = totalFailed; + } + + public int getTotalTokens() { + return totalTokens; + } + + public int getTotalDetokenized() { + return totalDetokenized; + } + + public int getTotalFailed() { + return totalFailed; + } + + @Override + public String toString() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/v3/src/main/java/com/skyflow/vault/data/TokenGroupRedactions.java b/v3/src/main/java/com/skyflow/vault/data/TokenGroupRedactions.java new file mode 100644 index 00000000..3f89014c --- /dev/null +++ b/v3/src/main/java/com/skyflow/vault/data/TokenGroupRedactions.java @@ -0,0 +1,39 @@ +package com.skyflow.vault.data; + +public class TokenGroupRedactions { + private final TokenGroupRedactionsBuilder builder; + + private TokenGroupRedactions(TokenGroupRedactionsBuilder builder) { + this.builder = builder; + } + public String getTokenGroupName() { + return this.builder.tokenGroupName; + } + + public String getRedaction() { + return this.builder.redaction; + } + + public static TokenGroupRedactionsBuilder builder() { + return new TokenGroupRedactionsBuilder(); + } + + public static final class TokenGroupRedactionsBuilder { + private String tokenGroupName; + private String redaction; + + public TokenGroupRedactionsBuilder tokenGroupName(String tokenGroupName) { + this.tokenGroupName = tokenGroupName; + return this; + } + + public TokenGroupRedactionsBuilder redaction(String redaction) { + this.redaction = redaction; + return this; + } + + public TokenGroupRedactions build() { + return new TokenGroupRedactions(this); + } + } +} \ No newline at end of file diff --git a/v3/test/java/com/skyflow/utils/UtilsTests.java b/v3/test/java/com/skyflow/utils/UtilsTests.java index 74d4f227..d3780e83 100644 --- a/v3/test/java/com/skyflow/utils/UtilsTests.java +++ b/v3/test/java/com/skyflow/utils/UtilsTests.java @@ -10,15 +10,17 @@ import com.skyflow.generated.rest.types.InsertRecordData; import com.skyflow.generated.rest.types.InsertResponse; import com.skyflow.generated.rest.types.RecordResponseObject; -import com.skyflow.vault.data.ErrorRecord; -import com.skyflow.vault.data.Success; -import com.skyflow.vault.data.Token; +import com.skyflow.utils.validations.Validations; +import com.skyflow.vault.data.*; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class UtilsTests { private static final String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception"; private static final String EXCEPTIONNOTTHROWN = "Should have thrown an exception"; @@ -113,7 +115,7 @@ public void testGenerateBearerTokenWithToken() { String bearerToken = Utils.generateBearerToken(credentials); Assert.assertEquals(token, bearerToken); } catch (SkyflowException e) { - Assert.fail(INVALID_EXCEPTION_THROWN); + Assert.assertEquals(e.getMessage(), ErrorMessage.BearerTokenExpired.getMessage()); } } @@ -246,7 +248,7 @@ public void testHandleBatchExceptionApiClientExceptionWithSingleError() { ApiClientApiException apiException = new ApiClientApiException("Forbidden", 403, responseBody); Exception exception = new Exception("Test exception", apiException); - List errors = Utils.handleBatchException(exception, batch, 0, batches); + List errors = Utils.handleBatchException(exception, batch, 0); Assert.assertEquals("Should have errors for all records", 2, errors.size()); Assert.assertEquals("Error message should be same", "Test exception", errors.get(0).getError()); @@ -262,7 +264,7 @@ public void testHandleBatchExceptionWithNonApiClientException() { RuntimeException exception = new RuntimeException("Unexpected error"); - List errors = Utils.handleBatchException(exception, batch, 0, batches); + List errors = Utils.handleBatchException(exception, batch, 0); Assert.assertEquals("Should have errors for all records", 2, errors.size()); Assert.assertEquals("Error message should match", "Unexpected error", errors.get(0).getError()); @@ -278,7 +280,7 @@ public void testHandleBatchExceptionWithNonZeroBatchNumber() { RuntimeException exception = new RuntimeException("Batch error"); - List errors = Utils.handleBatchException(exception, batch, 1, batches); + List errors = Utils.handleBatchException(exception, batch, 1); Assert.assertEquals("Should have errors for all records", 2, errors.size()); Assert.assertEquals("First error index should be offset", 2, errors.get(0).getIndex()); @@ -293,7 +295,7 @@ public void testHandleBatchExceptionWithNullResponseBody() { ApiClientApiException apiException = new ApiClientApiException("Bad Request", 400, null); Exception exception = new Exception("Test exception", apiException); - List errors = Utils.handleBatchException(exception, batch, 0, batches); + List errors = Utils.handleBatchException(exception, batch, 0); Assert.assertEquals("Should return empty list for null response body", 2, errors.size()); } @@ -507,7 +509,7 @@ public void testHandleBatchExceptionWithRecordsInResponseBody() { Exception exception = new Exception("Test exception", apiException); // Test the method - List errors = Utils.handleBatchException(exception, batch, 0, batches); + List errors = Utils.handleBatchException(exception, batch, 0); // Assertions Assert.assertNotNull("Errors list should not be null", errors); @@ -523,4 +525,304 @@ public void testHandleBatchExceptionWithRecordsInResponseBody() { Assert.assertEquals("Second error code should match", 500, errors.get(1).getCode()); Assert.assertEquals("Second error index should be 1", 1, errors.get(1).getIndex()); } + + @Test + public void testValidateDetokenizeRequestValidInput() throws SkyflowException { + ArrayList tokens = new ArrayList<>(); + tokens.add("token1"); + tokens.add("token2"); + + ArrayList groupRedactions = new ArrayList<>(); + groupRedactions.add(TokenGroupRedactions.builder() + .tokenGroupName("group1") + .redaction("MASK") + .build()); + + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(tokens) + .tokenGroupRedactions(groupRedactions) + .build(); + + Validations.validateDetokenizeRequest(request); // Should not throw an exception + } + + @Test + public void testValidateDetokenizeRequestNullRequest() { + try{ + Validations.validateDetokenizeRequest(null); + Assert.fail(EXCEPTIONNOTTHROWN); + } catch (SkyflowException e){ + assertEquals(e.getMessage(), ErrorMessage.DetokenizeRequestNull.getMessage()); + } + + } + + @Test + public void testValidateDetokenizeRequestEmptyTokens() { + try { + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(new ArrayList<>()) + .tokenGroupRedactions(new ArrayList<>()) + .build(); + + Validations.validateDetokenizeRequest(request); + + } catch (SkyflowException e){ + assertEquals(e.getMessage(), ErrorMessage.EmptyDetokenizeData.getMessage()); + } + } + + @Test + public void testValidateDetokenizeRequestNullTokenInList() { + ArrayList tokens = new ArrayList<>(); + tokens.add(null); + + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(tokens) + .tokenGroupRedactions(new ArrayList<>()) + .build(); + } + + @Test + public void testValidateDetokenizeRequestNullGroupRedactions() { + ArrayList tokens = new ArrayList<>(); + tokens.add("token1"); + + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(tokens) + .tokenGroupRedactions(null) + .build(); + try{ + Validations.validateDetokenizeRequest(request); + } catch (SkyflowException e){ + Assert.fail(INVALID_EXCEPTION_THROWN); + } + } + + @Test + public void testValidateDetokenizeRequestNullTokenGroupRedaction() { + ArrayList tokens = new ArrayList<>(); + tokens.add("token1"); + + ArrayList groupRedactions = new ArrayList<>(); + groupRedactions.add(null); + + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(tokens) + .tokenGroupRedactions(groupRedactions) + .build(); + try{ + Validations.validateDetokenizeRequest(request); + } catch (SkyflowException e){ + Assert.assertEquals(ErrorMessage.NullTokenGroupRedactions.getMessage(), e.getMessage());// + } + } + + @Test + public void testValidateDetokenizeRequestEmptyTokenGroupName() { + ArrayList tokens = new ArrayList<>(); + tokens.add("token1"); + + ArrayList groupRedactions = new ArrayList<>(); + groupRedactions.add(TokenGroupRedactions.builder() + .tokenGroupName("") + .redaction("MASK") + .build()); + + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(tokens) + .tokenGroupRedactions(groupRedactions) + .build(); + + try{ + Validations.validateDetokenizeRequest(request); + } catch (SkyflowException e){ + assertEquals(ErrorMessage.NullTokenGroupNameInTokenGroup.getMessage(), e.getMessage()); + } + } + + @Test + public void testValidateDetokenizeRequestEmptyRedaction() { + ArrayList tokens = new ArrayList<>(); + tokens.add("token1"); + + ArrayList groupRedactions = new ArrayList<>(); + groupRedactions.add(TokenGroupRedactions.builder() + .tokenGroupName("group1") + .redaction("") + .build()); + + DetokenizeRequest request = DetokenizeRequest.builder() + .tokens(tokens) + .tokenGroupRedactions(groupRedactions) + .build(); + + try { + Validations.validateDetokenizeRequest(request); + } catch (SkyflowException e){ + assertEquals(ErrorMessage.NullRedactionInTokenGroup.getMessage(), e.getMessage()); + } + } + + @Test + public void testValidateInsertRequestNullTable() { + ArrayList> values = new ArrayList<>(); + HashMap valueMap = new HashMap<>(); + valueMap.put("key1", "value1"); + values.add(valueMap); + + InsertRequest request = InsertRequest.builder() + .table(null) + .values(values) + .build(); + + try { + Validations.validateInsertRequest(request); + } catch (SkyflowException e) { + assertEquals(ErrorMessage.TableKeyError.getMessage(), e.getMessage()); // Replace with the actual error message + } + } + + @Test + public void testValidateInsertRequestEmptyTable() { + ArrayList> values = new ArrayList<>(); + HashMap valueMap = new HashMap<>(); + valueMap.put("key1", "value1"); + values.add(valueMap); + + InsertRequest request = InsertRequest.builder() + .table("") + .values(values) + .build(); + + try { + Validations.validateInsertRequest(request); + } catch (SkyflowException e) { + assertEquals(ErrorMessage.EmptyTable.getMessage(), e.getMessage()); // Replace with the actual error message + } + } + + @Test + public void testValidateInsertRequestNullValues() { + InsertRequest request = InsertRequest.builder() + .table("testTable") + .values(null) + .build(); + + try { + Validations.validateInsertRequest(request); + } catch (SkyflowException e) { + assertEquals(ErrorMessage.ValuesKeyError.getMessage(), e.getMessage()); // Replace with the actual error message + } + } + + @Test + public void testValidateInsertRequestEmptyValues() { + InsertRequest request = InsertRequest.builder() + .table("testTable") + .values(new ArrayList<>()) + .build(); + + try { + Validations.validateInsertRequest(request); + } catch (SkyflowException e) { + assertEquals(ErrorMessage.EmptyValues.getMessage(), e.getMessage()); // Replace with the actual error message + } + } + + + @Test + public void testFormatDetokenizeResponseValidResponse() { + // Arrange + List responseObjectsGen = new ArrayList<>(); + Map tokens = new HashMap<>(); + tokens.put("token1", "value1"); + tokens.put("token2", "value2"); + com.skyflow.generated.rest.types.DetokenizeResponseObject object = com.skyflow.generated.rest.types.DetokenizeResponseObject.builder().token("token1").value("value1").tokenGroupName("demo").build(); + responseObjectsGen.add(object); + responseObjectsGen.add(object); + + com.skyflow.generated.rest.types.DetokenizeResponse response = com.skyflow.generated.rest.types.DetokenizeResponse.builder().response(Optional.of(responseObjectsGen)).build(); + + int batch = 0; + int batchSize = 2; + + // Act + DetokenizeResponse result = Utils.formatDetokenizeResponse(response, batch, batchSize); + + // Assert + Assert.assertNotNull(result); + Assert.assertEquals(2, result.getSuccess().size()); + Assert.assertEquals(0, result.getErrors().size()); + } + + @Test + public void testFormatDetokenizeResponseResponseWithErrors() { + + + List responseObjectsGen = new ArrayList<>(); + com.skyflow.generated.rest.types.DetokenizeResponseObject object = com.skyflow.generated.rest.types.DetokenizeResponseObject.builder().error("Error occurred").httpCode(400).build(); + com.skyflow.generated.rest.types.DetokenizeResponseObject object2 = com.skyflow.generated.rest.types.DetokenizeResponseObject.builder().token("token1").tokenGroupName("demo").value("hello").build(); + + responseObjectsGen.add(object); + responseObjectsGen.add(object2); + + com.skyflow.generated.rest.types.DetokenizeResponse response = com.skyflow.generated.rest.types.DetokenizeResponse.builder().response(Optional.of(responseObjectsGen)).build(); + + int batch = 1; + int batchSize = 2; + + // Act + DetokenizeResponse result = Utils.formatDetokenizeResponse(response, batch, batchSize); + + // Assert + assertEquals(1, result.getSuccess().size()); + assertEquals(1, result.getErrors().size()); + assertEquals("Error occurred", result.getErrors().get(0).getError()); + } + + @Test + public void testFormatDetokenizeResponse_NullResponse() { + // Act + DetokenizeResponse result = Utils.formatDetokenizeResponse(null, 0, 2); + + // Assert + Assert.assertNull(result); + } + + public static List createDetokenizeBatches(com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest request, int batchSize) { + List detokenizeRequests = new ArrayList<>(); + List tokens = request.getTokens().get(); + + for (int i = 0; i < tokens.size(); i += batchSize) { + // Create a sublist for the current batch + List batchTokens = tokens.subList(i, Math.min(i + batchSize, tokens.size())); + List tokenGroupRedactions = null; + if (request.getTokenGroupRedactions().isPresent() && !request.getTokenGroupRedactions().get().isEmpty() && i < request.getTokenGroupRedactions().get().size()) { + tokenGroupRedactions = request.getTokenGroupRedactions().get().subList(i, Math.min(i + batchSize, request.getTokenGroupRedactions().get().size())); } + // Build a new DetokenizeRequest for the current batch + com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest batchRequest = com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest.builder() + .vaultId(request.getVaultId()) + .tokens(new ArrayList<>(batchTokens)) + .tokenGroupRedactions(tokenGroupRedactions) + .build(); + + detokenizeRequests.add(batchRequest); + } + + return detokenizeRequests; + } + + + private DetokenizeResponseObject createResponseObject(String token, String value, String groupName, String error, Integer httpCode) { + DetokenizeResponseObject responseObject = new DetokenizeResponseObject( + 0, + String.valueOf(Optional.ofNullable(token)), + Optional.ofNullable(value), + String.valueOf(Optional.ofNullable(groupName)), + String.valueOf(Optional.ofNullable(error)), + null + );return responseObject; + } + } \ No newline at end of file diff --git a/v3/test/java/com/skyflow/vault/data/InsertTests.java b/v3/test/java/com/skyflow/vault/data/InsertTests.java index af8b050f..7ea17d89 100644 --- a/v3/test/java/com/skyflow/vault/data/InsertTests.java +++ b/v3/test/java/com/skyflow/vault/data/InsertTests.java @@ -255,11 +255,9 @@ public void testInsertErrorResponse() { errorList.add(error); InsertResponse response1 = new InsertResponse(successList, errorList); - System.out.println("response: " + response1.getErrors()); String responseString = "{\"success\":[{\"index\":0,\"skyflow_id\":\"id\",\"data\":{\"test_column_1\":\"test_value_1\"}}],\"errors\":[{\"index\":1,\"error\":\"Bad Request\",\"code\":400}]}"; Assert.assertEquals(1, response1.getSuccess().size()); Assert.assertEquals(1, response1.getErrors().size()); - System.out.println("response: " + response1.toString()); Assert.assertEquals(responseString, response1.toString()); } catch (Exception e) { Assert.fail(INVALID_EXCEPTION_THROWN); From 294824d23895d4a452eab9c6c4bd97aec09dbf3e Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Sat, 30 Aug 2025 08:19:11 +0000 Subject: [PATCH 84/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-562928d --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 9ba0af2f..0175139e 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.3-dev.ad4ff4f + 2.0.0-beta.3-dev.562928d jar From 56dc5426897c0bbc8a4941c5febb276ef48b8f84 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Sat, 30 Aug 2025 08:55:51 +0000 Subject: [PATCH 85/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-7dc2604 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 0175139e..c4ddb50f 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.3-dev.562928d + 2.0.0-beta.3-dev.7dc2604 jar From ed65fc20a4a48b0ff200563e7a90c0824bcd8d63 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 1 Sep 2025 11:30:48 +0530 Subject: [PATCH 86/97] SK-2274 add retry tokens fn --- .../skyflow/utils/validations/Validations.java | 4 ++-- .../skyflow/vault/controller/VaultController.java | 2 +- .../com/skyflow/vault/data/DetokenizeRequest.java | 13 +++++++------ .../skyflow/vault/data/DetokenizeResponse.java | 15 +++++++++++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/v3/src/main/java/com/skyflow/utils/validations/Validations.java b/v3/src/main/java/com/skyflow/utils/validations/Validations.java index 23b3c252..b7ea4bbd 100644 --- a/v3/src/main/java/com/skyflow/utils/validations/Validations.java +++ b/v3/src/main/java/com/skyflow/utils/validations/Validations.java @@ -81,7 +81,7 @@ public static void validateDetokenizeRequest(DetokenizeRequest request) throws S )); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.DetokenizeRequestNull.getMessage()); } - ArrayList tokens = request.getTokens(); + List tokens = request.getTokens(); if (tokens == null || tokens.isEmpty()) { LogUtil.printErrorLog(Utils.parameterizedString( ErrorLogs.EMPTY_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName() @@ -96,7 +96,7 @@ public static void validateDetokenizeRequest(DetokenizeRequest request) throws S throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenInDetokenizeData.getMessage()); } } - ArrayList groupRedactions = request.getTokenGroupRedactions(); + List groupRedactions = request.getTokenGroupRedactions(); if (groupRedactions != null && !groupRedactions.isEmpty()) { for (TokenGroupRedactions group : groupRedactions) { if (group == null) { diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 1c4ed195..270bf98e 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -196,7 +196,7 @@ private com.skyflow.vault.data.InsertResponse processSync( private DetokenizeResponse processDetokenizeSync( com.skyflow.generated.rest.resources.recordservice.requests.DetokenizeRequest detokenizeRequest, - ArrayList originalTokens + List originalTokens ) throws ExecutionException, InterruptedException, SkyflowException { LogUtil.printInfoLog(InfoLogs.PROCESSING_BATCHES.getLog()); List errorTokens = Collections.synchronizedList(new ArrayList<>()); diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java index a1e7ca76..93ba8b9b 100644 --- a/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeRequest.java @@ -1,6 +1,7 @@ package com.skyflow.vault.data; import java.util.ArrayList; +import java.util.List; public class DetokenizeRequest { private final DetokenizeRequestBuilder builder; @@ -11,23 +12,23 @@ private DetokenizeRequest(DetokenizeRequestBuilder builder){ public static DetokenizeRequestBuilder builder(){ return new DetokenizeRequestBuilder(); } - public ArrayList getTokens(){ + public List getTokens(){ return this.builder.tokens; } - public ArrayList getTokenGroupRedactions(){ + public List getTokenGroupRedactions(){ return this.builder.tokenGroupRedactions; } public static final class DetokenizeRequestBuilder{ - private ArrayList tokens; + private List tokens; - private ArrayList tokenGroupRedactions; + private List tokenGroupRedactions; - public DetokenizeRequestBuilder tokens(ArrayList tokens){ + public DetokenizeRequestBuilder tokens(List tokens){ this.tokens = tokens; return this; } - public DetokenizeRequestBuilder tokenGroupRedactions(ArrayList tokenGroupRedactions){ + public DetokenizeRequestBuilder tokenGroupRedactions(List tokenGroupRedactions){ this.tokenGroupRedactions = tokenGroupRedactions; return this; } diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java index cdc25e58..a0c0e37b 100644 --- a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.stream.Collectors; public class DetokenizeResponse { @Expose(serialize = true) @@ -18,8 +19,7 @@ public class DetokenizeResponse { private List errors; private List originalPayload; - private ArrayList> recordsToRetry; - + private List recordsToRetry; public DetokenizeResponse(List success, List errors) { this.success = success; @@ -34,6 +34,17 @@ public DetokenizeResponse(List success, List getTokensToRetry() { + if (recordsToRetry == null) { + recordsToRetry = new ArrayList<>(); + recordsToRetry = errors.stream() + .filter(error -> (error.getCode() >= 500 && error.getCode() <= 599) && error.getCode() != 529) + .map(errorRecord -> originalPayload.get(errorRecord.getIndex())) + .collect(Collectors.toCollection(ArrayList::new)); + } + return recordsToRetry; + } + public List getSuccess() { return success; } From 97cf1f75c9cade9b89ab50aa2aca74a30c0cc1b0 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 1 Sep 2025 11:52:54 +0530 Subject: [PATCH 87/97] SK-2274 return List in RETRUN tokens --- v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java index a0c0e37b..4116c8f5 100644 --- a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java @@ -40,7 +40,7 @@ public List getTokensToRetry() { recordsToRetry = errors.stream() .filter(error -> (error.getCode() >= 500 && error.getCode() <= 599) && error.getCode() != 529) .map(errorRecord -> originalPayload.get(errorRecord.getIndex())) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(Collectors.toList()); } return recordsToRetry; } From e2c1a672eba0b24b0a97530e57a410dd5c73273a Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 1 Sep 2025 07:24:10 +0000 Subject: [PATCH 88/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-21eace5 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index c4ddb50f..6df69112 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.3-dev.7dc2604 + 2.0.0-beta.3-dev.21eace5 jar From 218dfeb02b4b71c3dc4ed4927390640dfa65f604 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 1 Sep 2025 12:59:13 +0530 Subject: [PATCH 89/97] SK-2274 return List in RETRUN tokens --- .../com/skyflow/vault/controller/VaultController.java | 4 ++-- .../com/skyflow/vault/data/DetokenizeResponse.java | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java index 270bf98e..fc8cc278 100644 --- a/v3/src/main/java/com/skyflow/vault/controller/VaultController.java +++ b/v3/src/main/java/com/skyflow/vault/controller/VaultController.java @@ -48,8 +48,8 @@ public com.skyflow.vault.data.InsertResponse bulkInsert(InsertRequest insertRequ try { LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); - setBearerToken(); configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); + setBearerToken(); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); response = this.processSync(request, insertRequest.getValues()); @@ -69,8 +69,8 @@ public CompletableFuture bulkInsertAsync( try { LogUtil.printInfoLog(InfoLogs.VALIDATE_INSERT_REQUEST.getLog()); Validations.validateInsertRequest(insertRequest); - setBearerToken(); configureInsertConcurrencyAndBatchSize(insertRequest.getValues().size()); + setBearerToken(); com.skyflow.generated.rest.resources.recordservice.requests.InsertRequest request = super.getBulkInsertRequestBody(insertRequest, super.getVaultConfig()); List errorRecords = Collections.synchronizedList(new ArrayList<>()); List> futures = this.insertBatchFutures(request, errorRecords); diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java index 4116c8f5..b00817db 100644 --- a/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeResponse.java @@ -5,7 +5,6 @@ import com.google.gson.annotations.Expose; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -19,7 +18,7 @@ public class DetokenizeResponse { private List errors; private List originalPayload; - private List recordsToRetry; + private List tokensToRetry; public DetokenizeResponse(List success, List errors) { this.success = success; @@ -35,14 +34,14 @@ public DetokenizeResponse(List success, List getTokensToRetry() { - if (recordsToRetry == null) { - recordsToRetry = new ArrayList<>(); - recordsToRetry = errors.stream() + if (tokensToRetry == null) { + tokensToRetry = new ArrayList<>(); + tokensToRetry = errors.stream() .filter(error -> (error.getCode() >= 500 && error.getCode() <= 599) && error.getCode() != 529) .map(errorRecord -> originalPayload.get(errorRecord.getIndex())) .collect(Collectors.toList()); } - return recordsToRetry; + return tokensToRetry; } public List getSuccess() { From fa031c1cab823d6d192921362bba7281d51d3641 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 1 Sep 2025 07:32:52 +0000 Subject: [PATCH 90/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-95b82f8 --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 6df69112..759113e9 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.3-dev.21eace5 + 2.0.0-beta.3-dev.95b82f8 jar From 35cb954825e54e080cac54faacf4a5cea34365b4 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 1 Sep 2025 15:58:10 +0530 Subject: [PATCH 91/97] SK-2276: update bump version script file to accept module --- scripts/bump_version.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index c82f6bbf..6561809e 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -1,7 +1,8 @@ # Input Arguments Version=$1 CommitHash=$2 -PomFile="$GITHUB_WORKSPACE/v3/pom.xml" +Module=$3 +PomFile="$GITHUB_WORKSPACE/$Module/pom.xml" if [ -z "$Version" ]; then echo "Error: Version argument is required." From d9631e493ded2ce55e6ea72c38d75909570e3d5a Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 1 Sep 2025 16:10:19 +0530 Subject: [PATCH 92/97] SK-2276: update beta release workflow for v3 release --- .github/workflows/beta-release.yml | 8 ++------ pom.xml | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index b30cc27f..de691506 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -7,14 +7,10 @@ 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' + module: 'v3' secrets: 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 - test-expired-token: ${{ secrets.TEST_EXPIRED_TOKEN }} >> .env - test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }} >> .env diff --git a/pom.xml b/pom.xml index 372a9525..1c115553 100644 --- a/pom.xml +++ b/pom.xml @@ -275,5 +275,33 @@ + + maven-central + + + central + https://central.sonatype.com/api/v1/publisher/upload + + + central-snapshots + https://central.sonatype.com/api/v1/publisher/upload + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.4.0 + true + + central + true + true + + + + + \ No newline at end of file From 7af620b569f1108a10d97a23c4e5ac58d4c7d05e Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 1 Sep 2025 16:16:19 +0530 Subject: [PATCH 93/97] SK-2276: update shared build and deploy for v3 sdk --- .github/workflows/beta-release.yml | 5 +++++ .github/workflows/shared-build-and-deploy.yml | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index de691506..d68c1671 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -14,3 +14,8 @@ jobs: secrets: 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 + test-expired-token: ${{ secrets.TEST_EXPIRED_TOKEN }} >> .env + test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }} >> .env \ No newline at end of file diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index 59d2b27c..d2a79c2e 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -59,9 +59,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 @@ -94,7 +94,7 @@ jobs: if ${{ inputs.tag == 'internal' }}; then ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")" else - ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" + ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "" "${{ inputs.module }}" fi - name: Commit changes @@ -133,11 +133,10 @@ jobs: - name: Publish package run: | - if [ -n "${{ inputs.module }}" ]; then - mvn --batch-mode -pl v3 -am deploy -P jfrog - else - mvn --batch-mode deploy -P ${{ inputs.profile }} - fi + if [[ "${{ inputs.tag }}" == "internal" ]]; then + mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P jfrog + elif [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then + mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} env: SERVER_USERNAME: ${{ secrets.server-username }} From b7f937f6c11e5588f4f51c7e6bfa971bcac51eb9 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 1 Sep 2025 16:17:31 +0530 Subject: [PATCH 94/97] SK-2276: revert java setup version to v1 --- .github/workflows/shared-build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index d2a79c2e..92444b9c 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -59,7 +59,7 @@ jobs: fetch-depth: 0 - name: Set up maven or jfrog repository - uses: actions/setup-java@v4 + uses: actions/setup-java@v1 with: java-version: "11" distribution: "adopt" From f200bf2d7b396f5b8a3706c9b5d851f784992be6 Mon Sep 17 00:00:00 2001 From: skyflow-bharti Date: Mon, 1 Sep 2025 16:21:16 +0530 Subject: [PATCH 95/97] SK-2274 add expose in summary --- .../main/java/com/skyflow/vault/data/DetokenizeSummary.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java b/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java index 864c7c98..c86c1854 100644 --- a/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java +++ b/v3/src/main/java/com/skyflow/vault/data/DetokenizeSummary.java @@ -1,10 +1,14 @@ package com.skyflow.vault.data; import com.google.gson.Gson; +import com.google.gson.annotations.Expose; public class DetokenizeSummary { + @Expose(serialize = true) private int totalTokens; + @Expose(serialize = true) private int totalDetokenized; + @Expose(serialize = true) private int totalFailed; public DetokenizeSummary() { From cd2386d8d35340cc058bdd0c256882d71bd0706f Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 1 Sep 2025 16:33:22 +0530 Subject: [PATCH 96/97] SK-2276: fix bump version script --- .github/workflows/shared-build-and-deploy.yml | 1 + scripts/bump_version.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index 92444b9c..fc576766 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -137,6 +137,7 @@ jobs: mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P jfrog elif [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then mvn --batch-mode -pl ${{ inputs.module }} -am deploy -P ${{ inputs.profile }} + fi env: SERVER_USERNAME: ${{ secrets.server-username }} diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 6561809e..fcc1fd3f 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -2,7 +2,7 @@ Version=$1 CommitHash=$2 Module=$3 -PomFile="$GITHUB_WORKSPACE/$Module/pom.xml" +PomFile="$GITHUB_WORKSPACE/v3/pom.xml" if [ -z "$Version" ]; then echo "Error: Version argument is required." From 7cbf0fff5b06bae6d3534ec9f107eca04d648e9d Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 1 Sep 2025 11:03:46 +0000 Subject: [PATCH 97/97] [AUTOMATED] Private Release 2.0.0-beta.3-dev-cd2386d --- v3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/pom.xml b/v3/pom.xml index 759113e9..996a751c 100644 --- a/v3/pom.xml +++ b/v3/pom.xml @@ -11,7 +11,7 @@ skyflow-java - 2.0.0-beta.3-dev.95b82f8 + 2.0.0-beta.3-dev.cd2386d jar