diff --git a/README.md b/README.md index a5bce548..b50ef808 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The root `pom.xml` (`packaging=pom`) aggregates this Maven reactor: ## Documentation - [skyvault API Reference](docs/api_reference.md) — full list of request builder methods, response getters, enums, and service-account utilities +- [Detect API Reference](docs/api_reference.md#detect-api) — request, response, configuration and enum classes for Detect, shared by both SDKs - [Migrate from v1 to v2](docs/migrate_to_v2.md) ## Reporting a Vulnerability diff --git a/common/src/main/java/com/skyflow/BaseVaultClient.java b/common/src/main/java/com/skyflow/BaseVaultClient.java index ba53d00e..8fb94454 100644 --- a/common/src/main/java/com/skyflow/BaseVaultClient.java +++ b/common/src/main/java/com/skyflow/BaseVaultClient.java @@ -6,7 +6,7 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.BaseErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.ObjectMappers; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; import com.skyflow.serviceaccount.util.Token; diff --git a/common/src/main/java/com/skyflow/detect/RedactionLevel.java b/common/src/main/java/com/skyflow/detect/RedactionLevel.java index 74f04f1e..b10d1806 100644 --- a/common/src/main/java/com/skyflow/detect/RedactionLevel.java +++ b/common/src/main/java/com/skyflow/detect/RedactionLevel.java @@ -1,5 +1,7 @@ package com.skyflow.detect; +import com.skyflow.enums.RedactionType; + /** * Controls how one group of tokens is rendered when re-identifying. Supply exactly one source (entityName or tokenGroupName) and exactly one replacement (redactionType or redactionPattern). */ diff --git a/common/src/main/java/com/skyflow/detect/RedactionType.java b/common/src/main/java/com/skyflow/detect/RedactionType.java deleted file mode 100644 index 87b3e891..00000000 --- a/common/src/main/java/com/skyflow/detect/RedactionType.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.skyflow.detect; - -/** - * How a token is rendered when re-identifying (skyvault vaults). - */ -public enum RedactionType { - PLAIN_TEXT, - MASKED, - DEFAULT, - REDACTED; -} diff --git a/common/src/main/java/com/skyflow/detect/internal/DetectRequestMapper.java b/common/src/main/java/com/skyflow/detect/internal/DetectRequestMapper.java index 42ef0faf..8461eddb 100644 --- a/common/src/main/java/com/skyflow/detect/internal/DetectRequestMapper.java +++ b/common/src/main/java/com/skyflow/detect/internal/DetectRequestMapper.java @@ -31,36 +31,36 @@ import com.skyflow.errors.BaseErrorMessage; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.types.DeidentifyFileRequestV2DataFormat; -import com.skyflow.generated.detect.rest.resources.filesv2.types.DeidentifyFileRequestV2DataSource; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.types.DeidentifyFileRequestV2DataFormat; +import com.skyflow.generated.common.rest.resources.filesv2.types.DeidentifyFileRequestV2DataSource; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; import com.skyflow.logs.ErrorLogs; import com.skyflow.utils.BaseUtils; import com.skyflow.utils.logger.LogUtil; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.AudioV2; -import com.skyflow.generated.detect.rest.types.AudioV2Bleep; -import com.skyflow.generated.detect.rest.types.AudioV2OutputTranscription; -import com.skyflow.generated.detect.rest.types.DetectConfigV2; -import com.skyflow.generated.detect.rest.types.DetectCustomTypes; -import com.skyflow.generated.detect.rest.types.DetectEntity; -import com.skyflow.generated.detect.rest.types.DetectEntityDeidentificationType; -import com.skyflow.generated.detect.rest.types.DetectEntityEntityType; -import com.skyflow.generated.detect.rest.types.DetectObjectEntity; -import com.skyflow.generated.detect.rest.types.DetectObjectEntityDeidentificationType; -import com.skyflow.generated.detect.rest.types.DetectObjectEntityEntityType; -import com.skyflow.generated.detect.rest.types.DetectReturnEntities; -import com.skyflow.generated.detect.rest.types.DocumentV2; -import com.skyflow.generated.detect.rest.types.DocumentV2Pdf; -import com.skyflow.generated.detect.rest.types.DocumentV2PdfProcessingMode; -import com.skyflow.generated.detect.rest.types.EntityTransformation; -import com.skyflow.generated.detect.rest.types.ImageV2; -import com.skyflow.generated.detect.rest.types.ImageV2MaskingMethod; -import com.skyflow.generated.detect.rest.types.RedactionLevelEntityName; -import com.skyflow.generated.detect.rest.types.RedactionLevelRedactionType; -import com.skyflow.generated.detect.rest.types.TransformationShiftDates; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.AudioV2; +import com.skyflow.generated.common.rest.types.AudioV2Bleep; +import com.skyflow.generated.common.rest.types.AudioV2OutputTranscription; +import com.skyflow.generated.common.rest.types.DetectConfigV2; +import com.skyflow.generated.common.rest.types.DetectCustomTypes; +import com.skyflow.generated.common.rest.types.DetectEntity; +import com.skyflow.generated.common.rest.types.DetectEntityDeidentificationType; +import com.skyflow.generated.common.rest.types.DetectEntityEntityType; +import com.skyflow.generated.common.rest.types.DetectObjectEntity; +import com.skyflow.generated.common.rest.types.DetectObjectEntityDeidentificationType; +import com.skyflow.generated.common.rest.types.DetectObjectEntityEntityType; +import com.skyflow.generated.common.rest.types.DetectReturnEntities; +import com.skyflow.generated.common.rest.types.DocumentV2; +import com.skyflow.generated.common.rest.types.DocumentV2Pdf; +import com.skyflow.generated.common.rest.types.DocumentV2PdfProcessingMode; +import com.skyflow.generated.common.rest.types.EntityTransformation; +import com.skyflow.generated.common.rest.types.ImageV2; +import com.skyflow.generated.common.rest.types.ImageV2MaskingMethod; +import com.skyflow.generated.common.rest.types.RedactionLevelEntityName; +import com.skyflow.generated.common.rest.types.RedactionLevelRedactionType; +import com.skyflow.generated.common.rest.types.TransformationShiftDates; /** * Converts public SDK request models into generated V2 API requests. Internal to the SDK. @@ -178,9 +178,9 @@ public static DetectConfigV2 toDetectConfig(DetectConfiguration configuration, S return builder.build(); } - static com.skyflow.generated.detect.rest.types.Detect toDetect(Detect detect) { - com.skyflow.generated.detect.rest.types.Detect.Builder builder = - com.skyflow.generated.detect.rest.types.Detect.builder(); + static com.skyflow.generated.common.rest.types.Detect toDetect(Detect detect) { + com.skyflow.generated.common.rest.types.Detect.Builder builder = + com.skyflow.generated.common.rest.types.Detect.builder(); if (detect.getEntities() != null) { List entities = new ArrayList<>(); for (Entity entity : detect.getEntities()) { @@ -276,14 +276,14 @@ static DetectObjectEntity toObjectEntity(ObjectEntity objectEntity) { return builder.build(); } - static List toFileMappings(List fileMappings) { - List result = new ArrayList<>(); + static List toFileMappings(List fileMappings) { + List result = new ArrayList<>(); for (FileMapping mapping : fileMappings) { if (mapping == null) { continue; } - com.skyflow.generated.detect.rest.types.FileMapping.Builder builder = - com.skyflow.generated.detect.rest.types.FileMapping.builder(); + com.skyflow.generated.common.rest.types.FileMapping.Builder builder = + com.skyflow.generated.common.rest.types.FileMapping.builder(); if (mapping.getSource() != null) { builder.source(mapping.getSource()); } @@ -304,9 +304,9 @@ static List toFileMappings( return result; } - static com.skyflow.generated.detect.rest.types.Media toMedia(Media media) { - com.skyflow.generated.detect.rest.types.Media.Builder builder = - com.skyflow.generated.detect.rest.types.Media.builder(); + static com.skyflow.generated.common.rest.types.Media toMedia(Media media) { + com.skyflow.generated.common.rest.types.Media.Builder builder = + com.skyflow.generated.common.rest.types.Media.builder(); if (media.getAudio() != null) { builder.audio(toAudio(media.getAudio())); } @@ -380,14 +380,14 @@ static ImageV2 toImage(Image image) { return builder.build(); } - public static List toRedactionLevels(List levels) { - List result = new ArrayList<>(); + public static List toRedactionLevels(List levels) { + List result = new ArrayList<>(); for (RedactionLevel level : levels) { if (level == null) { continue; } - com.skyflow.generated.detect.rest.types.RedactionLevel.Builder builder = - com.skyflow.generated.detect.rest.types.RedactionLevel.builder(); + com.skyflow.generated.common.rest.types.RedactionLevel.Builder builder = + com.skyflow.generated.common.rest.types.RedactionLevel.builder(); if (level.getEntityName() != null) { builder.entityName(RedactionLevelEntityName.valueOf(level.getEntityName().name())); } diff --git a/common/src/main/java/com/skyflow/detect/internal/DetectResponseMapper.java b/common/src/main/java/com/skyflow/detect/internal/DetectResponseMapper.java index f4d2484b..9994ab70 100644 --- a/common/src/main/java/com/skyflow/detect/internal/DetectResponseMapper.java +++ b/common/src/main/java/com/skyflow/detect/internal/DetectResponseMapper.java @@ -13,12 +13,12 @@ import com.skyflow.detect.EntityLocation; import com.skyflow.detect.Metrics; import com.skyflow.detect.ReidentifyStringResponse; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2DetectedEntity; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2EntityLocation; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2DetectedEntity; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2EntityLocation; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; import java.util.ArrayList; import java.util.Collections; @@ -83,9 +83,9 @@ public static CheckGuardrailsResponse toCheckGuardrailsResponse(DetectGuardrails public static GetRunResponse toGetRunResponse(String runId, DetectRunsResponseV2 response) { List outputs = new ArrayList<>(); - List apiOutputs = response.getOutput().orElse(null); + List apiOutputs = response.getOutput().orElse(null); if (apiOutputs != null) { - for (com.skyflow.generated.detect.rest.types.FileOutput apiOutput : apiOutputs) { + for (com.skyflow.generated.common.rest.types.FileOutput apiOutput : apiOutputs) { if (apiOutput != null) { outputs.add(toFileOutput(apiOutput)); } @@ -112,7 +112,7 @@ public static DeidentifyFileResponse toDeidentifyFileResponse(String runId, GetR run.getMetrics(), run.getMessage()); } - public static FileOutput toFileOutput(com.skyflow.generated.detect.rest.types.FileOutput apiOutput) { + public static FileOutput toFileOutput(com.skyflow.generated.common.rest.types.FileOutput apiOutput) { return new FileOutput( apiOutput.getProcessedFile().orElse(null), apiOutput.getProcessedFileType().map(Object::toString).orElse(null), @@ -133,7 +133,7 @@ static > E enumOrDefault(Class type, String value, E fallba } } - public static Metrics toMetrics(com.skyflow.generated.detect.rest.types.Metrics metrics) { + public static Metrics toMetrics(com.skyflow.generated.common.rest.types.Metrics metrics) { return new Metrics( metrics.getSize().orElse(null), metrics.getWordCount().orElse(null), diff --git a/common/src/main/java/com/skyflow/detect/internal/ReidentifyFileMapper.java b/common/src/main/java/com/skyflow/detect/internal/ReidentifyFileMapper.java index d1653166..188f0013 100644 --- a/common/src/main/java/com/skyflow/detect/internal/ReidentifyFileMapper.java +++ b/common/src/main/java/com/skyflow/detect/internal/ReidentifyFileMapper.java @@ -5,10 +5,10 @@ import com.skyflow.detect.FileOutput; import com.skyflow.detect.ReidentifyFileRequest; import com.skyflow.detect.ReidentifyFileResponse; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.types.ReidentifyFileRequestV2DataFormat; -import com.skyflow.generated.detect.rest.resources.filesv2.types.ReidentifyFileRequestV2DataSource; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.types.ReidentifyFileRequestV2DataFormat; +import com.skyflow.generated.common.rest.resources.filesv2.types.ReidentifyFileRequestV2DataSource; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; import java.util.ArrayList; import java.util.Collections; @@ -39,9 +39,9 @@ public static ReidentifyFileRequestV2 toApiRequest(ReidentifyFileRequest request public static ReidentifyFileResponse toResponse(ReidentifyFileResponseV2 response) { List outputs = new ArrayList<>(); - List apiOutputs = response.getOutput().orElse(null); + List apiOutputs = response.getOutput().orElse(null); if (apiOutputs != null) { - for (com.skyflow.generated.detect.rest.types.FileOutput apiOutput : apiOutputs) { + for (com.skyflow.generated.common.rest.types.FileOutput apiOutput : apiOutputs) { if (apiOutput != null) { outputs.add(DetectResponseMapper.toFileOutput(apiOutput)); } diff --git a/common/src/main/java/com/skyflow/enums/RedactionType.java b/common/src/main/java/com/skyflow/enums/RedactionType.java new file mode 100644 index 00000000..c6feaa68 --- /dev/null +++ b/common/src/main/java/com/skyflow/enums/RedactionType.java @@ -0,0 +1,21 @@ +package com.skyflow.enums; + +/** + * How a stored value is rendered when it is read back. Shared by the skyvault vault operations + * ({@code get} and {@code detokenize}) and by Detect re-identification, where a + * {@code RedactionLevel} applies it to one entity type. + */ +public enum RedactionType { + PLAIN_TEXT, + MASKED, + DEFAULT, + REDACTED; + + /** + * @return the wire value, which is the constant name + */ + @Override + public String toString() { + return name(); + } +} diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/ApiClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/ApiClient.java deleted file mode 100644 index a1dd3aae..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/ApiClient.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest; - -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 { - 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/generated/auth/rest/ApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/auth/rest/ApiClientBuilder.java deleted file mode 100644 index aed3ed24..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/ApiClientBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest; - -import com.skyflow.generated.auth.rest.core.ClientOptions; -import com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClient.java deleted file mode 100644 index 748eb02e..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClient.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest; - -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 { - 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/generated/auth/rest/AsyncApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClientBuilder.java deleted file mode 100644 index 2e30d45a..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/AsyncApiClientBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest; - -import com.skyflow.generated.auth.rest.core.ClientOptions; -import com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientApiException.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientApiException.java deleted file mode 100644 index 53d67f0b..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientApiException.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest.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/common/src/main/java/com/skyflow/generated/auth/rest/core/ClientOptions.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ClientOptions.java deleted file mode 100644 index 4eee6b92..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ClientOptions.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest.core; - -import okhttp3.OkHttpClient; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; - -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.generated.rest.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/generated/auth/rest/core/DateTimeDeserializer.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/DateTimeDeserializer.java deleted file mode 100644 index dfa25a82..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/DateTimeDeserializer.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/core/ObjectMappers.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/ObjectMappers.java deleted file mode 100644 index 4997b3ca..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ObjectMappers.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/core/QueryStringMapper.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/QueryStringMapper.java deleted file mode 100644 index 8b1f9f7e..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/QueryStringMapper.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.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 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/common/src/main/java/com/skyflow/generated/auth/rest/core/RequestOptions.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/RequestOptions.java deleted file mode 100644 index b70c02df..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/RequestOptions.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/core/RetryInterceptor.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/RetryInterceptor.java deleted file mode 100644 index 8344b974..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/RetryInterceptor.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest.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/common/src/main/java/com/skyflow/generated/auth/rest/core/Stream.java b/common/src/main/java/com/skyflow/generated/auth/rest/core/Stream.java deleted file mode 100644 index 4a984faa..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/Stream.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/errors/BadRequestError.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/BadRequestError.java deleted file mode 100644 index 4517200d..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/errors/BadRequestError.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest.errors; - -import com.skyflow.generated.auth.rest.core.ApiClientApiException; -import okhttp3.Response; - -import java.util.Map; - -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 - */ - @Override - public Map body() { - return this.body; - } -} diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/errors/HttpStatus.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/HttpStatus.java deleted file mode 100644 index 2e1c45d2..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/errors/HttpStatus.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.skyflow.generated.auth.rest.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/generated/auth/rest/errors/UnauthorizedError.java b/common/src/main/java/com/skyflow/generated/auth/rest/errors/UnauthorizedError.java deleted file mode 100644 index 42f1c624..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/errors/UnauthorizedError.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.auth.rest.errors; - -import com.skyflow.generated.auth.rest.core.ApiClientApiException; -import okhttp3.Response; - -import java.util.Map; - -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 - */ - @Override - public Map body() { - return this.body; - } -} diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncAuthenticationClient.java deleted file mode 100644 index c742b239..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncAuthenticationClient.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -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.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AuthenticationClient.java deleted file mode 100644 index a0ba860a..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AuthenticationClient.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -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.resources.authentication.requests.V1GetAuthTokenRequest; -import com.skyflow.generated.auth.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/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/RawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/RawAuthenticationClient.java deleted file mode 100644 index 6c52c048..00000000 --- a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/RawAuthenticationClient.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -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.auth.rest.core.*; -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 okhttp3.*; - -import java.io.IOException; -import java.util.Map; - -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/generated/common/rest/ApiClient.java b/common/src/main/java/com/skyflow/generated/common/rest/ApiClient.java new file mode 100644 index 00000000..79634e85 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/ApiClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.Suppliers; +import com.skyflow.generated.common.rest.requests.PatchV2VaultsIdRequest; +import com.skyflow.generated.common.rest.resources.authentication.AuthenticationClient; +import com.skyflow.generated.common.rest.resources.filesv2.FilesV2Client; +import com.skyflow.generated.common.rest.resources.guardrailsv2.GuardrailsV2Client; +import com.skyflow.generated.common.rest.resources.stringsv2.StringsV2Client; +import com.skyflow.generated.common.rest.resources.tokenexchange.TokenExchangeClient; +import java.util.Optional; +import java.util.function.Supplier; + +public class ApiClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final RawApiClient rawClient; + + protected final Supplier authenticationClient; + + protected final Supplier tokenExchangeClient; + + protected final Supplier filesV2Client; + + protected final Supplier stringsV2Client; + + protected final Supplier guardrailsV2Client; + + public ApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawApiClient(clientOptions); + this.authenticationClient = Suppliers.memoize(() -> new AuthenticationClient(clientOptions)); + this.tokenExchangeClient = Suppliers.memoize(() -> new TokenExchangeClient(clientOptions)); + this.filesV2Client = Suppliers.memoize(() -> new FilesV2Client(clientOptions)); + this.stringsV2Client = Suppliers.memoize(() -> new StringsV2Client(clientOptions)); + this.guardrailsV2Client = Suppliers.memoize(() -> new GuardrailsV2Client(clientOptions)); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawApiClient withRawResponse() { + return this.rawClient; + } + + public void patchV2VaultsId(Optional vaultId) { + this.rawClient.patchV2VaultsId(vaultId).body(); + } + + public void patchV2VaultsId(Optional vaultId, RequestOptions requestOptions) { + this.rawClient.patchV2VaultsId(vaultId, requestOptions).body(); + } + + public void patchV2VaultsId(Optional vaultId, PatchV2VaultsIdRequest request) { + this.rawClient.patchV2VaultsId(vaultId, request).body(); + } + + public void patchV2VaultsId( + Optional vaultId, PatchV2VaultsIdRequest request, RequestOptions requestOptions) { + this.rawClient.patchV2VaultsId(vaultId, request, requestOptions).body(); + } + + public AuthenticationClient authentication() { + return this.authenticationClient.get(); + } + + public TokenExchangeClient tokenExchange() { + return this.tokenExchangeClient.get(); + } + + public FilesV2Client filesV2() { + return this.filesV2Client.get(); + } + + public StringsV2Client stringsV2() { + return this.stringsV2Client.get(); + } + + public GuardrailsV2Client guardrailsV2() { + return this.guardrailsV2Client.get(); + } + + /** + * Releases resources owned by this client. See {@code ClientOptions.close()} for what is + * and is not released. + */ + @Override + public void close() { + this.clientOptions.close(); + } + + public static ApiClientBuilder builder() { + return new ApiClientBuilder(); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/ApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/common/rest/ApiClientBuilder.java new file mode 100644 index 00000000..216c95fc --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/ApiClientBuilder.java @@ -0,0 +1,286 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.Environment; +import com.skyflow.generated.common.rest.core.LogConfig; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import okhttp3.OkHttpClient; + +public class ApiClientBuilder { + private Optional timeout = Optional.empty(); + + private Optional maxRetries = Optional.empty(); + + private Optional initialRetryDelayMillis = Optional.empty(); + + private Optional maxRetryDelayMillis = Optional.empty(); + + private Optional retryJitterFactor = Optional.empty(); + + private final Map customHeaders = new HashMap<>(); + + private String token = null; + + private Environment environment = Environment.PRODUCTION; + + private OkHttpClient httpClient; + + private Optional logging = Optional.empty(); + + private String vaultUrl; + + /** + * 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.timeout = Optional.of(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public ApiClientBuilder maxRetries(int maxRetries) { + this.maxRetries = Optional.of(maxRetries); + return this; + } + + /** + * Sets the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. + */ + public ApiClientBuilder initialRetryDelayMillis(long initialRetryDelayMillis) { + this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis); + return this; + } + + /** + * Sets the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds. + */ + public ApiClientBuilder maxRetryDelayMillis(long maxRetryDelayMillis) { + this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis); + return this; + } + + /** + * Sets the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2. + */ + public ApiClientBuilder retryJitterFactor(double retryJitterFactor) { + this.retryJitterFactor = Optional.of(retryJitterFactor); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public ApiClientBuilder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public ApiClientBuilder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public ApiClientBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + public ApiClientBuilder vaultUrl(String vaultUrl) { + this.vaultUrl = vaultUrl; + return this; + } + + protected ClientOptions buildClientOptions() { + ClientOptions.Builder builder = ClientOptions.builder(); + setEnvironment(builder); + setAuthentication(builder); + setHttpClient(builder); + setTimeouts(builder); + setRetries(builder); + setLogging(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + setAdditional(builder); + return builder.build(); + } + + /** + * Sets the environment configuration for the client. + * Override this method to modify URLs or add environment-specific logic. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setEnvironment(ClientOptions.Builder builder) { + if (this.vaultUrl != null) { + String _vaultUrl = this.vaultUrl != null ? this.vaultUrl : "{{vault_url}}"; + String _urlTemplate = null; + if (this.environment == null) { + _urlTemplate = "https://{vault_url}"; + } else if (this.environment.equals(Environment.PRODUCTION)) { + _urlTemplate = "https://{vault_url}"; + } else if (this.environment.equals(Environment.SANDBOX)) { + _urlTemplate = "https://{vault_url}"; + } + if (_urlTemplate != null) { + this.environment = Environment.custom(_urlTemplate.replace("{vault_url}", _vaultUrl)); + } + } + builder.environment(this.environment); + } + + /** + * Override this method to customize authentication. + * This method is called during client options construction to set up authentication headers. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAuthentication(ClientOptions.Builder builder) {
+     *     super.setAuthentication(builder); // Keep existing auth
+     *     builder.addHeader("X-API-Key", this.apiKey);
+     * }
+     * }
+ */ + protected void setAuthentication(ClientOptions.Builder builder) { + if (this.token != null) { + builder.addHeader("Authorization", "Bearer " + this.token); + } + } + + /** + * Sets the request timeout configuration. + * Override this method to customize timeout behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setTimeouts(ClientOptions.Builder builder) { + if (this.timeout.isPresent()) { + builder.timeout(this.timeout.get()); + } + } + + /** + * Sets the retry configuration for failed requests. + * Override this method to implement custom retry strategies. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setRetries(ClientOptions.Builder builder) { + if (this.maxRetries.isPresent()) { + builder.maxRetries(this.maxRetries.get()); + } + if (this.initialRetryDelayMillis.isPresent()) { + builder.initialRetryDelayMillis(this.initialRetryDelayMillis.get()); + } + if (this.maxRetryDelayMillis.isPresent()) { + builder.maxRetryDelayMillis(this.maxRetryDelayMillis.get()); + } + if (this.retryJitterFactor.isPresent()) { + builder.retryJitterFactor(this.retryJitterFactor.get()); + } + } + + /** + * Sets the OkHttp client configuration. + * Override this method to customize HTTP client behavior (interceptors, connection pools, etc). + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setHttpClient(ClientOptions.Builder builder) { + if (this.httpClient != null) { + builder.httpClient(this.httpClient); + } + } + + /** + * Sets the logging configuration for the SDK. + * Override this method to customize logging behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setLogging(ClientOptions.Builder builder) { + if (this.logging.isPresent()) { + builder.logging(this.logging.get()); + } + } + + /** + * Override this method to add any additional configuration to the client. + * This method is called at the end of the configuration chain, allowing you to add + * custom headers, modify settings, or perform any other client customization. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAdditional(ClientOptions.Builder builder) {
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Client-Version", "1.0.0");
+     * }
+     * }
+ */ + protected void setAdditional(ClientOptions.Builder builder) {} + + /** + * Override this method to add custom validation logic before the client is built. + * This method is called at the beginning of the build() method to ensure the configuration is valid. + * Throw an exception to prevent client creation if validation fails. + * + * Example: + *
{@code
+     * @Override
+     * protected void validateConfiguration() {
+     *     super.validateConfiguration(); // Run parent validations
+     *     if (tenantId == null || tenantId.isEmpty()) {
+     *         throw new IllegalStateException("tenantId is required");
+     *     }
+     * }
+     * }
+ */ + protected void validateConfiguration() {} + + public ApiClient build() { + validateConfiguration(); + return new ApiClient(buildClientOptions()); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/AsyncApiClient.java b/common/src/main/java/com/skyflow/generated/common/rest/AsyncApiClient.java new file mode 100644 index 00000000..dd931b70 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/AsyncApiClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.Suppliers; +import com.skyflow.generated.common.rest.requests.PatchV2VaultsIdRequest; +import com.skyflow.generated.common.rest.resources.authentication.AsyncAuthenticationClient; +import com.skyflow.generated.common.rest.resources.filesv2.AsyncFilesV2Client; +import com.skyflow.generated.common.rest.resources.guardrailsv2.AsyncGuardrailsV2Client; +import com.skyflow.generated.common.rest.resources.stringsv2.AsyncStringsV2Client; +import com.skyflow.generated.common.rest.resources.tokenexchange.AsyncTokenExchangeClient; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +public class AsyncApiClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final AsyncRawApiClient rawClient; + + protected final Supplier authenticationClient; + + protected final Supplier tokenExchangeClient; + + protected final Supplier filesV2Client; + + protected final Supplier stringsV2Client; + + protected final Supplier guardrailsV2Client; + + public AsyncApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawApiClient(clientOptions); + this.authenticationClient = Suppliers.memoize(() -> new AsyncAuthenticationClient(clientOptions)); + this.tokenExchangeClient = Suppliers.memoize(() -> new AsyncTokenExchangeClient(clientOptions)); + this.filesV2Client = Suppliers.memoize(() -> new AsyncFilesV2Client(clientOptions)); + this.stringsV2Client = Suppliers.memoize(() -> new AsyncStringsV2Client(clientOptions)); + this.guardrailsV2Client = Suppliers.memoize(() -> new AsyncGuardrailsV2Client(clientOptions)); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawApiClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture patchV2VaultsId(Optional vaultId) { + return this.rawClient.patchV2VaultsId(vaultId).thenApply(response -> response.body()); + } + + public CompletableFuture patchV2VaultsId(Optional vaultId, RequestOptions requestOptions) { + return this.rawClient.patchV2VaultsId(vaultId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture patchV2VaultsId(Optional vaultId, PatchV2VaultsIdRequest request) { + return this.rawClient.patchV2VaultsId(vaultId, request).thenApply(response -> response.body()); + } + + public CompletableFuture patchV2VaultsId( + Optional vaultId, PatchV2VaultsIdRequest request, RequestOptions requestOptions) { + return this.rawClient.patchV2VaultsId(vaultId, request, requestOptions).thenApply(response -> response.body()); + } + + public AsyncAuthenticationClient authentication() { + return this.authenticationClient.get(); + } + + public AsyncTokenExchangeClient tokenExchange() { + return this.tokenExchangeClient.get(); + } + + public AsyncFilesV2Client filesV2() { + return this.filesV2Client.get(); + } + + public AsyncStringsV2Client stringsV2() { + return this.stringsV2Client.get(); + } + + public AsyncGuardrailsV2Client guardrailsV2() { + return this.guardrailsV2Client.get(); + } + + /** + * Releases resources owned by this client. See {@code ClientOptions.close()} for what is + * and is not released. + */ + @Override + public void close() { + this.clientOptions.close(); + } + + public static AsyncApiClientBuilder builder() { + return new AsyncApiClientBuilder(); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/AsyncApiClientBuilder.java b/common/src/main/java/com/skyflow/generated/common/rest/AsyncApiClientBuilder.java new file mode 100644 index 00000000..c39617c4 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/AsyncApiClientBuilder.java @@ -0,0 +1,286 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.Environment; +import com.skyflow.generated.common.rest.core.LogConfig; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import okhttp3.OkHttpClient; + +public class AsyncApiClientBuilder { + private Optional timeout = Optional.empty(); + + private Optional maxRetries = Optional.empty(); + + private Optional initialRetryDelayMillis = Optional.empty(); + + private Optional maxRetryDelayMillis = Optional.empty(); + + private Optional retryJitterFactor = Optional.empty(); + + private final Map customHeaders = new HashMap<>(); + + private String token = null; + + private Environment environment = Environment.PRODUCTION; + + private OkHttpClient httpClient; + + private Optional logging = Optional.empty(); + + private String vaultUrl; + + /** + * 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.timeout = Optional.of(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public AsyncApiClientBuilder maxRetries(int maxRetries) { + this.maxRetries = Optional.of(maxRetries); + return this; + } + + /** + * Sets the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. + */ + public AsyncApiClientBuilder initialRetryDelayMillis(long initialRetryDelayMillis) { + this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis); + return this; + } + + /** + * Sets the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds. + */ + public AsyncApiClientBuilder maxRetryDelayMillis(long maxRetryDelayMillis) { + this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis); + return this; + } + + /** + * Sets the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2. + */ + public AsyncApiClientBuilder retryJitterFactor(double retryJitterFactor) { + this.retryJitterFactor = Optional.of(retryJitterFactor); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public AsyncApiClientBuilder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public AsyncApiClientBuilder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public AsyncApiClientBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + public AsyncApiClientBuilder vaultUrl(String vaultUrl) { + this.vaultUrl = vaultUrl; + return this; + } + + protected ClientOptions buildClientOptions() { + ClientOptions.Builder builder = ClientOptions.builder(); + setEnvironment(builder); + setAuthentication(builder); + setHttpClient(builder); + setTimeouts(builder); + setRetries(builder); + setLogging(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + setAdditional(builder); + return builder.build(); + } + + /** + * Sets the environment configuration for the client. + * Override this method to modify URLs or add environment-specific logic. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setEnvironment(ClientOptions.Builder builder) { + if (this.vaultUrl != null) { + String _vaultUrl = this.vaultUrl != null ? this.vaultUrl : "{{vault_url}}"; + String _urlTemplate = null; + if (this.environment == null) { + _urlTemplate = "https://{vault_url}"; + } else if (this.environment.equals(Environment.PRODUCTION)) { + _urlTemplate = "https://{vault_url}"; + } else if (this.environment.equals(Environment.SANDBOX)) { + _urlTemplate = "https://{vault_url}"; + } + if (_urlTemplate != null) { + this.environment = Environment.custom(_urlTemplate.replace("{vault_url}", _vaultUrl)); + } + } + builder.environment(this.environment); + } + + /** + * Override this method to customize authentication. + * This method is called during client options construction to set up authentication headers. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAuthentication(ClientOptions.Builder builder) {
+     *     super.setAuthentication(builder); // Keep existing auth
+     *     builder.addHeader("X-API-Key", this.apiKey);
+     * }
+     * }
+ */ + protected void setAuthentication(ClientOptions.Builder builder) { + if (this.token != null) { + builder.addHeader("Authorization", "Bearer " + this.token); + } + } + + /** + * Sets the request timeout configuration. + * Override this method to customize timeout behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setTimeouts(ClientOptions.Builder builder) { + if (this.timeout.isPresent()) { + builder.timeout(this.timeout.get()); + } + } + + /** + * Sets the retry configuration for failed requests. + * Override this method to implement custom retry strategies. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setRetries(ClientOptions.Builder builder) { + if (this.maxRetries.isPresent()) { + builder.maxRetries(this.maxRetries.get()); + } + if (this.initialRetryDelayMillis.isPresent()) { + builder.initialRetryDelayMillis(this.initialRetryDelayMillis.get()); + } + if (this.maxRetryDelayMillis.isPresent()) { + builder.maxRetryDelayMillis(this.maxRetryDelayMillis.get()); + } + if (this.retryJitterFactor.isPresent()) { + builder.retryJitterFactor(this.retryJitterFactor.get()); + } + } + + /** + * Sets the OkHttp client configuration. + * Override this method to customize HTTP client behavior (interceptors, connection pools, etc). + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setHttpClient(ClientOptions.Builder builder) { + if (this.httpClient != null) { + builder.httpClient(this.httpClient); + } + } + + /** + * Sets the logging configuration for the SDK. + * Override this method to customize logging behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setLogging(ClientOptions.Builder builder) { + if (this.logging.isPresent()) { + builder.logging(this.logging.get()); + } + } + + /** + * Override this method to add any additional configuration to the client. + * This method is called at the end of the configuration chain, allowing you to add + * custom headers, modify settings, or perform any other client customization. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAdditional(ClientOptions.Builder builder) {
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Client-Version", "1.0.0");
+     * }
+     * }
+ */ + protected void setAdditional(ClientOptions.Builder builder) {} + + /** + * Override this method to add custom validation logic before the client is built. + * This method is called at the beginning of the build() method to ensure the configuration is valid. + * Throw an exception to prevent client creation if validation fails. + * + * Example: + *
{@code
+     * @Override
+     * protected void validateConfiguration() {
+     *     super.validateConfiguration(); // Run parent validations
+     *     if (tenantId == null || tenantId.isEmpty()) {
+     *         throw new IllegalStateException("tenantId is required");
+     *     }
+     * }
+     * }
+ */ + protected void validateConfiguration() {} + + public AsyncApiClient build() { + validateConfiguration(); + return new AsyncApiClient(buildClientOptions()); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/AsyncRawApiClient.java b/common/src/main/java/com/skyflow/generated/common/rest/AsyncRawApiClient.java new file mode 100644 index 00000000..369c255e --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/AsyncRawApiClient.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.requests.PatchV2VaultsIdRequest; +import java.io.IOException; +import java.util.Optional; +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 AsyncRawApiClient { + protected final ClientOptions clientOptions; + + public AsyncRawApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> patchV2VaultsId(Optional vaultId) { + return patchV2VaultsId(vaultId, PatchV2VaultsIdRequest.builder().build()); + } + + public CompletableFuture> patchV2VaultsId( + Optional vaultId, RequestOptions requestOptions) { + return patchV2VaultsId(vaultId, PatchV2VaultsIdRequest.builder().build(), requestOptions); + } + + public CompletableFuture> patchV2VaultsId( + Optional vaultId, PatchV2VaultsIdRequest request) { + return patchV2VaultsId(vaultId, request, null); + } + + public CompletableFuture> patchV2VaultsId( + Optional vaultId, PatchV2VaultsIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/vaults"); + if (vaultId.isPresent()) { + httpUrl.addPathSegment(vaultId.get()); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new ApiClientApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new ApiClientException("Failed to deserialize response: " + e.getMessage(), e)); + } 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/generated/common/rest/RawApiClient.java b/common/src/main/java/com/skyflow/generated/common/rest/RawApiClient.java new file mode 100644 index 00000000..6777a1ca --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/RawApiClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.requests.PatchV2VaultsIdRequest; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawApiClient { + protected final ClientOptions clientOptions; + + public RawApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public ApiClientHttpResponse patchV2VaultsId(Optional vaultId) { + return patchV2VaultsId(vaultId, PatchV2VaultsIdRequest.builder().build()); + } + + public ApiClientHttpResponse patchV2VaultsId(Optional vaultId, RequestOptions requestOptions) { + return patchV2VaultsId(vaultId, PatchV2VaultsIdRequest.builder().build(), requestOptions); + } + + public ApiClientHttpResponse patchV2VaultsId(Optional vaultId, PatchV2VaultsIdRequest request) { + return patchV2VaultsId(vaultId, request, null); + } + + public ApiClientHttpResponse patchV2VaultsId( + Optional vaultId, PatchV2VaultsIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v2/vaults"); + if (vaultId.isPresent()) { + httpUrl.addPathSegment(vaultId.get()); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new ApiClientHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new ApiClientApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new ApiClientException("Network error executing HTTP request", e); + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientApiException.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientApiException.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientApiException.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientApiException.java index d864c404..ae75156d 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientApiException.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientApiException.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.ArrayList; import java.util.HashMap; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientException.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientException.java similarity index 88% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientException.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientException.java index f08afa2e..fdc44e9b 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientException.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientException.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.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/auth/rest/core/ApiClientHttpResponse.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientHttpResponse.java similarity index 94% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientHttpResponse.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientHttpResponse.java index 8a28d22f..aeefd9b6 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ApiClientHttpResponse.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ApiClientHttpResponse.java @@ -1,14 +1,13 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; - -import okhttp3.Response; +package com.skyflow.generated.common.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 { diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/ClientOptions.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ClientOptions.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/ClientOptions.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ClientOptions.java index cf61d5db..da903b21 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ClientOptions.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ClientOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.HashMap; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/ConsoleLogger.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ConsoleLogger.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/ConsoleLogger.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ConsoleLogger.java index e4feb843..dc14c66c 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ConsoleLogger.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ConsoleLogger.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.logging.Level; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/DateTimeDeserializer.java b/common/src/main/java/com/skyflow/generated/common/rest/core/DateTimeDeserializer.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/DateTimeDeserializer.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/DateTimeDeserializer.java index f2c9053a..c4a94049 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/DateTimeDeserializer.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/DateTimeDeserializer.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/DoubleSerializer.java b/common/src/main/java/com/skyflow/generated/common/rest/core/DoubleSerializer.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/DoubleSerializer.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/DoubleSerializer.java index 635869a6..6ede9fd7 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/DoubleSerializer.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/DoubleSerializer.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/Environment.java b/common/src/main/java/com/skyflow/generated/common/rest/core/Environment.java similarity index 80% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/Environment.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/Environment.java index 098667c0..00c25f17 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/Environment.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/Environment.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.rest.core; public final class Environment { - public static final Environment PRODUCTION = new Environment("https://manage.skyflowapis.com"); + public static final Environment PRODUCTION = new Environment("https://%7B%7Bvault_url%7D%7D"); - public static final Environment SANDBOX = new Environment("https://manage.skyflowapis-preview.com"); + public static final Environment SANDBOX = new Environment("https://%7B%7Bvault_url%7D%7D"); private final String url; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/FileStream.java b/common/src/main/java/com/skyflow/generated/common/rest/core/FileStream.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/FileStream.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/FileStream.java index 0e878ed3..760b574e 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/FileStream.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/FileStream.java @@ -1,15 +1,14 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.rest.core; +import java.io.InputStream; +import java.util.Objects; import okhttp3.MediaType; import okhttp3.RequestBody; import org.jetbrains.annotations.Nullable; -import java.io.InputStream; -import java.util.Objects; - /** * Represents a file stream with associated metadata for file uploads. */ diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/ILogger.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ILogger.java similarity index 95% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/ILogger.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ILogger.java index 0df7a4f5..340277a0 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ILogger.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ILogger.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; /** * Interface for custom logger implementations. diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/InputStreamRequestBody.java b/common/src/main/java/com/skyflow/generated/common/rest/core/InputStreamRequestBody.java similarity index 90% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/InputStreamRequestBody.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/InputStreamRequestBody.java index a94faec9..d22d2d05 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/InputStreamRequestBody.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/InputStreamRequestBody.java @@ -1,20 +1,18 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.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; -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, @@ -69,12 +67,8 @@ public long contentLength() throws IOException { */ @Override public void writeTo(BufferedSink sink) throws IOException { - Source source = null; - try { - source = Okio.source(inputStream); + try (Source source = Okio.source(inputStream)) { sink.writeAll(source); - } finally { - Util.closeQuietly(Objects.requireNonNull(source)); } } } diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/LogConfig.java b/common/src/main/java/com/skyflow/generated/common/rest/core/LogConfig.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/LogConfig.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/LogConfig.java index e613616b..8db7fe7a 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/LogConfig.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/LogConfig.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; /** * Configuration for SDK logging. diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/LogLevel.java b/common/src/main/java/com/skyflow/generated/common/rest/core/LogLevel.java similarity index 94% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/LogLevel.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/LogLevel.java index b37806c0..a6b8775e 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/LogLevel.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/LogLevel.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; /** * Log levels for SDK logging configuration. diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/Logger.java b/common/src/main/java/com/skyflow/generated/common/rest/core/Logger.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/Logger.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/Logger.java index 19a9d1fe..dd98e661 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/Logger.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/Logger.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; /** * SDK logger that filters messages based on level and silent mode. diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/LoggingInterceptor.java b/common/src/main/java/com/skyflow/generated/common/rest/core/LoggingInterceptor.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/LoggingInterceptor.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/LoggingInterceptor.java index 33c1d6aa..9e87fafb 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/LoggingInterceptor.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/LoggingInterceptor.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.io.IOException; import java.util.Arrays; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/MediaTypes.java b/common/src/main/java/com/skyflow/generated/common/rest/core/MediaTypes.java similarity index 84% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/MediaTypes.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/MediaTypes.java index d4374647..a4b5d490 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/MediaTypes.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/MediaTypes.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.rest.core; import okhttp3.MediaType; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/Nullable.java b/common/src/main/java/com/skyflow/generated/common/rest/core/Nullable.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/Nullable.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/Nullable.java index efabe806..c62bfb7e 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/Nullable.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/Nullable.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.Optional; import java.util.function.Function; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/NullableNonemptyFilter.java b/common/src/main/java/com/skyflow/generated/common/rest/core/NullableNonemptyFilter.java similarity index 67% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/NullableNonemptyFilter.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/NullableNonemptyFilter.java index dd32d66c..27a91ec4 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/NullableNonemptyFilter.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/NullableNonemptyFilter.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.Optional; @@ -14,6 +14,9 @@ public boolean equals(Object o) { } private boolean isOptionalEmpty(Object o) { - return o instanceof Optional && !((Optional) o).isPresent(); + if (o instanceof Optional) { + return !((Optional) o).isPresent(); + } + return false; } } diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/ObjectMappers.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ObjectMappers.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/ObjectMappers.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ObjectMappers.java index 7b4660ad..1d99d774 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ObjectMappers.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ObjectMappers.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/QueryStringMapper.java b/common/src/main/java/com/skyflow/generated/common/rest/core/QueryStringMapper.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/QueryStringMapper.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/QueryStringMapper.java index ba2dadc4..6a5091f9 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/QueryStringMapper.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/QueryStringMapper.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/RequestOptions.java b/common/src/main/java/com/skyflow/generated/common/rest/core/RequestOptions.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/RequestOptions.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/RequestOptions.java index 7f5ccea0..a3db26e4 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/RequestOptions.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/RequestOptions.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.HashMap; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyInputStream.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ResponseBodyInputStream.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyInputStream.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ResponseBodyInputStream.java index 1d0a9110..bcb4fc33 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyInputStream.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ResponseBodyInputStream.java @@ -1,12 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; - -import okhttp3.Response; +package com.skyflow.generated.common.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 diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyReader.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ResponseBodyReader.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyReader.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ResponseBodyReader.java index f4dfb17b..3d70a739 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/ResponseBodyReader.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ResponseBodyReader.java @@ -1,12 +1,11 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; - -import okhttp3.Response; +package com.skyflow.generated.common.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 diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/ResponseDecompressionInterceptor.java b/common/src/main/java/com/skyflow/generated/common/rest/core/ResponseDecompressionInterceptor.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/ResponseDecompressionInterceptor.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/ResponseDecompressionInterceptor.java index 9988a7fc..a9fe6502 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ResponseDecompressionInterceptor.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/ResponseDecompressionInterceptor.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.io.IOException; import java.util.zip.Inflater; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/core/RetryInterceptor.java b/common/src/main/java/com/skyflow/generated/common/rest/core/RetryInterceptor.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/core/RetryInterceptor.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/RetryInterceptor.java index c46a526e..17613132 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/RetryInterceptor.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/RetryInterceptor.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.core; +package com.skyflow.generated.common.rest.core; import java.io.IOException; import java.time.Duration; diff --git a/common/src/main/java/com/skyflow/generated/common/rest/core/Rfc2822DateTimeDeserializer.java b/common/src/main/java/com/skyflow/generated/common/rest/core/Rfc2822DateTimeDeserializer.java new file mode 100644 index 00000000..15272081 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/Rfc2822DateTimeDeserializer.java @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Custom deserializer that handles converting RFC 2822 (RFC 1123) dates into {@link OffsetDateTime} objects. + * This is used for fields with format "date-time-rfc-2822", such as Twilio's dateCreated, dateSent, dateUpdated. + */ +public class Rfc2822DateTimeDeserializer extends JsonDeserializer { + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + String raw = parser.getValueAsString(); + return ZonedDateTime.parse(raw, DateTimeFormatter.RFC_1123_DATE_TIME).toOffsetDateTime(); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/core/SseEvent.java b/common/src/main/java/com/skyflow/generated/common/rest/core/SseEvent.java new file mode 100644 index 00000000..f0ccf071 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/SseEvent.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.core; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.Optional; + +/** + * Represents a Server-Sent Event with all standard fields. + * Used for event-level discrimination where the discriminator is at the SSE envelope level. + * + * @param The type of the data field + */ +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonIgnoreProperties(ignoreUnknown = true) +public final class SseEvent { + private final String event; + private final T data; + private final String id; + private final Long retry; + + private SseEvent(String event, T data, String id, Long retry) { + this.event = event; + this.data = data; + this.id = id; + this.retry = retry; + } + + @JsonProperty("event") + public Optional getEvent() { + return Optional.ofNullable(event); + } + + @JsonProperty("data") + public T getData() { + return data; + } + + @JsonProperty("id") + public Optional getId() { + return Optional.ofNullable(id); + } + + @JsonProperty("retry") + public Optional getRetry() { + return Optional.ofNullable(retry); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SseEvent sseEvent = (SseEvent) o; + return Objects.equals(event, sseEvent.event) + && Objects.equals(data, sseEvent.data) + && Objects.equals(id, sseEvent.id) + && Objects.equals(retry, sseEvent.retry); + } + + @Override + public int hashCode() { + return Objects.hash(event, data, id, retry); + } + + @Override + public String toString() { + return "SseEvent{" + "event='" + + event + '\'' + ", data=" + + data + ", id='" + + id + '\'' + ", retry=" + + retry + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static final class Builder { + private String event; + private T data; + private String id; + private Long retry; + + private Builder() {} + + public Builder event(String event) { + this.event = event; + return this; + } + + public Builder data(T data) { + this.data = data; + return this; + } + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder retry(Long retry) { + this.retry = retry; + return this; + } + + public SseEvent build() { + return new SseEvent<>(event, data, id, retry); + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/core/SseEventParser.java b/common/src/main/java/com/skyflow/generated/common/rest/core/SseEventParser.java new file mode 100644 index 00000000..6380f93e --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/SseEventParser.java @@ -0,0 +1,228 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.core; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.core.type.TypeReference; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +/** + * Utility class for parsing Server-Sent Events with support for discriminated unions. + *

+ * Handles two discrimination patterns: + *

    + *
  1. Data-level discrimination: The discriminator (e.g., 'type') is inside the JSON data payload. + * Jackson's polymorphic deserialization handles this automatically.
  2. + *
  3. Event-level discrimination: The discriminator (e.g., 'event') is at the SSE envelope level. + * This requires constructing the full SSE envelope for Jackson to process.
  4. + *
+ */ +public final class SseEventParser { + + private static final Set SSE_ENVELOPE_FIELDS = new HashSet<>(Arrays.asList("event", "data", "id", "retry")); + + private SseEventParser() { + // Utility class + } + + /** + * Parse an SSE event using event-level discrimination. + *

+ * Constructs the full SSE envelope object with event, data, id, and retry fields, + * then deserializes it to the target union type. + * + * @param eventType The SSE event type (from event: field) + * @param data The SSE data content (from data: field) + * @param id The SSE event ID (from id: field), may be null + * @param retry The SSE retry value (from retry: field), may be null + * @param unionClass The target union class + * @param discriminatorProperty The property name used for discrimination (e.g., "event") + * @param The target type + * @return The deserialized object + */ + public static T parseEventLevelUnion( + String eventType, String data, String id, Long retry, Class unionClass, String discriminatorProperty) { + try { + // Determine if data should be parsed as JSON based on the variant's expected type + Object parsedData = parseDataForVariant(eventType, data, unionClass, discriminatorProperty); + + // Construct the SSE envelope object + Map envelope = new HashMap<>(); + envelope.put(discriminatorProperty, eventType); + envelope.put("data", parsedData); + if (id != null) { + envelope.put("id", id); + } + if (retry != null) { + envelope.put("retry", retry); + } + + // Serialize to JSON and deserialize to target type + String envelopeJson = ObjectMappers.JSON_MAPPER.writeValueAsString(envelope); + return ObjectMappers.JSON_MAPPER.readValue(envelopeJson, unionClass); + } catch (Exception e) { + throw new RuntimeException("Failed to parse SSE event with event-level discrimination", e); + } + } + + /** + * Parse an SSE event using data-level discrimination. + *

+ * Simply parses the data field as JSON and deserializes it to the target type. + * Jackson's polymorphic deserialization handles the discrimination automatically. + * + * @param data The SSE data content (from data: field) + * @param valueType The target type + * @param The target type + * @return The deserialized object + */ + public static T parseDataLevelUnion(String data, Class valueType) { + try { + return ObjectMappers.JSON_MAPPER.readValue(data, valueType); + } catch (Exception e) { + throw new RuntimeException("Failed to parse SSE data with data-level discrimination", e); + } + } + + /** + * Determines if the given discriminator property indicates event-level discrimination. + * Event-level discrimination occurs when the discriminator is an SSE envelope field. + * + * @param discriminatorProperty The discriminator property name + * @return true if event-level discrimination, false otherwise + */ + public static boolean isEventLevelDiscrimination(String discriminatorProperty) { + return SSE_ENVELOPE_FIELDS.contains(discriminatorProperty); + } + + /** + * Attempts to find the discriminator property from the union class's Jackson annotations. + * + * @param unionClass The union class to inspect + * @return The discriminator property name, or empty if not found + */ + public static Optional findDiscriminatorProperty(Class unionClass) { + try { + // Look for JsonTypeInfo on the class itself + JsonTypeInfo typeInfo = unionClass.getAnnotation(JsonTypeInfo.class); + if (typeInfo != null && !typeInfo.property().isEmpty()) { + return Optional.of(typeInfo.property()); + } + + // Look for inner Value interface with JsonTypeInfo + for (Class innerClass : unionClass.getDeclaredClasses()) { + typeInfo = innerClass.getAnnotation(JsonTypeInfo.class); + if (typeInfo != null && !typeInfo.property().isEmpty()) { + return Optional.of(typeInfo.property()); + } + } + } catch (Exception e) { + // Ignore reflection errors + } + return Optional.empty(); + } + + /** + * Parse the data field based on what the matching variant expects. + * If the variant expects a String for its data field, returns the raw string. + * Otherwise, parses the data as JSON. + */ + private static Object parseDataForVariant( + String eventType, String data, Class unionClass, String discriminatorProperty) { + if (data == null || data.isEmpty()) { + return data; + } + + try { + // Try to find the variant class that matches this event type + Class variantClass = findVariantClass(unionClass, eventType, discriminatorProperty); + if (variantClass != null) { + // Check if the variant expects a String for the data field + Field dataField = findField(variantClass, "data"); + if (dataField != null && String.class.equals(dataField.getType())) { + // Variant expects String - return raw data + return data; + } + } + + // Try to parse as JSON + return ObjectMappers.JSON_MAPPER.readValue(data, new TypeReference>() {}); + } catch (Exception e) { + // If JSON parsing fails, return as string + return data; + } + } + + /** + * Find the variant class that matches the given discriminator value. + */ + private static Class findVariantClass( + Class unionClass, String discriminatorValue, String discriminatorProperty) { + try { + // Look for JsonSubTypes annotation + JsonSubTypes subTypes = findJsonSubTypes(unionClass); + if (subTypes == null) { + return null; + } + + for (JsonSubTypes.Type subType : subTypes.value()) { + JsonTypeName typeName = subType.value().getAnnotation(JsonTypeName.class); + if (typeName != null && typeName.value().equals(discriminatorValue)) { + return subType.value(); + } + // Also check the name attribute of @JsonSubTypes.Type + if (subType.name().equals(discriminatorValue)) { + return subType.value(); + } + } + } catch (Exception e) { + // Ignore reflection errors + } + return null; + } + + /** + * Find JsonSubTypes annotation on the class or its inner classes. + */ + private static JsonSubTypes findJsonSubTypes(Class unionClass) { + // Check the class itself + JsonSubTypes subTypes = unionClass.getAnnotation(JsonSubTypes.class); + if (subTypes != null) { + return subTypes; + } + + // Check inner classes (for Fern-style unions with inner Value interface) + for (Class innerClass : unionClass.getDeclaredClasses()) { + subTypes = innerClass.getAnnotation(JsonSubTypes.class); + if (subTypes != null) { + return subTypes; + } + } + return null; + } + + /** + * Find a field by name in a class, including private fields. + */ + private static Field findField(Class clazz, String fieldName) { + try { + return clazz.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + // Check superclass + Class superClass = clazz.getSuperclass(); + if (superClass != null && superClass != Object.class) { + return findField(superClass, fieldName); + } + return null; + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/core/Stream.java b/common/src/main/java/com/skyflow/generated/common/rest/core/Stream.java new file mode 100644 index 00000000..1586718a --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/Stream.java @@ -0,0 +1,513 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.core; + +import java.io.Closeable; +import java.io.IOException; +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. + * Iterable stream for parsing JSON and Server-Sent Events (SSE) data. + * Supports both newline-delimited JSON and SSE with optional stream termination. + * + * @param The type of objects in the stream. + */ +public final class Stream implements Iterable, Closeable { + + private static final String NEWLINE = "\n"; + private static final String DATA_PREFIX = "data:"; + + public enum StreamType { + JSON, + SSE, + SSE_EVENT_DISCRIMINATED + } + + private final Class valueType; + private final Scanner scanner; + private final StreamType streamType; + private final String messageTerminator; + private final String streamTerminator; + private final Reader sseReader; + private final String discriminatorProperty; + private boolean isClosed = false; + + /** + * 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.valueType = valueType; + this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.streamType = StreamType.JSON; + this.messageTerminator = delimiter; + this.streamTerminator = null; + this.sseReader = null; + this.discriminatorProperty = null; + } + + private Stream(Class valueType, StreamType type, Reader reader, String terminator) { + this(valueType, type, reader, terminator, null); + } + + private Stream( + Class valueType, StreamType type, Reader reader, String terminator, String discriminatorProperty) { + this.valueType = valueType; + this.streamType = type; + this.discriminatorProperty = discriminatorProperty; + if (type == StreamType.JSON) { + this.scanner = new Scanner(reader).useDelimiter(terminator); + this.messageTerminator = terminator; + this.streamTerminator = null; + this.sseReader = null; + } else { + this.scanner = null; + this.messageTerminator = NEWLINE; + this.streamTerminator = terminator; + this.sseReader = reader; + } + } + + public static Stream fromJson(Class valueType, Reader reader, String delimiter) { + return new Stream<>(valueType, reader, delimiter); + } + + public static Stream fromJson(Class valueType, Reader reader) { + return new Stream<>(valueType, reader, NEWLINE); + } + + public static Stream fromSse(Class valueType, Reader sseReader) { + return new Stream<>(valueType, StreamType.SSE, sseReader, null); + } + + public static Stream fromSse(Class valueType, Reader sseReader, String streamTerminator) { + return new Stream<>(valueType, StreamType.SSE, sseReader, streamTerminator); + } + + /** + * Creates a stream from SSE data with event-level discrimination support. + * Use this when the SSE payload is a discriminated union where the discriminator + * is an SSE envelope field (e.g., 'event'). + * + * @param valueType The class of the objects in the stream. + * @param sseReader The reader that provides the SSE data. + * @param discriminatorProperty The property name used for discrimination (e.g., "event"). + * @param The type of objects in the stream. + * @return A new Stream instance configured for SSE with event-level discrimination. + */ + public static Stream fromSseWithEventDiscrimination( + Class valueType, Reader sseReader, String discriminatorProperty) { + return new Stream<>(valueType, StreamType.SSE_EVENT_DISCRIMINATED, sseReader, null, discriminatorProperty); + } + + /** + * Creates a stream from SSE data with event-level discrimination support and a stream terminator. + * + * @param valueType The class of the objects in the stream. + * @param sseReader The reader that provides the SSE data. + * @param discriminatorProperty The property name used for discrimination (e.g., "event"). + * @param streamTerminator The terminator string that signals end of stream (e.g., "[DONE]"). + * @param The type of objects in the stream. + * @return A new Stream instance configured for SSE with event-level discrimination. + */ + public static Stream fromSseWithEventDiscrimination( + Class valueType, Reader sseReader, String discriminatorProperty, String streamTerminator) { + return new Stream<>( + valueType, StreamType.SSE_EVENT_DISCRIMINATED, sseReader, streamTerminator, discriminatorProperty); + } + + @Override + public void close() throws IOException { + if (!isClosed) { + isClosed = true; + if (scanner != null) { + scanner.close(); + } + if (sseReader != null) { + sseReader.close(); + } + } + } + + private boolean isStreamClosed() { + return isClosed; + } + + /** + * 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() { + switch (streamType) { + case SSE: + return new SSEIterator(); + case SSE_EVENT_DISCRIMINATED: + return new SSEEventDiscriminatedIterator(); + case JSON: + default: + return new JsonIterator(); + } + } + + private final class JsonIterator implements 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() { + if (isStreamClosed()) { + return false; + } + 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 (isStreamClosed()) { + throw new NoSuchElementException("Stream is closed"); + } + + 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); + } + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + } + + private final class SSEIterator implements Iterator { + private Scanner sseScanner; + private T nextItem; + private boolean hasNextItem = false; + private boolean endOfStream = false; + private StringBuilder eventDataBuffer = new StringBuilder(); + private String currentEventType = null; + + private SSEIterator() { + if (sseReader != null && !isStreamClosed()) { + this.sseScanner = new Scanner(sseReader); + } else { + this.endOfStream = true; + } + } + + @Override + public boolean hasNext() { + if (isStreamClosed() || endOfStream) { + return false; + } + + if (hasNextItem) { + return true; + } + + return readNextMessage(); + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements in stream"); + } + + T result = nextItem; + nextItem = null; + hasNextItem = false; + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + private boolean readNextMessage() { + if (sseScanner == null || isStreamClosed()) { + endOfStream = true; + return false; + } + + try { + while (sseScanner.hasNextLine()) { + String line = sseScanner.nextLine(); + + if (line.trim().isEmpty()) { + if (eventDataBuffer.length() > 0) { + try { + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; + continue; + } + } + continue; + } + + if (line.startsWith(DATA_PREFIX)) { + String dataContent = line.substring(DATA_PREFIX.length()); + if (dataContent.startsWith(" ")) { + dataContent = dataContent.substring(1); + } + + if (eventDataBuffer.length() == 0 + && streamTerminator != null + && dataContent.trim().equals(streamTerminator)) { + endOfStream = true; + return false; + } + + if (eventDataBuffer.length() > 0) { + eventDataBuffer.append('\n'); + } + eventDataBuffer.append(dataContent); + } else if (line.startsWith("event:")) { + String eventValue = line.length() > 6 ? line.substring(6) : ""; + if (eventValue.startsWith(" ")) { + eventValue = eventValue.substring(1); + } + currentEventType = eventValue; + } else if (line.startsWith("id:")) { + // Event ID field (ignored) + } else if (line.startsWith("retry:")) { + // Retry field (ignored) + } else if (line.startsWith(":")) { + // Comment line (ignored) + } + } + + if (eventDataBuffer.length() > 0) { + try { + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse final SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; + } + } + + endOfStream = true; + return false; + + } catch (Exception e) { + System.err.println("Failed to parse SSE stream: " + e.getMessage()); + endOfStream = true; + return false; + } + } + } + + /** + * Iterator for SSE streams with event-level discrimination. + * Uses SseEventParser to construct the full SSE envelope for Jackson deserialization. + */ + private final class SSEEventDiscriminatedIterator implements Iterator { + private Scanner sseScanner; + private T nextItem; + private boolean hasNextItem = false; + private boolean endOfStream = false; + private StringBuilder eventDataBuffer = new StringBuilder(); + private String currentEventType = null; + private String currentEventId = null; + private Long currentRetry = null; + + private SSEEventDiscriminatedIterator() { + if (sseReader != null && !isStreamClosed()) { + this.sseScanner = new Scanner(sseReader); + } else { + this.endOfStream = true; + } + } + + @Override + public boolean hasNext() { + if (isStreamClosed() || endOfStream) { + return false; + } + + if (hasNextItem) { + return true; + } + + return readNextMessage(); + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements in stream"); + } + + T result = nextItem; + nextItem = null; + hasNextItem = false; + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + private boolean readNextMessage() { + if (sseScanner == null || isStreamClosed()) { + endOfStream = true; + return false; + } + + try { + while (sseScanner.hasNextLine()) { + String line = sseScanner.nextLine(); + + if (line.trim().isEmpty()) { + if (eventDataBuffer.length() > 0 || currentEventType != null) { + try { + // Use SseEventParser for event-level discrimination + nextItem = SseEventParser.parseEventLevelUnion( + currentEventType, + eventDataBuffer.toString(), + currentEventId, + currentRetry, + valueType, + discriminatorProperty); + hasNextItem = true; + resetEventState(); + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse SSE event: " + parseEx.getMessage()); + resetEventState(); + continue; + } + } + continue; + } + + if (line.startsWith(DATA_PREFIX)) { + String dataContent = line.substring(DATA_PREFIX.length()); + if (dataContent.startsWith(" ")) { + dataContent = dataContent.substring(1); + } + + if (eventDataBuffer.length() == 0 + && streamTerminator != null + && dataContent.trim().equals(streamTerminator)) { + endOfStream = true; + return false; + } + + if (eventDataBuffer.length() > 0) { + eventDataBuffer.append('\n'); + } + eventDataBuffer.append(dataContent); + } else if (line.startsWith("event:")) { + String eventValue = line.length() > 6 ? line.substring(6) : ""; + if (eventValue.startsWith(" ")) { + eventValue = eventValue.substring(1); + } + currentEventType = eventValue; + } else if (line.startsWith("id:")) { + String idValue = line.length() > 3 ? line.substring(3) : ""; + if (idValue.startsWith(" ")) { + idValue = idValue.substring(1); + } + currentEventId = idValue; + } else if (line.startsWith("retry:")) { + String retryValue = line.length() > 6 ? line.substring(6) : ""; + if (retryValue.startsWith(" ")) { + retryValue = retryValue.substring(1); + } + try { + currentRetry = Long.parseLong(retryValue.trim()); + } catch (NumberFormatException e) { + // Ignore invalid retry values + } + } else if (line.startsWith(":")) { + // Comment line (ignored) + } + } + + // Handle any remaining buffered data at end of stream + if (eventDataBuffer.length() > 0 || currentEventType != null) { + try { + nextItem = SseEventParser.parseEventLevelUnion( + currentEventType, + eventDataBuffer.toString(), + currentEventId, + currentRetry, + valueType, + discriminatorProperty); + hasNextItem = true; + resetEventState(); + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse final SSE event: " + parseEx.getMessage()); + resetEventState(); + } + } + + endOfStream = true; + return false; + + } catch (Exception e) { + System.err.println("Failed to parse SSE stream: " + e.getMessage()); + endOfStream = true; + return false; + } + } + + private void resetEventState() { + eventDataBuffer.setLength(0); + currentEventType = null; + currentEventId = null; + currentRetry = null; + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/core/Suppliers.java b/common/src/main/java/com/skyflow/generated/common/rest/core/Suppliers.java similarity index 92% rename from common/src/main/java/com/skyflow/generated/auth/rest/core/Suppliers.java rename to common/src/main/java/com/skyflow/generated/common/rest/core/Suppliers.java index d3ab5e53..a648cd99 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/core/Suppliers.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/core/Suppliers.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.core; +package com.skyflow.generated.common.rest.core; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/errors/BadRequestError.java b/common/src/main/java/com/skyflow/generated/common/rest/errors/BadRequestError.java similarity index 80% rename from common/src/main/java/com/skyflow/generated/detect/rest/errors/BadRequestError.java rename to common/src/main/java/com/skyflow/generated/common/rest/errors/BadRequestError.java index 7858ef63..1687be40 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/errors/BadRequestError.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/errors/BadRequestError.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.errors; +package com.skyflow.generated.common.rest.errors; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.types.ErrorResponse; import okhttp3.Response; public final class BadRequestError extends ApiClientApiException { diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/errors/InternalServerError.java b/common/src/main/java/com/skyflow/generated/common/rest/errors/InternalServerError.java similarity index 80% rename from common/src/main/java/com/skyflow/generated/detect/rest/errors/InternalServerError.java rename to common/src/main/java/com/skyflow/generated/common/rest/errors/InternalServerError.java index c21d7766..ef3a1b46 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/errors/InternalServerError.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/errors/InternalServerError.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.errors; +package com.skyflow.generated.common.rest.errors; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.types.ErrorResponse; import okhttp3.Response; public final class InternalServerError extends ApiClientApiException { diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/errors/NotFoundError.java b/common/src/main/java/com/skyflow/generated/common/rest/errors/NotFoundError.java similarity index 55% rename from common/src/main/java/com/skyflow/generated/auth/rest/errors/NotFoundError.java rename to common/src/main/java/com/skyflow/generated/common/rest/errors/NotFoundError.java index 60a1771c..bc8af4a3 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/errors/NotFoundError.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/errors/NotFoundError.java @@ -1,25 +1,24 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.errors; +package com.skyflow.generated.common.rest.errors; -import com.skyflow.generated.auth.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.types.ErrorResponse; import okhttp3.Response; -import java.util.Map; - public final class NotFoundError extends ApiClientApiException { /** * The body of the response that triggered the exception. */ - private final Map body; + private final ErrorResponse body; - public NotFoundError(Map body) { + public NotFoundError(ErrorResponse body) { super("NotFoundError", 404, body); this.body = body; } - public NotFoundError(Map body, Response rawResponse) { + public NotFoundError(ErrorResponse body, Response rawResponse) { super("NotFoundError", 404, body, rawResponse); this.body = body; } @@ -27,8 +26,8 @@ public NotFoundError(Map body, Response rawResponse) { /** * @return the body */ - @Override - public Map body() { + @java.lang.Override + public ErrorResponse body() { return this.body; } } diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/errors/UnauthorizedError.java b/common/src/main/java/com/skyflow/generated/common/rest/errors/UnauthorizedError.java similarity index 80% rename from common/src/main/java/com/skyflow/generated/detect/rest/errors/UnauthorizedError.java rename to common/src/main/java/com/skyflow/generated/common/rest/errors/UnauthorizedError.java index 63754690..0531cc88 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/errors/UnauthorizedError.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/errors/UnauthorizedError.java @@ -1,10 +1,10 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.errors; +package com.skyflow.generated.common.rest.errors; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.types.ErrorResponse; import okhttp3.Response; public final class UnauthorizedError extends ApiClientApiException { diff --git a/common/src/main/java/com/skyflow/generated/common/rest/requests/PatchV2VaultsIdRequest.java b/common/src/main/java/com/skyflow/generated/common/rest/requests/PatchV2VaultsIdRequest.java new file mode 100644 index 00000000..8ab5b295 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/requests/PatchV2VaultsIdRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.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.common.rest.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PatchV2VaultsIdRequest.Builder.class) +public final class PatchV2VaultsIdRequest { + private final Map additionalProperties; + + private PatchV2VaultsIdRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PatchV2VaultsIdRequest; + } + + @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(PatchV2VaultsIdRequest other) { + return this; + } + + public PatchV2VaultsIdRequest build() { + return new PatchV2VaultsIdRequest(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AsyncAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AsyncAuthenticationClient.java new file mode 100644 index 00000000..928f9c82 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AsyncAuthenticationClient.java @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.authentication; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.authentication.requests.GetAuthTokenRequest; +import com.skyflow.generated.common.rest.types.GetAuthTokenResponse; +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; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public CompletableFuture getBearerToken(GetAuthTokenRequest request) { + return this.rawClient.getBearerToken(request).thenApply(response -> response.body()); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public CompletableFuture getBearerToken( + GetAuthTokenRequest request, RequestOptions requestOptions) { + return this.rawClient.getBearerToken(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncRawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AsyncRawAuthenticationClient.java similarity index 51% rename from common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncRawAuthenticationClient.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AsyncRawAuthenticationClient.java index 56a47dc0..e4f780f4 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/AsyncRawAuthenticationClient.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AsyncRawAuthenticationClient.java @@ -1,22 +1,36 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.resources.authentication; +package com.skyflow.generated.common.rest.resources.authentication; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.skyflow.generated.auth.rest.core.*; -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 okhttp3.*; -import org.jetbrains.annotations.NotNull; - +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.NotFoundError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.authentication.requests.GetAuthTokenRequest; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.GetAuthTokenResponse; 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; @@ -26,22 +40,25 @@ public AsyncRawAuthenticationClient(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>

+ * Generates a Bearer Token to authenticate with Skyflow. */ - public CompletableFuture> authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request) { - return authenticationServiceGetAuthToken(request, null); + public CompletableFuture> getBearerToken(GetAuthTokenRequest request) { + return getBearerToken(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>

+ * Generates a Bearer Token to authenticate with Skyflow. */ - public CompletableFuture> authenticationServiceGetAuthToken( - V1GetAuthTokenRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> getBearerToken( + GetAuthTokenRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("v1/auth/sa/oauth/token") - .build(); + .addPathSegments("v1/auth/sa/oauth/token"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -50,7 +67,7 @@ public CompletableFuture> authenti throw new ApiClientException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -60,49 +77,60 @@ public CompletableFuture> authenti if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new ApiClientHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), V1GetAuthTokenResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAuthTokenResponse.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>() {}), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response)); return; case 401: future.completeExceptionally(new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response)); return; case 404: future.completeExceptionally(new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue( - responseBodyString, new TypeReference>() {}), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.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 } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new ApiClientApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new ApiClientException("Failed to deserialize response: " + e.getMessage(), e)); } catch (IOException e) { future.completeExceptionally(new ApiClientException("Network error executing HTTP request", e)); } diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AuthenticationClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AuthenticationClient.java new file mode 100644 index 00000000..b5143997 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/AuthenticationClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.authentication; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.authentication.requests.GetAuthTokenRequest; +import com.skyflow.generated.common.rest.types.GetAuthTokenResponse; + +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; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public GetAuthTokenResponse getBearerToken(GetAuthTokenRequest request) { + return this.rawClient.getBearerToken(request).body(); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public GetAuthTokenResponse getBearerToken(GetAuthTokenRequest request, RequestOptions requestOptions) { + return this.rawClient.getBearerToken(request, requestOptions).body(); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/RawAuthenticationClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/RawAuthenticationClient.java new file mode 100644 index 00000000..dba11478 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/RawAuthenticationClient.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.authentication; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.NotFoundError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.authentication.requests.GetAuthTokenRequest; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.GetAuthTokenResponse; +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; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public ApiClientHttpResponse getBearerToken(GetAuthTokenRequest request) { + return getBearerToken(request, null); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public ApiClientHttpResponse getBearerToken( + GetAuthTokenRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sa/oauth/token"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + 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.build()) + .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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAuthTokenResponse.class), response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new ApiClientApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new ApiClientException("Network error executing HTTP request", e); + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/requests/V1GetAuthTokenRequest.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/requests/GetAuthTokenRequest.java similarity index 68% rename from common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/requests/V1GetAuthTokenRequest.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/requests/GetAuthTokenRequest.java index 382c5431..65006de0 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/resources/authentication/requests/V1GetAuthTokenRequest.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/authentication/requests/GetAuthTokenRequest.java @@ -1,21 +1,26 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.resources.authentication.requests; - -import com.fasterxml.jackson.annotation.*; +package com.skyflow.generated.common.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.auth.rest.core.ObjectMappers; -import org.jetbrains.annotations.NotNull; - +import com.skyflow.generated.common.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 { +@JsonDeserialize(builder = GetAuthTokenRequest.Builder.class) +public final class GetAuthTokenRequest { private final String grantType; private final String assertion; @@ -30,7 +35,7 @@ public final class V1GetAuthTokenRequest { private final Map additionalProperties; - private V1GetAuthTokenRequest( + private GetAuthTokenRequest( String grantType, String assertion, Optional subjectToken, @@ -56,7 +61,7 @@ public String getGrantType() { } /** - * @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> + * @return User-signed JWT token that contains the following fields: iss (Issuer), key (Unique identifier), aud (Recipient), exp (Expiry), sub (Subject), ctx (Optional context for context-aware authorization). */ @JsonProperty("assertion") public String getAssertion() { @@ -88,17 +93,17 @@ public Optional getRequestedTokenUse() { } /** - * @return Subset of available <a href='#Roles'>roles</a> to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>". + * @return Subset of available roles to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>". */ @JsonProperty("scope") public Optional getScope() { return scope; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof V1GetAuthTokenRequest && equalTo((V1GetAuthTokenRequest) other); + return other instanceof GetAuthTokenRequest && equalTo((GetAuthTokenRequest) other); } @JsonAnyGetter @@ -106,7 +111,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(V1GetAuthTokenRequest other) { + private boolean equalTo(GetAuthTokenRequest other) { return grantType.equals(other.grantType) && assertion.equals(other.assertion) && subjectToken.equals(other.subjectToken) @@ -115,7 +120,7 @@ private boolean equalTo(V1GetAuthTokenRequest other) { && scope.equals(other.scope); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash( this.grantType, @@ -126,7 +131,7 @@ public int hashCode() { this.scope); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -137,22 +142,26 @@ public static GrantTypeStage builder() { public interface GrantTypeStage { /** - * 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.

*/ AssertionStage grantType(@NotNull String grantType); - Builder from(V1GetAuthTokenRequest other); + Builder from(GetAuthTokenRequest 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.
+ *

User-signed JWT token that contains the following fields: iss (Issuer), key (Unique identifier), aud (Recipient), exp (Expiry), sub (Subject), ctx (Optional context for context-aware authorization).

*/ _FinalStage assertion(@NotNull String assertion); } public interface _FinalStage { - V1GetAuthTokenRequest build(); + GetAuthTokenRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); /** *

Subject token.

@@ -176,7 +185,7 @@ public interface _FinalStage { _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>".

+ *

Subset of available roles to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

*/ _FinalStage scope(Optional scope); @@ -202,8 +211,8 @@ public static final class Builder implements GrantTypeStage, AssertionStage, _Fi private Builder() {} - @Override - public Builder from(V1GetAuthTokenRequest other) { + @java.lang.Override + public Builder from(GetAuthTokenRequest other) { grantType(other.getGrantType()); assertion(other.getAssertion()); subjectToken(other.getSubjectToken()); @@ -214,10 +223,10 @@ public Builder from(V1GetAuthTokenRequest other) { } /** - * 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.

+ *

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 + @java.lang.Override @JsonSetter("grant_type") public AssertionStage grantType(@NotNull String grantType) { this.grantType = Objects.requireNonNull(grantType, "grantType must not be null"); @@ -225,10 +234,10 @@ public AssertionStage grantType(@NotNull String grantType) { } /** - * 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>

+ *

User-signed JWT token that contains the following fields: iss (Issuer), key (Unique identifier), aud (Recipient), exp (Expiry), sub (Subject), ctx (Optional context for context-aware authorization).

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

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

+ *

Subset of available roles 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 + @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>".

+ *

Subset of available roles to associate with the requested token. Uses the format "role:<roleID1> role:<roleID2>".

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

Token use type. Either delegation or impersonation.

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

Token use type. Either delegation or impersonation.

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

Subject token type.

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

Subject token type.

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

Subject token.

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

Subject token.

*/ - @Override + @java.lang.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( + @java.lang.Override + public GetAuthTokenRequest build() { + return new GetAuthTokenRequest( grantType, assertion, subjectToken, @@ -326,5 +335,17 @@ public V1GetAuthTokenRequest build() { scope, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/AsyncFilesV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/AsyncFilesV2Client.java similarity index 86% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/AsyncFilesV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/AsyncFilesV2Client.java index c032d144..52e19e33 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/AsyncFilesV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/AsyncFilesV2Client.java @@ -1,16 +1,16 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2; +package com.skyflow.generated.common.rest.resources.filesv2; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.GetRunV2Request; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyFileResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.GetRunV2Request; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyFileResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; import java.util.concurrent.CompletableFuture; public class AsyncFilesV2Client { diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/AsyncRawFilesV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/AsyncRawFilesV2Client.java similarity index 93% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/AsyncRawFilesV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/AsyncRawFilesV2Client.java index 6764e32b..83e6c2cc 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/AsyncRawFilesV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/AsyncRawFilesV2Client.java @@ -1,28 +1,28 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2; +package com.skyflow.generated.common.rest.resources.filesv2; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.MediaTypes; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.QueryStringMapper; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.core.RetryInterceptor; -import com.skyflow.generated.detect.rest.errors.BadRequestError; -import com.skyflow.generated.detect.rest.errors.InternalServerError; -import com.skyflow.generated.detect.rest.errors.UnauthorizedError; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.GetRunV2Request; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyFileResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ErrorResponse; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.QueryStringMapper; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.GetRunV2Request; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyFileResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/FilesV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/FilesV2Client.java similarity index 84% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/FilesV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/FilesV2Client.java index 9f9f8c1a..60935ef7 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/FilesV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/FilesV2Client.java @@ -1,16 +1,16 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2; +package com.skyflow.generated.common.rest.resources.filesv2; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.GetRunV2Request; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyFileResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.GetRunV2Request; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyFileResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; public class FilesV2Client { protected final ClientOptions clientOptions; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/RawFilesV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/RawFilesV2Client.java similarity index 91% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/RawFilesV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/RawFilesV2Client.java index 2ffe352d..abe6815f 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/RawFilesV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/RawFilesV2Client.java @@ -1,28 +1,28 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2; +package com.skyflow.generated.common.rest.resources.filesv2; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.MediaTypes; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.QueryStringMapper; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.core.RetryInterceptor; -import com.skyflow.generated.detect.rest.errors.BadRequestError; -import com.skyflow.generated.detect.rest.errors.InternalServerError; -import com.skyflow.generated.detect.rest.errors.UnauthorizedError; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.GetRunV2Request; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyFileResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ErrorResponse; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.QueryStringMapper; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.GetRunV2Request; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyFileResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/DeidentifyFileRequestV2.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/DeidentifyFileRequestV2.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/DeidentifyFileRequestV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/DeidentifyFileRequestV2.java index f95ee7ab..99075ff3 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/DeidentifyFileRequestV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/DeidentifyFileRequestV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.requests; +package com.skyflow.generated.common.rest.resources.filesv2.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,10 +11,10 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.resources.filesv2.types.DeidentifyFileRequestV2DataFormat; -import com.skyflow.generated.detect.rest.resources.filesv2.types.DeidentifyFileRequestV2DataSource; -import com.skyflow.generated.detect.rest.types.DetectConfigV2; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.resources.filesv2.types.DeidentifyFileRequestV2DataFormat; +import com.skyflow.generated.common.rest.resources.filesv2.types.DeidentifyFileRequestV2DataSource; +import com.skyflow.generated.common.rest.types.DetectConfigV2; import java.util.HashMap; import java.util.Map; import java.util.Objects; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/GetRunV2Request.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/GetRunV2Request.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/GetRunV2Request.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/GetRunV2Request.java index f90f7153..93ff2521 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/GetRunV2Request.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/GetRunV2Request.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.requests; +package com.skyflow.generated.common.rest.resources.filesv2.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/resources/filesv2/requests/ReidentifyFileRequestV2.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/ReidentifyFileRequestV2.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/ReidentifyFileRequestV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/ReidentifyFileRequestV2.java index 29751862..6ab80a00 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/requests/ReidentifyFileRequestV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/requests/ReidentifyFileRequestV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.requests; +package com.skyflow.generated.common.rest.resources.filesv2.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,10 +11,10 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.resources.filesv2.types.ReidentifyFileRequestV2DataFormat; -import com.skyflow.generated.detect.rest.resources.filesv2.types.ReidentifyFileRequestV2DataSource; -import com.skyflow.generated.detect.rest.types.RedactionLevel; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.resources.filesv2.types.ReidentifyFileRequestV2DataFormat; +import com.skyflow.generated.common.rest.resources.filesv2.types.ReidentifyFileRequestV2DataSource; +import com.skyflow.generated.common.rest.types.RedactionLevel; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/DeidentifyFileRequestV2DataFormat.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/DeidentifyFileRequestV2DataFormat.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/DeidentifyFileRequestV2DataFormat.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/DeidentifyFileRequestV2DataFormat.java index 6a4aaf01..58b4f251 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/DeidentifyFileRequestV2DataFormat.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/DeidentifyFileRequestV2DataFormat.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.types; +package com.skyflow.generated.common.rest.resources.filesv2.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/DeidentifyFileRequestV2DataSource.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/DeidentifyFileRequestV2DataSource.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/DeidentifyFileRequestV2DataSource.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/DeidentifyFileRequestV2DataSource.java index 83c9aed3..af0f978a 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/DeidentifyFileRequestV2DataSource.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/DeidentifyFileRequestV2DataSource.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.types; +package com.skyflow.generated.common.rest.resources.filesv2.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/ReidentifyFileRequestV2DataFormat.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/ReidentifyFileRequestV2DataFormat.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/ReidentifyFileRequestV2DataFormat.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/ReidentifyFileRequestV2DataFormat.java index df3c688f..ea599b40 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/ReidentifyFileRequestV2DataFormat.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/ReidentifyFileRequestV2DataFormat.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.types; +package com.skyflow.generated.common.rest.resources.filesv2.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/ReidentifyFileRequestV2DataSource.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/ReidentifyFileRequestV2DataSource.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/ReidentifyFileRequestV2DataSource.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/ReidentifyFileRequestV2DataSource.java index 538cbc49..9c02024b 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/filesv2/types/ReidentifyFileRequestV2DataSource.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/filesv2/types/ReidentifyFileRequestV2DataSource.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.filesv2.types; +package com.skyflow.generated.common.rest.resources.filesv2.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/AsyncGuardrailsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/AsyncGuardrailsV2Client.java similarity index 81% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/AsyncGuardrailsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/AsyncGuardrailsV2Client.java index fe74a2d3..e59a3246 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/AsyncGuardrailsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/AsyncGuardrailsV2Client.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.guardrailsv2; +package com.skyflow.generated.common.rest.resources.guardrailsv2; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; import java.util.concurrent.CompletableFuture; public class AsyncGuardrailsV2Client { diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/AsyncRawGuardrailsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/AsyncRawGuardrailsV2Client.java similarity index 86% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/AsyncRawGuardrailsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/AsyncRawGuardrailsV2Client.java index c6b84c0e..8554afda 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/AsyncRawGuardrailsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/AsyncRawGuardrailsV2Client.java @@ -1,23 +1,23 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.guardrailsv2; +package com.skyflow.generated.common.rest.resources.guardrailsv2; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.MediaTypes; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.core.RetryInterceptor; -import com.skyflow.generated.detect.rest.errors.BadRequestError; -import com.skyflow.generated.detect.rest.errors.InternalServerError; -import com.skyflow.generated.detect.rest.errors.UnauthorizedError; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; -import com.skyflow.generated.detect.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.types.ErrorResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/GuardrailsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/GuardrailsV2Client.java similarity index 79% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/GuardrailsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/GuardrailsV2Client.java index 2d3a9bf7..98e0732f 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/GuardrailsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/GuardrailsV2Client.java @@ -1,12 +1,12 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.guardrailsv2; +package com.skyflow.generated.common.rest.resources.guardrailsv2; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; public class GuardrailsV2Client { protected final ClientOptions clientOptions; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/RawGuardrailsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/RawGuardrailsV2Client.java similarity index 83% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/RawGuardrailsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/RawGuardrailsV2Client.java index c124c516..102434d4 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/RawGuardrailsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/RawGuardrailsV2Client.java @@ -1,23 +1,23 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.guardrailsv2; +package com.skyflow.generated.common.rest.resources.guardrailsv2; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.MediaTypes; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.core.RetryInterceptor; -import com.skyflow.generated.detect.rest.errors.BadRequestError; -import com.skyflow.generated.detect.rest.errors.InternalServerError; -import com.skyflow.generated.detect.rest.errors.UnauthorizedError; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; -import com.skyflow.generated.detect.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.types.ErrorResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/requests/DetectGuardrailsRequestV2.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/requests/DetectGuardrailsRequestV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/requests/DetectGuardrailsRequestV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/requests/DetectGuardrailsRequestV2.java index f6d8dbad..17888dd9 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/guardrailsv2/requests/DetectGuardrailsRequestV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/guardrailsv2/requests/DetectGuardrailsRequestV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.guardrailsv2.requests; +package com.skyflow.generated.common.rest.resources.guardrailsv2.requests; 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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/resources/stringsv2/AsyncRawStringsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/AsyncRawStringsV2Client.java similarity index 91% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/AsyncRawStringsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/AsyncRawStringsV2Client.java index cac69231..554f1cbf 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/AsyncRawStringsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/AsyncRawStringsV2Client.java @@ -1,25 +1,25 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.stringsv2; +package com.skyflow.generated.common.rest.resources.stringsv2; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.MediaTypes; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.core.RetryInterceptor; -import com.skyflow.generated.detect.rest.errors.BadRequestError; -import com.skyflow.generated.detect.rest.errors.InternalServerError; -import com.skyflow.generated.detect.rest.errors.UnauthorizedError; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.ErrorResponse; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/AsyncStringsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/AsyncStringsV2Client.java similarity index 85% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/AsyncStringsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/AsyncStringsV2Client.java index 47c34f06..fd172616 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/AsyncStringsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/AsyncStringsV2Client.java @@ -1,14 +1,14 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.stringsv2; - -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +package com.skyflow.generated.common.rest.resources.stringsv2; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; import java.util.concurrent.CompletableFuture; public class AsyncStringsV2Client { diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/RawStringsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/RawStringsV2Client.java similarity index 89% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/RawStringsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/RawStringsV2Client.java index 61f71478..093b9f31 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/RawStringsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/RawStringsV2Client.java @@ -1,25 +1,25 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.stringsv2; +package com.skyflow.generated.common.rest.resources.stringsv2; import com.fasterxml.jackson.core.JsonProcessingException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ApiClientHttpResponse; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.MediaTypes; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.core.RetryInterceptor; -import com.skyflow.generated.detect.rest.errors.BadRequestError; -import com.skyflow.generated.detect.rest.errors.InternalServerError; -import com.skyflow.generated.detect.rest.errors.UnauthorizedError; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.ErrorResponse; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/StringsV2Client.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/StringsV2Client.java similarity index 83% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/StringsV2Client.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/StringsV2Client.java index 2a50d897..5cfa05b3 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/StringsV2Client.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/StringsV2Client.java @@ -1,14 +1,14 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.stringsv2; - -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +package com.skyflow.generated.common.rest.resources.stringsv2; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; public class StringsV2Client { protected final ClientOptions clientOptions; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/requests/DeidentifyStringRequestV2.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/requests/DeidentifyStringRequestV2.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/requests/DeidentifyStringRequestV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/requests/DeidentifyStringRequestV2.java index c3964a6d..8af6804c 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/requests/DeidentifyStringRequestV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/requests/DeidentifyStringRequestV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.stringsv2.requests; +package com.skyflow.generated.common.rest.resources.stringsv2.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,8 +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.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.types.DetectConfigV2; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.types.DetectConfigV2; import java.util.HashMap; import java.util.Map; import java.util.Objects; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/requests/ReidentifyStringRequestV2.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/requests/ReidentifyStringRequestV2.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/requests/ReidentifyStringRequestV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/requests/ReidentifyStringRequestV2.java index b242a87b..6d388058 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/resources/stringsv2/requests/ReidentifyStringRequestV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/stringsv2/requests/ReidentifyStringRequestV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.resources.stringsv2.requests; +package com.skyflow.generated.common.rest.resources.stringsv2.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -11,8 +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.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.types.RedactionLevel; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.types.RedactionLevel; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/AsyncRawTokenExchangeClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/AsyncRawTokenExchangeClient.java new file mode 100644 index 00000000..565e8649 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/AsyncRawTokenExchangeClient.java @@ -0,0 +1,146 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.tokenexchange; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.NotFoundError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.tokenexchange.requests.GetStsTokenRequest; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.GetStsTokenResponse; +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 AsyncRawTokenExchangeClient { + protected final ClientOptions clientOptions; + + public AsyncRawTokenExchangeClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public CompletableFuture> getStsToken(GetStsTokenRequest request) { + return getStsToken(request, null); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public CompletableFuture> getStsToken( + GetStsTokenRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sts/token"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + 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.build()) + .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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetStsTokenResponse.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new ApiClientApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new ApiClientException("Failed to deserialize response: " + e.getMessage(), e)); + } 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/generated/common/rest/resources/tokenexchange/AsyncTokenExchangeClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/AsyncTokenExchangeClient.java new file mode 100644 index 00000000..4ea687a8 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/AsyncTokenExchangeClient.java @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.tokenexchange; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.tokenexchange.requests.GetStsTokenRequest; +import com.skyflow.generated.common.rest.types.GetStsTokenResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTokenExchangeClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTokenExchangeClient rawClient; + + public AsyncTokenExchangeClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTokenExchangeClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTokenExchangeClient withRawResponse() { + return this.rawClient; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public CompletableFuture getStsToken(GetStsTokenRequest request) { + return this.rawClient.getStsToken(request).thenApply(response -> response.body()); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public CompletableFuture getStsToken( + GetStsTokenRequest request, RequestOptions requestOptions) { + return this.rawClient.getStsToken(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/RawTokenExchangeClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/RawTokenExchangeClient.java new file mode 100644 index 00000000..64051243 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/RawTokenExchangeClient.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.tokenexchange; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ApiClientHttpResponse; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.MediaTypes; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.core.RetryInterceptor; +import com.skyflow.generated.common.rest.errors.BadRequestError; +import com.skyflow.generated.common.rest.errors.InternalServerError; +import com.skyflow.generated.common.rest.errors.NotFoundError; +import com.skyflow.generated.common.rest.errors.UnauthorizedError; +import com.skyflow.generated.common.rest.resources.tokenexchange.requests.GetStsTokenRequest; +import com.skyflow.generated.common.rest.types.ErrorResponse; +import com.skyflow.generated.common.rest.types.GetStsTokenResponse; +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 RawTokenExchangeClient { + protected final ClientOptions clientOptions; + + public RawTokenExchangeClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public ApiClientHttpResponse getStsToken(GetStsTokenRequest request) { + return getStsToken(request, null); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public ApiClientHttpResponse getStsToken( + GetStsTokenRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v1/auth/sts/token"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + 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.build()) + .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); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new ApiClientHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetStsTokenResponse.class), response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorResponse.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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new ApiClientApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new ApiClientException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new ApiClientException("Network error executing HTTP request", e); + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/TokenExchangeClient.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/TokenExchangeClient.java new file mode 100644 index 00000000..c0eb551d --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/TokenExchangeClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.tokenexchange; + +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.tokenexchange.requests.GetStsTokenRequest; +import com.skyflow.generated.common.rest.types.GetStsTokenResponse; + +public class TokenExchangeClient { + protected final ClientOptions clientOptions; + + private final RawTokenExchangeClient rawClient; + + public TokenExchangeClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawTokenExchangeClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTokenExchangeClient withRawResponse() { + return this.rawClient; + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public GetStsTokenResponse getStsToken(GetStsTokenRequest request) { + return this.rawClient.getStsToken(request).body(); + } + + /** + * Generates a Bearer Token to authenticate with Skyflow. + */ + public GetStsTokenResponse getStsToken(GetStsTokenRequest request, RequestOptions requestOptions) { + return this.rawClient.getStsToken(request, requestOptions).body(); + } +} diff --git a/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/requests/GetStsTokenRequest.java b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/requests/GetStsTokenRequest.java new file mode 100644 index 00000000..2a12253d --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/resources/tokenexchange/requests/GetStsTokenRequest.java @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.rest.resources.tokenexchange.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.common.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 = GetStsTokenRequest.Builder.class) +public final class GetStsTokenRequest { + private final String grantType; + + private final String subjectToken; + + private final String subjectTokenType; + + private final String serviceAccountId; + + private final Map additionalProperties; + + private GetStsTokenRequest( + String grantType, + String subjectToken, + String subjectTokenType, + String serviceAccountId, + Map additionalProperties) { + this.grantType = grantType; + this.subjectToken = subjectToken; + this.subjectTokenType = subjectTokenType; + this.serviceAccountId = serviceAccountId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("grant_type") + public String getGrantType() { + return grantType; + } + + /** + * @return Subject token. + */ + @JsonProperty("subject_token") + public String getSubjectToken() { + return subjectToken; + } + + /** + * @return Subject token type. + */ + @JsonProperty("subject_token_type") + public String getSubjectTokenType() { + return subjectTokenType; + } + + @JsonProperty("service_account_id") + public String getServiceAccountId() { + return serviceAccountId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetStsTokenRequest && equalTo((GetStsTokenRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetStsTokenRequest other) { + return grantType.equals(other.grantType) + && subjectToken.equals(other.subjectToken) + && subjectTokenType.equals(other.subjectTokenType) + && serviceAccountId.equals(other.serviceAccountId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.grantType, this.subjectToken, this.subjectTokenType, this.serviceAccountId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static GrantTypeStage builder() { + return new Builder(); + } + + public interface GrantTypeStage { + SubjectTokenStage grantType(@NotNull String grantType); + + Builder from(GetStsTokenRequest other); + } + + public interface SubjectTokenStage { + /** + *

Subject token.

+ */ + SubjectTokenTypeStage subjectToken(@NotNull String subjectToken); + } + + public interface SubjectTokenTypeStage { + /** + *

Subject token type.

+ */ + ServiceAccountIdStage subjectTokenType(@NotNull String subjectTokenType); + } + + public interface ServiceAccountIdStage { + _FinalStage serviceAccountId(@NotNull String serviceAccountId); + } + + public interface _FinalStage { + GetStsTokenRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements GrantTypeStage, SubjectTokenStage, SubjectTokenTypeStage, ServiceAccountIdStage, _FinalStage { + private String grantType; + + private String subjectToken; + + private String subjectTokenType; + + private String serviceAccountId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetStsTokenRequest other) { + grantType(other.getGrantType()); + subjectToken(other.getSubjectToken()); + subjectTokenType(other.getSubjectTokenType()); + serviceAccountId(other.getServiceAccountId()); + return this; + } + + @java.lang.Override + @JsonSetter("grant_type") + public SubjectTokenStage grantType(@NotNull String grantType) { + this.grantType = Objects.requireNonNull(grantType, "grantType must not be null"); + return this; + } + + /** + *

Subject token.

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

Subject token type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("subject_token_type") + public ServiceAccountIdStage subjectTokenType(@NotNull String subjectTokenType) { + this.subjectTokenType = Objects.requireNonNull(subjectTokenType, "subjectTokenType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("service_account_id") + public _FinalStage serviceAccountId(@NotNull String serviceAccountId) { + this.serviceAccountId = Objects.requireNonNull(serviceAccountId, "serviceAccountId must not be null"); + return this; + } + + @java.lang.Override + public GetStsTokenRequest build() { + return new GetStsTokenRequest( + grantType, subjectToken, subjectTokenType, serviceAccountId, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2.java index eb4be5de..c0ef0619 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/AudioV2Bleep.java b/common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2Bleep.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2Bleep.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2Bleep.java index eb234230..39360814 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2Bleep.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2Bleep.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/AudioV2OutputTranscription.java b/common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2OutputTranscription.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2OutputTranscription.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2OutputTranscription.java index 9d48255f..4ac533ec 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/AudioV2OutputTranscription.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/AudioV2OutputTranscription.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyFileResponseV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyFileResponseV2.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyFileResponseV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyFileResponseV2.java index fa5b77eb..e4c88a65 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyFileResponseV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyFileResponseV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DeidentifyStringResponseV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyStringResponseV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2.java index eb0eca2d..7c1d3020 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyStringResponseV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DeidentifyStringResponseV2DetectedEntity.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2DetectedEntity.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyStringResponseV2DetectedEntity.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2DetectedEntity.java index e3bf15bd..c7843117 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyStringResponseV2DetectedEntity.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2DetectedEntity.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DeidentifyStringResponseV2EntityLocation.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2EntityLocation.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyStringResponseV2EntityLocation.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2EntityLocation.java index 6ac6a633..bf75e2d5 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DeidentifyStringResponseV2EntityLocation.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DeidentifyStringResponseV2EntityLocation.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/Detect.java b/common/src/main/java/com/skyflow/generated/common/rest/types/Detect.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/Detect.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/Detect.java index 4935b1d0..ae1dfb15 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/Detect.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/Detect.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectConfigV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectConfigV2.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectConfigV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectConfigV2.java index 77f00c81..81efd72b 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectConfigV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectConfigV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectConfigV2VaultType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectConfigV2VaultType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectConfigV2VaultType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectConfigV2VaultType.java index 4249b6a3..89bdcd78 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectConfigV2VaultType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectConfigV2VaultType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectCustomTypes.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectCustomTypes.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectCustomTypes.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectCustomTypes.java index a4db8e7c..32a6f56f 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectCustomTypes.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectCustomTypes.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectEntity.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntity.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntity.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntity.java index 472e7044..76a4216c 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntity.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntity.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectEntityDeidentificationType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntityDeidentificationType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntityDeidentificationType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntityDeidentificationType.java index 26262dce..aa338a0f 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntityDeidentificationType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntityDeidentificationType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntityEntityType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntityEntityType.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntityEntityType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntityEntityType.java index 7e286cfc..91ea6f18 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectEntityEntityType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectEntityEntityType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectGuardrailsResponseV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectGuardrailsResponseV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectGuardrailsResponseV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectGuardrailsResponseV2.java index ca14dc32..b418cf67 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectGuardrailsResponseV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectGuardrailsResponseV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectGuardrailsResponseV2Validation.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectGuardrailsResponseV2Validation.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectGuardrailsResponseV2Validation.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectGuardrailsResponseV2Validation.java index 0337a29f..bbdc7bb0 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectGuardrailsResponseV2Validation.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectGuardrailsResponseV2Validation.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntity.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntity.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntity.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntity.java index 52333c00..ce232fa3 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntity.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntity.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectObjectEntityDeidentificationType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntityDeidentificationType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntityDeidentificationType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntityDeidentificationType.java index aec7dc98..806d5dc6 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntityDeidentificationType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntityDeidentificationType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntityEntityType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntityEntityType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntityEntityType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntityEntityType.java index 93f8b64f..230600ec 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectObjectEntityEntityType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectObjectEntityEntityType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectReturnEntities.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectReturnEntities.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectReturnEntities.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectReturnEntities.java index f5435ec2..32441ba0 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectReturnEntities.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectReturnEntities.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2.java index 372e164d..6061f04f 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DetectRunsResponseV2OutputType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2OutputType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2OutputType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2OutputType.java index cb995d80..856b930b 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2OutputType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2OutputType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2Status.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2Status.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2Status.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2Status.java index c4549699..a70b3f6d 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DetectRunsResponseV2Status.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DetectRunsResponseV2Status.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2.java index 4e080422..6fb6df1c 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DocumentV2Pdf.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2Pdf.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2Pdf.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2Pdf.java index 4aae1940..0604a3a5 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2Pdf.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2Pdf.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/DocumentV2PdfProcessingMode.java b/common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2PdfProcessingMode.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2PdfProcessingMode.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2PdfProcessingMode.java index 2ada581f..3f749db2 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/DocumentV2PdfProcessingMode.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/DocumentV2PdfProcessingMode.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/EntityTransformation.java b/common/src/main/java/com/skyflow/generated/common/rest/types/EntityTransformation.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/EntityTransformation.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/EntityTransformation.java index 870b3e13..294287b4 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/EntityTransformation.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/EntityTransformation.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/ErrorResponse.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ErrorResponse.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ErrorResponse.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ErrorResponse.java index 4e29036e..65c9d01a 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ErrorResponse.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ErrorResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.skyflow.generated.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/ErrorResponseError.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ErrorResponseError.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ErrorResponseError.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ErrorResponseError.java index 5c43d6a6..97312dbf 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ErrorResponseError.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ErrorResponseError.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/FileMapping.java b/common/src/main/java/com/skyflow/generated/common/rest/types/FileMapping.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/FileMapping.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/FileMapping.java index 75b023be..d613eebf 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/FileMapping.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/FileMapping.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/FileOutput.java b/common/src/main/java/com/skyflow/generated/common/rest/types/FileOutput.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutput.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/FileOutput.java index 69f6cdf8..0896a570 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutput.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/FileOutput.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/FileOutputProcessedFileExtension.java b/common/src/main/java/com/skyflow/generated/common/rest/types/FileOutputProcessedFileExtension.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutputProcessedFileExtension.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/FileOutputProcessedFileExtension.java index 5eb8fd6f..a929071c 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutputProcessedFileExtension.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/FileOutputProcessedFileExtension.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutputProcessedFileType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/FileOutputProcessedFileType.java similarity index 96% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutputProcessedFileType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/FileOutputProcessedFileType.java index faeb8849..cd807aaa 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/FileOutputProcessedFileType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/FileOutputProcessedFileType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/auth/rest/types/V1GetAuthTokenResponse.java b/common/src/main/java/com/skyflow/generated/common/rest/types/GetAuthTokenResponse.java similarity index 67% rename from common/src/main/java/com/skyflow/generated/auth/rest/types/V1GetAuthTokenResponse.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/GetAuthTokenResponse.java index 3db2f22b..519a2081 100644 --- a/common/src/main/java/com/skyflow/generated/auth/rest/types/V1GetAuthTokenResponse.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/GetAuthTokenResponse.java @@ -1,27 +1,32 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.auth.rest.types; - -import com.fasterxml.jackson.annotation.*; +package com.skyflow.generated.common.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.auth.rest.core.ObjectMappers; - +import com.skyflow.generated.common.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 { +@JsonDeserialize(builder = GetAuthTokenResponse.Builder.class) +public final class GetAuthTokenResponse { private final Optional accessToken; private final Optional tokenType; private final Map additionalProperties; - private V1GetAuthTokenResponse( + private GetAuthTokenResponse( Optional accessToken, Optional tokenType, Map additionalProperties) { this.accessToken = accessToken; this.tokenType = tokenType; @@ -44,10 +49,10 @@ public Optional getTokenType() { return tokenType; } - @Override + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof V1GetAuthTokenResponse && equalTo((V1GetAuthTokenResponse) other); + return other instanceof GetAuthTokenResponse && equalTo((GetAuthTokenResponse) other); } @JsonAnyGetter @@ -55,16 +60,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(V1GetAuthTokenResponse other) { + private boolean equalTo(GetAuthTokenResponse other) { return accessToken.equals(other.accessToken) && tokenType.equals(other.tokenType); } - @Override + @java.lang.Override public int hashCode() { return Objects.hash(this.accessToken, this.tokenType); } - @Override + @java.lang.Override public String toString() { return ObjectMappers.stringify(this); } @@ -84,7 +89,7 @@ public static final class Builder { private Builder() {} - public Builder from(V1GetAuthTokenResponse other) { + public Builder from(GetAuthTokenResponse other) { accessToken(other.getAccessToken()); tokenType(other.getTokenType()); return this; @@ -118,8 +123,18 @@ public Builder tokenType(String tokenType) { return this; } - public V1GetAuthTokenResponse build() { - return new V1GetAuthTokenResponse(accessToken, tokenType, additionalProperties); + public GetAuthTokenResponse build() { + return new GetAuthTokenResponse(accessToken, tokenType, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; } } } diff --git a/common/src/main/java/com/skyflow/generated/common/rest/types/GetStsTokenResponse.java b/common/src/main/java/com/skyflow/generated/common/rest/types/GetStsTokenResponse.java new file mode 100644 index 00000000..d972a9f2 --- /dev/null +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/GetStsTokenResponse.java @@ -0,0 +1,173 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.skyflow.generated.common.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.common.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 = GetStsTokenResponse.Builder.class) +public final class GetStsTokenResponse { + private final Optional accessToken; + + private final Optional issuedTokenType; + + private final Optional tokenType; + + private final Map additionalProperties; + + private GetStsTokenResponse( + Optional accessToken, + Optional issuedTokenType, + Optional tokenType, + Map additionalProperties) { + this.accessToken = accessToken; + this.issuedTokenType = issuedTokenType; + this.tokenType = tokenType; + this.additionalProperties = additionalProperties; + } + + /** + * @return AccessToken. + */ + @JsonProperty("accessToken") + public Optional getAccessToken() { + return accessToken; + } + + /** + * @return IssuedTokenType : urn:ietf:params:oauth:token-type:jwt. + */ + @JsonProperty("issuedTokenType") + public Optional getIssuedTokenType() { + return issuedTokenType; + } + + /** + * @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 GetStsTokenResponse && equalTo((GetStsTokenResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetStsTokenResponse other) { + return accessToken.equals(other.accessToken) + && issuedTokenType.equals(other.issuedTokenType) + && tokenType.equals(other.tokenType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.accessToken, this.issuedTokenType, 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 issuedTokenType = Optional.empty(); + + private Optional tokenType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetStsTokenResponse other) { + accessToken(other.getAccessToken()); + issuedTokenType(other.getIssuedTokenType()); + 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; + } + + /** + *

IssuedTokenType : urn:ietf:params:oauth:token-type:jwt.

+ */ + @JsonSetter(value = "issuedTokenType", nulls = Nulls.SKIP) + public Builder issuedTokenType(Optional issuedTokenType) { + this.issuedTokenType = issuedTokenType; + return this; + } + + public Builder issuedTokenType(String issuedTokenType) { + this.issuedTokenType = Optional.ofNullable(issuedTokenType); + 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 GetStsTokenResponse build() { + return new GetStsTokenResponse(accessToken, issuedTokenType, tokenType, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/ImageV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ImageV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ImageV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ImageV2.java index ebcc89de..a6793380 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ImageV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ImageV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/ImageV2MaskingMethod.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ImageV2MaskingMethod.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ImageV2MaskingMethod.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ImageV2MaskingMethod.java index 41f59512..35e90bd6 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ImageV2MaskingMethod.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ImageV2MaskingMethod.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/Media.java b/common/src/main/java/com/skyflow/generated/common/rest/types/Media.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/Media.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/Media.java index 7bba13bb..4ea06678 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/Media.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/Media.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/Metrics.java b/common/src/main/java/com/skyflow/generated/common/rest/types/Metrics.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/Metrics.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/Metrics.java index ac525333..651a8e2a 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/Metrics.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/Metrics.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/RedactionLevel.java b/common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevel.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevel.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevel.java index 961c2f2f..ee7e9be2 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevel.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevel.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/RedactionLevelEntityName.java b/common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevelEntityName.java similarity index 99% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevelEntityName.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevelEntityName.java index a4e9acb6..47120d45 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevelEntityName.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevelEntityName.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevelRedactionType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevelRedactionType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevelRedactionType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevelRedactionType.java index 5e9b0807..559cad75 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/RedactionLevelRedactionType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/RedactionLevelRedactionType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2.java index b7b8e3e5..896cf19f 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/ReidentifyFileResponseV2OutputType.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2OutputType.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2OutputType.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2OutputType.java index ad4ea20f..64930329 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2OutputType.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2OutputType.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2Status.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2Status.java similarity index 98% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2Status.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2Status.java index 250bd1a9..60af69d7 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyFileResponseV2Status.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyFileResponseV2Status.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.rest.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyStringResponseV2.java b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyStringResponseV2.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyStringResponseV2.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyStringResponseV2.java index 2c836067..4aca3703 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/ReidentifyStringResponseV2.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/ReidentifyStringResponseV2.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/types/TransformationShiftDates.java b/common/src/main/java/com/skyflow/generated/common/rest/types/TransformationShiftDates.java similarity index 97% rename from common/src/main/java/com/skyflow/generated/detect/rest/types/TransformationShiftDates.java rename to common/src/main/java/com/skyflow/generated/common/rest/types/TransformationShiftDates.java index 78879313..ec812fc7 100644 --- a/common/src/main/java/com/skyflow/generated/detect/rest/types/TransformationShiftDates.java +++ b/common/src/main/java/com/skyflow/generated/common/rest/types/TransformationShiftDates.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.skyflow.generated.detect.rest.types; +package com.skyflow.generated.common.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.detect.rest.core.ObjectMappers; +import com.skyflow.generated.common.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/detect/rest/core/ApiClientException.java b/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientException.java deleted file mode 100644 index 0f99fbc6..00000000 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientException.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.detect.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/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientHttpResponse.java b/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientHttpResponse.java deleted file mode 100644 index 4b251a98..00000000 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/ApiClientHttpResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.detect.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/common/src/main/java/com/skyflow/generated/detect/rest/core/Environment.java b/common/src/main/java/com/skyflow/generated/detect/rest/core/Environment.java deleted file mode 100644 index c95311b0..00000000 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/Environment.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.detect.rest.core; - -public final class Environment { - public static final Environment PRODUCTION = new Environment("https://%7B%7BvaultUri%7D%7D.vault.skyflowapis.com"); - - public static final Environment SANDBOX = - new Environment("https://%7B%7BvaultUri%7D%7D.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/common/src/main/java/com/skyflow/generated/detect/rest/core/MediaTypes.java b/common/src/main/java/com/skyflow/generated/detect/rest/core/MediaTypes.java deleted file mode 100644 index b2d084be..00000000 --- a/common/src/main/java/com/skyflow/generated/detect/rest/core/MediaTypes.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.skyflow.generated.detect.rest.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/serviceaccount/util/BearerToken.java b/common/src/main/java/com/skyflow/serviceaccount/util/BearerToken.java index a98f4e3a..dad43edd 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.BaseErrorMessage; import com.skyflow.errors.SkyflowException; -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.generated.common.rest.ApiClient; +import com.skyflow.generated.common.rest.ApiClientBuilder; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.resources.authentication.AuthenticationClient; +import com.skyflow.generated.common.rest.resources.authentication.requests.GetAuthTokenRequest; +import com.skyflow.generated.common.rest.types.GetAuthTokenResponse; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; import com.skyflow.utils.BaseConstants; @@ -49,7 +49,7 @@ public static BearerTokenBuilder builder() { return new BearerTokenBuilder(); } - private static V1GetAuthTokenResponse generateBearerTokenFromCredentials( + private static GetAuthTokenResponse generateBearerTokenFromCredentials( File credentialsFile, Object context, ArrayList roles ) throws SkyflowException { LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED.getLog()); @@ -76,7 +76,7 @@ private static V1GetAuthTokenResponse generateBearerTokenFromCredentials( } } - private static V1GetAuthTokenResponse generateBearerTokenFromCredentialString( + private static GetAuthTokenResponse generateBearerTokenFromCredentialString( String credentials, Object context, ArrayList roles ) throws SkyflowException { LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED.getLog()); @@ -94,7 +94,7 @@ private static V1GetAuthTokenResponse generateBearerTokenFromCredentialString( } } - private static V1GetAuthTokenResponse getBearerTokenFromCredentials( + private static GetAuthTokenResponse getBearerTokenFromCredentials( JsonObject credentials, Object context, ArrayList roles ) throws SkyflowException { try { @@ -151,13 +151,13 @@ private static V1GetAuthTokenResponse getBearerTokenFromCredentials( ApiClient apiClient = API_CLIENT_BUILDER.token("token").build(); AuthenticationClient authenticationApi = apiClient.authentication(); - V1GetAuthTokenRequest._FinalStage authTokenBuilder = V1GetAuthTokenRequest.builder().grantType(BaseConstants.GRANT_TYPE).assertion(signedUserJWT); + GetAuthTokenRequest._FinalStage authTokenBuilder = GetAuthTokenRequest.builder().grantType(BaseConstants.GRANT_TYPE).assertion(signedUserJWT); if (roles != null) { String scopedRoles = getScopeUsingRoles(roles); authTokenBuilder.scope(scopedRoles); } - return authenticationApi.authenticationServiceGetAuthToken(authTokenBuilder.build()); + return authenticationApi.getBearerToken(authTokenBuilder.build()); } catch (MalformedURLException e) { LogUtil.printErrorLog(ErrorLogs.INVALID_TOKEN_URI.getLog()); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseErrorMessage.InvalidTokenUri.getMessage()); @@ -202,7 +202,7 @@ private static String getScopeUsingRoles(ArrayList roles) { public synchronized String getBearerToken() throws SkyflowException { LogUtil.printInfoLog(InfoLogs.GET_BEARER_TOKEN_TRIGGERED.getLog()); - V1GetAuthTokenResponse response; + GetAuthTokenResponse response; String accessToken = null; if (this.credentialsFile != null && Objects.equals(this.credentialsType, "FILE")) { response = generateBearerTokenFromCredentials(this.credentialsFile, this.ctx, this.roles); @@ -215,7 +215,7 @@ public synchronized String getBearerToken() throws SkyflowException { return accessToken; } - private static String extractAccessToken(V1GetAuthTokenResponse response) throws SkyflowException { + private static String extractAccessToken(GetAuthTokenResponse response) throws SkyflowException { if (!response.getAccessToken().isPresent()) { LogUtil.printErrorLog(ErrorLogs.MISSING_ACCESS_TOKEN.getLog()); throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseErrorMessage.MissingAccessToken.getMessage()); diff --git a/common/src/main/java/com/skyflow/vault/controller/BaseDetectController.java b/common/src/main/java/com/skyflow/vault/controller/BaseDetectController.java index 865bd1ff..dc605441 100644 --- a/common/src/main/java/com/skyflow/vault/controller/BaseDetectController.java +++ b/common/src/main/java/com/skyflow/vault/controller/BaseDetectController.java @@ -22,27 +22,27 @@ import com.skyflow.detect.internal.ReidentifyFileMapper; import com.skyflow.detect.internal.ReidentifyFileValidations; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.detect.rest.core.ApiClientApiException; -import com.skyflow.generated.detect.rest.core.ApiClientException; -import com.skyflow.generated.detect.rest.core.ClientOptions; -import com.skyflow.generated.detect.rest.core.Environment; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.core.RequestOptions; -import com.skyflow.generated.detect.rest.resources.filesv2.FilesV2Client; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.GetRunV2Request; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.GuardrailsV2Client; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.StringsV2Client; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.DeidentifyFileResponseV2; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +import com.skyflow.generated.common.rest.core.ApiClientApiException; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.core.ClientOptions; +import com.skyflow.generated.common.rest.core.Environment; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.core.RequestOptions; +import com.skyflow.generated.common.rest.resources.filesv2.FilesV2Client; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.filesv2.requests.GetRunV2Request; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.resources.guardrailsv2.GuardrailsV2Client; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.StringsV2Client; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.DeidentifyFileResponseV2; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; import com.skyflow.logs.ErrorLogs; import com.skyflow.logs.InfoLogs; import com.skyflow.utils.BaseConstants; diff --git a/common/src/test/java/com/skyflow/detect/internal/DeidentifyFileMapperTests.java b/common/src/test/java/com/skyflow/detect/internal/DeidentifyFileMapperTests.java index 41886c3c..be54cb49 100644 --- a/common/src/test/java/com/skyflow/detect/internal/DeidentifyFileMapperTests.java +++ b/common/src/test/java/com/skyflow/detect/internal/DeidentifyFileMapperTests.java @@ -12,9 +12,9 @@ import com.skyflow.detect.GetRunResponse; import com.skyflow.errors.BaseErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.DeidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.resources.filesv2.requests.DeidentifyFileRequestV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; diff --git a/common/src/test/java/com/skyflow/detect/internal/DetectRequestMapperTests.java b/common/src/test/java/com/skyflow/detect/internal/DetectRequestMapperTests.java index facad0ec..a805f103 100644 --- a/common/src/test/java/com/skyflow/detect/internal/DetectRequestMapperTests.java +++ b/common/src/test/java/com/skyflow/detect/internal/DetectRequestMapperTests.java @@ -12,16 +12,16 @@ import com.skyflow.detect.MaskingMethod; import com.skyflow.detect.Media; import com.skyflow.detect.RedactionLevel; -import com.skyflow.detect.RedactionType; +import com.skyflow.enums.RedactionType; import com.skyflow.detect.ReidentifyStringRequest; import com.skyflow.detect.ReturnEntitiesType; import com.skyflow.detect.ShiftDates; import com.skyflow.detect.Transformation; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; -import com.skyflow.generated.detect.rest.types.DetectConfigV2; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.resources.guardrailsv2.requests.DetectGuardrailsRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.DeidentifyStringRequestV2; +import com.skyflow.generated.common.rest.resources.stringsv2.requests.ReidentifyStringRequestV2; +import com.skyflow.generated.common.rest.types.DetectConfigV2; import com.skyflow.detect.FileMapping; import com.skyflow.detect.ObjectEntity; import org.junit.Assert; @@ -144,7 +144,7 @@ public void checkGuardrailsCarriesVaultIdAndOnlySetOptions() throws Exception { @Test public void nullElementsInConfigurationListsAreSkipped() throws Exception { - com.skyflow.generated.detect.rest.types.DetectConfigV2 api = DetectRequestMapper.toDetectConfig( + com.skyflow.generated.common.rest.types.DetectConfigV2 api = DetectRequestMapper.toDetectConfig( DetectConfiguration.builder() .detect(Detect.builder() .entities(Arrays.asList(null, Entity.builder().entityType(EntityType.NAME).build())) diff --git a/common/src/test/java/com/skyflow/detect/internal/DetectResponseMapperTests.java b/common/src/test/java/com/skyflow/detect/internal/DetectResponseMapperTests.java index 0a4ab894..f0ebcada 100644 --- a/common/src/test/java/com/skyflow/detect/internal/DetectResponseMapperTests.java +++ b/common/src/test/java/com/skyflow/detect/internal/DetectResponseMapperTests.java @@ -9,11 +9,11 @@ import com.skyflow.detect.GuardrailsValidation; import com.skyflow.detect.DetectedEntity; import com.skyflow.detect.ReidentifyStringResponse; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.types.DeidentifyStringResponseV2; -import com.skyflow.generated.detect.rest.types.DetectGuardrailsResponseV2; -import com.skyflow.generated.detect.rest.types.DetectRunsResponseV2; -import com.skyflow.generated.detect.rest.types.ReidentifyStringResponseV2; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.types.DeidentifyStringResponseV2; +import com.skyflow.generated.common.rest.types.DetectGuardrailsResponseV2; +import com.skyflow.generated.common.rest.types.DetectRunsResponseV2; +import com.skyflow.generated.common.rest.types.ReidentifyStringResponseV2; import org.junit.Assert; import org.junit.Test; diff --git a/common/src/test/java/com/skyflow/detect/internal/DetectValidationsTests.java b/common/src/test/java/com/skyflow/detect/internal/DetectValidationsTests.java index dd154096..b663f805 100644 --- a/common/src/test/java/com/skyflow/detect/internal/DetectValidationsTests.java +++ b/common/src/test/java/com/skyflow/detect/internal/DetectValidationsTests.java @@ -6,7 +6,7 @@ import com.skyflow.detect.EntityType; import com.skyflow.detect.GetRunRequest; import com.skyflow.detect.RedactionLevel; -import com.skyflow.detect.RedactionType; +import com.skyflow.enums.RedactionType; import com.skyflow.detect.ReidentifyStringRequest; import com.skyflow.errors.BaseErrorMessage; import com.skyflow.errors.ErrorCode; diff --git a/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileMapperTests.java b/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileMapperTests.java index 88da01e4..ec711c12 100644 --- a/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileMapperTests.java +++ b/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileMapperTests.java @@ -6,12 +6,12 @@ import com.skyflow.detect.FileDataFormat; import com.skyflow.detect.FileOutput; import com.skyflow.detect.RedactionLevel; -import com.skyflow.detect.RedactionType; +import com.skyflow.enums.RedactionType; import com.skyflow.detect.ReidentifyFileRequest; import com.skyflow.detect.ReidentifyFileResponse; -import com.skyflow.generated.detect.rest.core.ObjectMappers; -import com.skyflow.generated.detect.rest.resources.filesv2.requests.ReidentifyFileRequestV2; -import com.skyflow.generated.detect.rest.types.ReidentifyFileResponseV2; +import com.skyflow.generated.common.rest.core.ObjectMappers; +import com.skyflow.generated.common.rest.resources.filesv2.requests.ReidentifyFileRequestV2; +import com.skyflow.generated.common.rest.types.ReidentifyFileResponseV2; import org.junit.Assert; import org.junit.Test; diff --git a/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileValidationsTests.java b/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileValidationsTests.java index d910fa77..8b36827b 100644 --- a/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileValidationsTests.java +++ b/common/src/test/java/com/skyflow/detect/internal/ReidentifyFileValidationsTests.java @@ -3,7 +3,7 @@ import com.skyflow.detect.DataSourceType; import com.skyflow.detect.EntityType; import com.skyflow.detect.RedactionLevel; -import com.skyflow.detect.RedactionType; +import com.skyflow.enums.RedactionType; import com.skyflow.detect.ReidentifyFileRequest; import com.skyflow.errors.ErrorCode; import com.skyflow.errors.BaseErrorMessage; diff --git a/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java b/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java index 9557b48b..8ac7bfa4 100644 --- a/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java +++ b/common/src/test/java/com/skyflow/serviceaccount/util/BearerTokenTests.java @@ -5,8 +5,8 @@ import com.skyflow.errors.ErrorCode; import com.skyflow.errors.BaseErrorMessage; import com.skyflow.errors.SkyflowException; -import com.skyflow.generated.auth.rest.core.ApiClientException; -import com.skyflow.generated.auth.rest.types.V1GetAuthTokenResponse; +import com.skyflow.generated.common.rest.core.ApiClientException; +import com.skyflow.generated.common.rest.types.GetAuthTokenResponse; import com.skyflow.utils.BaseConstants; import com.skyflow.utils.BaseUtils; import org.junit.Assert; @@ -361,8 +361,8 @@ public void testMalformedPrivateKeyTypeThrowsSkyflowException() { @Test public void testExtractAccessTokenMissingThrowsSkyflowException() throws Exception { - V1GetAuthTokenResponse response = V1GetAuthTokenResponse.builder().build(); - Method method = BearerToken.class.getDeclaredMethod("extractAccessToken", V1GetAuthTokenResponse.class); + GetAuthTokenResponse response = GetAuthTokenResponse.builder().build(); + Method method = BearerToken.class.getDeclaredMethod("extractAccessToken", GetAuthTokenResponse.class); method.setAccessible(true); try { method.invoke(null, response); @@ -377,8 +377,8 @@ public void testExtractAccessTokenMissingThrowsSkyflowException() throws Excepti @Test public void testExtractAccessTokenPresentReturnsToken() throws Exception { - V1GetAuthTokenResponse response = V1GetAuthTokenResponse.builder().accessToken("test-access-token").build(); - Method method = BearerToken.class.getDeclaredMethod("extractAccessToken", V1GetAuthTokenResponse.class); + GetAuthTokenResponse response = GetAuthTokenResponse.builder().accessToken("test-access-token").build(); + Method method = BearerToken.class.getDeclaredMethod("extractAccessToken", GetAuthTokenResponse.class); method.setAccessible(true); Object result = method.invoke(null, response); Assert.assertEquals("test-access-token", result); diff --git a/docs/api_reference.md b/docs/api_reference.md index 5908751c..2141f893 100644 --- a/docs/api_reference.md +++ b/docs/api_reference.md @@ -1,11 +1,16 @@ # API Reference -A reference for the public Skyflow Java SDK surface: client-management methods, config classes, request and response objects, helper classes, enums, and service-account utilities. For task-oriented usage and examples, see the [README](../README.md). +A reference for the public Skyflow Java SDK surface: client-management methods, config classes, request and response objects, helper classes, enums, and service-account utilities. + +The vault, connection and file-upload classes belong to the skyvault SDK (`com.skyflow:skyflow-java`). The Detect classes in `com.skyflow.detect`, together with the credentials, config and service-account classes, live in the shared `common` module and apply to both the skyvault and the flowvault SDK (`com.skyflow:skyflow-flowvault-java`). Where a Detect field is specific to one vault type the table says so. The flowvault vault-operation classes (bulk insert, tokenize, detokenize and delete) are documented in the [flowvault README](../flowvault/README.md). + +For task-oriented usage and examples, see the [skyvault README](../skyvault/README.md) and the [flowvault README](../flowvault/README.md). All attributes, parameters, and enum values below are taken directly from the SDK source. ## Table of Contents +- [Detect API](#detect-api) - [Client management methods](#client-management-methods) - [Config classes](#config-classes) - [Request objects](#request-objects) @@ -16,6 +21,23 @@ All attributes, parameters, and enum values below are taken directly from the SD --- +## Detect API + +Shared by the skyvault and flowvault SDKs. `skyflowClient.detect()` and `skyflowClient.detect(vaultId)` return a `DetectController`; every class below is in `com.skyflow.detect`. Usage and examples: [skyvault README](../skyvault/README.md#detect), [flowvault README](../flowvault/README.md#detect). + +| Method | Request | Response | +|--------|---------|----------| +| `deidentifyString` | [`DeidentifyStringRequest`](#deidentifystringrequest) | [`DeidentifyStringResponse`](#deidentifystringresponse) | +| `deidentifyFile` | [`DeidentifyFileRequest`](#deidentifyfilerequest) | [`DeidentifyFileResponse`](#deidentifyfileresponse) | +| `reidentifyString` | [`ReidentifyStringRequest`](#reidentifystringrequest) | [`ReidentifyStringResponse`](#reidentifystringresponse) | +| `reidentifyFile` | [`ReidentifyFileRequest`](#reidentifyfilerequest) | [`ReidentifyFileResponse`](#reidentifyfileresponse) | +| `getRun` | [`GetRunRequest`](#getrunrequest) | [`GetRunResponse`](#getrunresponse) | +| `checkGuardrails` | [`CheckGuardrailsRequest`](#checkguardrailsrequest) | [`CheckGuardrailsResponse`](#checkguardrailsresponse) | + +Configuration and helper classes: [`DetectConfiguration`](#detectconfiguration), [`Detect`](#detect), [`Entity`](#entity), [`Transformation` and `ShiftDates`](#transformation-and-shiftdates), [`CustomType`](#customtype), [`ObjectEntity`](#objectentity), [`FileMapping`](#filemapping), [`Media`](#media) (with `Audio`, `Bleep`, `Document`, `Pdf`, `Image`), [`PollOptions`](#polloptions), [`RedactionLevel`](#redactionlevel), [`DetectedEntity`](#detectedentity), [`EntityLocation`](#entitylocation), [`Metrics`](#metrics), [`FileOutput`](#fileoutput). Enums: [Detect enums](#detect-enums). + +--- + ## Client management methods A built `Skyflow` client exposes methods to mutate its configuration and logging at runtime, in addition to the builder methods used during initialization. @@ -211,8 +233,8 @@ Parameters listed with their defaults as defined in the builders. | Builder method | Default | Description | |----------------|---------|-------------| | `text(String)` | _(required)_ | Text to de-identify. | -| `configurationId(String)` | `null` | Id of a Detect configuration created in Studio or through the management API. | -| `configuration(DetectConfiguration)` | `null` | Inline configuration. See [`DetectConfiguration`](#detectconfiguration). Supply this or `configurationId`. | +| `configurationId(String)` | `null` | Id of a Detect configuration created through the management API. | +| `configuration(DetectConfiguration)` | `null` | Inline configuration. See [`DetectConfiguration`](#detectconfiguration).| ### `DeidentifyFileRequest` @@ -228,7 +250,7 @@ Parameters listed with their defaults as defined in the builders. | `configurationId(String)` | `null` | Id of a stored Detect configuration. | | `configuration(DetectConfiguration)` | `null` | Inline configuration. See [`DetectConfiguration`](#detectconfiguration). | | `pollOptions(PollOptions)` | `null` | Poll the run after submitting. `null` submits only and returns the run id. See [`PollOptions`](#polloptions). | -| `outputDirectory(String)` | working directory | Where outputs are written on success. Requires `pollOptions` and a local file. | +| `outputDirectory(String)` | working directory | Where outputs are written on success. Requires `pollOptions` and a local file; setting it without `pollOptions` fails client-side validation. | ### `ReidentifyStringRequest` @@ -247,8 +269,8 @@ Parameters listed with their defaults as defined in the builders. |----------------|---------|-------------| | `dataSource(DataSourceType)` | _(required)_ | `BASE64`, `SKYFLOW_ID` or `PRESIGNED_URL`. | | `value(String)` | _(required)_ | Base64 content, a skyflow id, or a presigned URL, per `dataSource`. | -| `dataFormat(FileDataFormat)` | `null` | File format. | -| `redactionLevel(List)` | `null` | Per-entity redaction rules. See [`RedactionLevel`](#redactionlevel). | +| `dataFormat(FileDataFormat)` | `null` | File format. Limited to the formats that support `VAULT_TOKEN`: `TXT`, `CSV`, `JSON`, `JSONL`, `XML`, `DOCX`, `XLSX` or `PPTX`. | +| `redactionLevel(List)` | `null` | Redaction rules. See [`RedactionLevel`](#redactionlevel). | ### `GetRunRequest` @@ -265,7 +287,7 @@ Parameters listed with their defaults as defined in the builders. | Builder method | Default | Description | |----------------|---------|-------------| | `text(String)` | _(required)_ | Text to screen. | -| `checkToxicity(Boolean)` | `true` on the server | Whether to check for toxicity. | +| `checkToxicity(Boolean)` | `null` | Whether to check for toxicity. Sent only when set. | | `denyTopics(List)` | `null` | Topics to deny. | ### `InvokeConnectionRequest` @@ -501,7 +523,7 @@ Each element returned by `getDetokenizedFields()` and `getErrors()`. |----------------|---------|-------------| | `entityType(EntityType)` | `ALL` | Entity type. See [`EntityType`](#entitytype). | | `deidentificationType(DeidentificationType)` | `ENTITY_UNIQUE_COUNTER` | How the value is replaced. See [`DeidentificationType`](#deidentificationtype). | -| `destination(String)` | `null` | For `VAULT_TOKEN`: the `table.column` that stores the value. | +| `destination(String)` | `null` | For `VAULT_TOKEN`: where the value is stored. A `table.column` on skyvault vaults, a token group name on flowvault vaults. Must already exist. | | `transformation(Transformation)` | `null` | Date shifting. See [`Transformation`](#transformation). | ### `Transformation` and `ShiftDates` @@ -555,14 +577,14 @@ Each element returned by `getDetokenizedFields()` and `getErrors()`. ### `RedactionLevel` -`com.skyflow.detect` — element of `ReidentifyStringRequest.redactionLevel()`. For skyvault vaults name an entity and a redaction type. +`com.skyflow.detect` — element of `redactionLevel()` on `ReidentifyStringRequest` and `ReidentifyFileRequest`. Each rule names one source and one replacement: `entityName` plus `redactionType` on skyvault vaults, `tokenGroupName` plus `redactionPattern` on flowvault vaults. Every field is optional on the API; the server rejects invalid combinations. | Builder method | Description | |----------------|-------------| -| `entityName(EntityType)` | Entity the rule applies to. | -| `redactionType(RedactionType)` | `PLAIN_TEXT`, `MASKED`, `REDACTED` or `DEFAULT`. See [`RedactionType`](#redactiontype). | -| `tokenGroupName(String)` | Flowvault vaults only. | -| `redactionPattern(String)` | Flowvault vaults only. | +| `entityName(EntityType)` | Skyvault vaults: entity type the rule applies to. | +| `redactionType(RedactionType)` | Skyvault vaults: `PLAIN_TEXT`, `MASKED`, `REDACTED` or `DEFAULT`, the same `com.skyflow.enums.RedactionType` used by `get` and `detokenize`. See [`RedactionType`](#redactiontype). | +| `tokenGroupName(String)` | Flowvault vaults: token group the rule applies to. | +| `redactionPattern(String)` | Flowvault vaults: name of a redaction pattern configured in the vault. | ### `DetectedEntity` @@ -633,7 +655,7 @@ Each element returned by `getDetokenizedFields()` and `getErrors()`. ### `RedactionType` -`com.skyflow.enums` +`com.skyflow.enums` — one enum for every place a redaction is chosen: `GetRequest.redactionType`, `DetokenizeData`, and Detect's `RedactionLevel.redactionType` on skyvault vaults. | Value | Description | |-------|-------------| @@ -676,7 +698,6 @@ All in `com.skyflow.detect`. | `FileDataFormat` | `BMP`, `CSV`, `DCM`, `DOC`, `DOCX`, `GIF`, `JPEG`, `JPG`, `JSON`, `JSONL`, `MP3`, `PDF`, `PNG`, `PPT`, `PPTX`, `TIF`, `TIFF`, `TXT`, `WAV`, `XLS`, `XLSX`, `XML`, `ZIP` | | `DetectRunStatus` | `QUEUED`, `IN_PROGRESS`, `SUCCESS`, `FAILED`, `UNKNOWN`. `SUCCESS`, `FAILED` and `UNKNOWN` end polling. | | `ReturnEntitiesType` | `EXCLUDE_SENSITIVE_DATA` _(default)_, `ALL`, `NONE` | -| `RedactionType` | `PLAIN_TEXT`, `MASKED`, `REDACTED`, `DEFAULT` | | `MaskingMethod` | `NONE`, `BLUR`, `BLACKBOX` | | `OutputTranscriptionType` | `NONE`, `TRANSCRIPTION`, `MEDICAL_TRANSCRIPTION`, `DIARIZED_TRANSCRIPTION`, `MEDICAL_DIARIZED_TRANSCRIPTION` | | `PdfProcessingMode` | `NONE`, `OCR`, `TEXT_LAYER` | diff --git a/flowvault/README.md b/flowvault/README.md index 378de9a0..894a21c3 100644 --- a/flowvault/README.md +++ b/flowvault/README.md @@ -1644,11 +1644,16 @@ Detect configurations are created in Studio or through the management API. The S | `getRun(GetRunRequest)` | `com.skyflow.detect.GetRunRequest` | `com.skyflow.detect.GetRunResponse` | Retrieve the status and outputs of a Detect file run | | `checkGuardrails(CheckGuardrailsRequest)` | `com.skyflow.detect.CheckGuardrailsRequest` | `com.skyflow.detect.CheckGuardrailsResponse` | Screen text for toxicity and denied topics | -> Detect V2 is in beta. +## Before you start + +- **Role.** The service account needs the Detect Invoker, Detect Manager or Vault Owner role on the vault. Detect Invoker can de-identify data and write vault tokens into the vault; Detect Manager adds the ability to create, update and delete Detect configurations. Re-identifying values stored as `VAULT_TOKEN` is governed like detokenization: the caller also needs a policy that grants the Detokenization action on the destination, unless it is a Vault Owner. Detect Invoker or Detect Manager alone is not enough. +- **Configuration.** `configurationId` is the id of a Detect configuration created through the management API; the SDK does not create, update or delete them. The alternative is an inline `DetectConfiguration` passed as `configuration` (see [Detect configuration](#detect-configuration)). +- **Destination for vault tokens.** An entity de-identified with `VAULT_TOKEN` stores its value in the token group named by `destination`. That token group must already exist in the vault; Detect writes into it but does not create it. +- **API reference.** Every Detect request, response and configuration class is listed in the [API reference](../docs/api_reference.md#detect-api). ## Deidentify string -`DeidentifyStringRequest` takes the text plus, optionally, `configurationId` (a stored Detect configuration) and/or `configuration` (an inline `DetectConfiguration`). Both are optional on the API and are sent exactly as supplied. The SDK fills the vault id from the controller. +`DeidentifyStringRequest` takes the text plus exactly one of `configurationId` (a stored Detect configuration) or `configuration` (an inline `DetectConfiguration`). Both fields are sent exactly as supplied and the server rejects a request that has neither or both (see [Before you start](#before-you-start)). For an inline configuration the SDK fills the vault id from the controller. ```java import com.skyflow.detect.*; @@ -1696,6 +1701,60 @@ System.out.println(response.getMetrics().getWordCount()); `DeidentifyStringResponse` carries `getProcessedText()`, `getEntities()` (a `List` with token, entity type, location and confidence scores; never `null`) and `getMetrics()`. +## Detect configuration + +`DetectConfiguration` is the inline form of a stored configuration and accepts the same options. `detect` applies to string and file inputs; `fileMapping` and `media` apply to file inputs only. + +| Class | Builder methods | Notes | +|-------|-----------------|-------| +| `Detect` | `entities`, `objectEntities`, `restrict`, `skip`, `customTypes`, `returnEntities` | `restrict` and `skip` are regexes that are always, respectively never, treated as sensitive. `returnEntities` is `EXCLUDE_SENSITIVE_DATA` (server default), `ALL` or `NONE`. | +| `Entity` | `entityType`, `deidentificationType`, `destination`, `transformation` | `entityType` defaults to `ALL`. `deidentificationType` is `ENTITY_UNIQUE_COUNTER` (server default), `ENTITY_ONLY`, `MASK` or `VAULT_TOKEN`. `destination` is used only with `VAULT_TOKEN`. | +| `Transformation` / `ShiftDates` | `shiftDates(ShiftDates)`; `minDays`, `maxDays` | Shifts detected dates by a random number of days within the range. | +| `CustomType` | `label`, `match` | A regex-defined entity type. `label` is reported as the entity type of its matches. | +| `ObjectEntity` | `entityType`, `deidentificationType` | Visual objects in images: `FACE`, `LICENSE_PLATE`, `LOGO`, `SIGNATURE` or `ALL`, handled with `REDACT` or `UNREDACT`. File inputs only. | +| `FileMapping` | `source`, `destination`, `outputFileNameSuffix`, `entitiesDestination`, `objectEntitiesDestination` | Where the processed file and the entity files are written. File inputs only. | +| `Media` | `audio(Audio)`, `document(Document)`, `image(Image)` | Media-type options. File inputs only. | +| `Audio` / `Bleep` | `outputProcessedAudio`, `outputTranscription`, `bleep`; `startPadding`, `stopPadding`, `frequency`, `gain` | `outputTranscription` is `NONE`, `TRANSCRIPTION`, `MEDICAL_TRANSCRIPTION`, `DIARIZED_TRANSCRIPTION` or `MEDICAL_DIARIZED_TRANSCRIPTION`. `Bleep` is the tone laid over detected speech; paddings are in seconds, frequency in Hz. | +| `Document` / `Pdf` | `pdf(Pdf)`; `processingMode`, `density`, `maxResolution` | `processingMode` is `NONE`, `OCR` or `TEXT_LAYER`. `density` is the rendering DPI. | +| `Image` | `outputProcessedImage`, `outputOcrText`, `maskingMethod` | `maskingMethod` is `NONE`, `BLUR` or `BLACKBOX`. | + +```java +DetectConfiguration configuration = DetectConfiguration.builder() + .detect(Detect.builder() + .entities(Arrays.asList( + Entity.builder() + .entityType(EntityType.DOB) + .deidentificationType(DeidentificationType.ENTITY_UNIQUE_COUNTER) + .transformation(Transformation.builder() + .shiftDates(ShiftDates.builder().minDays(10).maxDays(30).build()) + .build()) + .build(), + Entity.builder().entityType(EntityType.ALL).build())) + .objectEntities(Collections.singletonList( + ObjectEntity.builder() + .entityType(ObjectEntityType.FACE) + .deidentificationType(ObjectDeidentificationType.REDACT) + .build())) + .customTypes(Collections.singletonList( + CustomType.builder() + .label("EMPLOYEE_ID") + .match(Collections.singletonList("EMP-[0-9]{6}")) + .build())) + .restrict(Collections.singletonList("[0-9]{3}-[0-9]{2}-[0-9]{4}")) + .build()) + .media(Media.builder() + .image(Image.builder().maskingMethod(MaskingMethod.BLUR).outputOcrText(true).build()) + .document(Document.builder() + .pdf(Pdf.builder().processingMode(PdfProcessingMode.OCR).build()) + .build()) + .audio(Audio.builder() + .outputTranscription(OutputTranscriptionType.TRANSCRIPTION) + .bleep(Bleep.builder().startPadding(0.5f).stopPadding(0.5f).build()) + .build()) + .build()) + .build(); +``` + ## Deidentify file File de-identification is asynchronous on the API: the submit call returns a run id and the result is retrieved from the run. `deidentifyFile` exposes both modes. @@ -1703,7 +1762,11 @@ File de-identification is asynchronous on the API: the submit call returns a run - **Submit only** (default): one call, returns `getRunId()`. `getStatus()` is `null` and nothing is written to disk. Retrieve the result later with [`getRun`](#get-run). - **Submit and poll**: set `pollOptions`. The SDK polls the run with exponential backoff (1, 2, 4, 8, 16, then 32 seconds between lookups) until it is `SUCCESS`, `FAILED` or `UNKNOWN`, or until `waitTime` (default 60 s, max 300) or `maxAttempts` (default 23, max 23) is used up. If the budget runs out the response carries the run id with `IN_PROGRESS` or `QUEUED` so you can resume with `getRun`. -The file is supplied in one of three ways: `dataSource` plus `value` (`BASE64` content, a `SKYFLOW_ID`, or a `PRESIGNED_URL`), or `file(File)` / `filePath(String)`, which read and encode a local file and infer `dataFormat` from its extension. Supply exactly one of `value`, `file` or `filePath`. Either `configurationId` or an inline `configuration` is passed through as given. +The file is supplied in one of three ways: `dataSource` plus `value` (`BASE64` content, a `SKYFLOW_ID`, or a `PRESIGNED_URL`), or `file(File)` / `filePath(String)`, which read and encode a local file and infer `dataFormat` from its extension. Supply exactly one of `value`, `file` or `filePath`, and exactly one of `configurationId` or an inline `configuration`; the server rejects neither-or-both (see [Before you start](#before-you-start)). + +`dataFormat` accepts every `FileDataFormat`: `BMP`, `CSV`, `DCM`, `DOC`, `DOCX`, `GIF`, `JPEG`, `JPG`, `JSON`, `JSONL`, `MP3`, `PDF`, `PNG`, `PPT`, `PPTX`, `TIF`, `TIFF`, `TXT`, `WAV`, `XLS`, `XLSX`, `XML` and `ZIP`. The `VAULT_TOKEN` de-identification type is supported only for `TXT`, `CSV`, `JSON`, `JSONL`, `XML`, `DOCX`, `XLSX` and `PPTX`. + +`outputDirectory` is meaningful only when polling. Setting it without `pollOptions` fails client-side validation with a `SkyflowException` before any request is sent. ```java // Submit only @@ -1744,7 +1807,7 @@ Outputs are written only when polling reached `SUCCESS`, the request was built f With `pollOptions` set, `deidentifyFile` polls on the thread that called it: each lookup is a synchronous `getRun` followed by a sleep, until the run is terminal or the budget runs out. No other thread, lock or connection is held while it waits, so other SDK calls are unaffected, but the calling thread is. If that thread is your main thread, a request thread or an event loop, run the call elsewhere. -**Run the blocking call on a thread you own.** Simplest when you process a few files at a time. The SDK still enforces the budget and writes outputs to disk; your thread is parked for the whole poll. +**Run the blocking call on a thread you own.** Simplest when you process a few files at a time. The SDK still enforces the budget and writes outputs to disk; your thread is parked for the whole poll. [DeidentifyFileAsyncSample.java](samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java) runs several files this way on a bounded pool. ```java ExecutorService pool = Executors.newFixedThreadPool(4); // or Executors.newVirtualThreadPerTaskExecutor() on JDK 21+ @@ -1805,6 +1868,8 @@ Either way the main thread only pays for the submit round trip. Avoid `new Threa ## Reidentify string +Re-identification looks tokens up in the vault, so it applies to values that were de-identified with `VAULT_TOKEN`. Placeholders produced by `ENTITY_UNIQUE_COUNTER`, `ENTITY_ONLY` or `MASK` are not stored anywhere and cannot be re-identified. + `ReidentifyStringRequest` takes the tokenized text and an optional list of `RedactionLevel` rules. For flowvault vaults each rule targets a `tokenGroupName` and applies a named `redactionPattern`. Without rules every token is replaced by its original value. ```java @@ -1822,11 +1887,11 @@ System.out.println(response.getProcessedText()); // My name is J**n D*e. ``` -A `RedactionLevel` is expected to name one source (`tokenGroupName` or `entityName`) and one replacement (`redactionPattern` or `redactionType`). Every field is optional on the API, so the SDK passes the list through as given and the server enforces the combination rules, including which fields apply to flowvault vaults. +A `RedactionLevel` names one source and one replacement. On flowvault vaults the source is a `tokenGroupName` and the replacement a `redactionPattern` configured in the vault. The `entityName` and `redactionType` fields are the skyvault equivalents and do not apply to flowvault vaults. Every field is optional on the API, so the SDK passes the list through as given and the server rejects invalid combinations. ## Reidentify file -`reidentifyFile` is synchronous: the re-identified file comes back in the response, not through a run id. `ReidentifyFileRequest` takes a `dataSource` (`BASE64`, `SKYFLOW_ID` or `PRESIGNED_URL`), the matching `value`, an optional `dataFormat` and the same optional `RedactionLevel` rules as `reidentifyString`. Re-identification supports text-based formats such as TXT, CSV, JSON, JSONL, XML, DOCX, XLSX and PPTX. +`reidentifyFile` is synchronous: the re-identified file comes back in the response, not through a run id. `ReidentifyFileRequest` takes a `dataSource` (`BASE64`, `SKYFLOW_ID` or `PRESIGNED_URL`), the matching `value`, an optional `dataFormat` and the same optional `RedactionLevel` rules as `reidentifyString`. `dataFormat` is limited to the formats that support `VAULT_TOKEN`: `TXT`, `CSV`, `JSON`, `JSONL`, `XML`, `DOCX`, `XLSX` and `PPTX`. ```java byte[] content = Files.readAllBytes(Paths.get("tokenized.txt")); @@ -1879,7 +1944,7 @@ switch (run.getStatus()) { ## Check guardrails -`checkGuardrails` screens text for toxicity and for a list of denied topics, which makes it a natural pre-LLM check. Each check runs only when requested: `getToxic()` is `null` unless `checkToxicity(true)` was set, and `getDeniedTopic()` is `null` unless `denyTopics` was supplied. `getValidation()` is `FAILED` if any requested check triggered. +`checkGuardrails` screens text for toxicity and for a list of denied topics, which makes it a natural pre-LLM check. `checkToxicity` and `denyTopics` are optional: the SDK sends each one only when you set it and does not fill in a default. The response is passed through as returned, so `getToxic()`, `getDeniedTopic()` and `getValidation()` carry exactly what the API sent back. ```java CheckGuardrailsResponse response = skyflowClient.detect().checkGuardrails( @@ -1896,7 +1961,7 @@ if (response.getValidation() == GuardrailsValidation.FAILED) { All Detect methods throw `SkyflowException` as described in [Error Handling](#error-handling). Client-side validation fails before any network call. -See the samples [DeidentifyStringSample.java](samples/src/main/java/com/example/detect/DeidentifyStringSample.java), [DeidentifyFileSample.java](samples/src/main/java/com/example/detect/DeidentifyFileSample.java), [ReidentifyStringSample.java](samples/src/main/java/com/example/detect/ReidentifyStringSample.java), [ReidentifyFileSample.java](samples/src/main/java/com/example/detect/ReidentifyFileSample.java), [GetRunSample.java](samples/src/main/java/com/example/detect/GetRunSample.java) and [CheckGuardrailsSample.java](samples/src/main/java/com/example/detect/CheckGuardrailsSample.java). +See the samples [DeidentifyStringSample.java](samples/src/main/java/com/example/detect/DeidentifyStringSample.java), [DeidentifyFileSample.java](samples/src/main/java/com/example/detect/DeidentifyFileSample.java), [DeidentifyFileAsyncSample.java](samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java), [ReidentifyStringSample.java](samples/src/main/java/com/example/detect/ReidentifyStringSample.java), [ReidentifyFileSample.java](samples/src/main/java/com/example/detect/ReidentifyFileSample.java), [GetRunSample.java](samples/src/main/java/com/example/detect/GetRunSample.java) and [CheckGuardrailsSample.java](samples/src/main/java/com/example/detect/CheckGuardrailsSample.java). # Custom Request Headers diff --git a/flowvault/api-report/skyflow-flowvault-java.baseline.jar b/flowvault/api-report/skyflow-flowvault-java.baseline.jar index 813b5c66..a131a5ee 100644 Binary files a/flowvault/api-report/skyflow-flowvault-java.baseline.jar and b/flowvault/api-report/skyflow-flowvault-java.baseline.jar differ diff --git a/flowvault/pom.xml b/flowvault/pom.xml index d9dd86f1..3a276101 100644 --- a/flowvault/pom.xml +++ b/flowvault/pom.xml @@ -12,7 +12,7 @@ skyflow-flowvault-java - 1.2.0-dev.68d5268c + 1.2.0-dev.d4140366 jar ${project.groupId}:${project.artifactId} Skyflow FlowVault SDK for the Java programming language diff --git a/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java b/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java new file mode 100644 index 00000000..4d223b12 --- /dev/null +++ b/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java @@ -0,0 +1,94 @@ +package com.example.detect; + +import com.skyflow.Skyflow; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.detect.DeidentifyFileRequest; +import com.skyflow.detect.DeidentifyFileResponse; +import com.skyflow.detect.DetectRunStatus; +import com.skyflow.detect.PollOptions; +import com.skyflow.enums.Env; +import com.skyflow.enums.LogLevel; +import com.skyflow.errors.SkyflowException; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +/** + * De-identifies several local files concurrently with polling enabled. Each task calls + * deidentifyFile with pollOptions, so the SDK polls the run with exponential backoff and writes + * the outputs to outputDirectory on success. The blocking poll runs on a pool thread, not on the + * caller's thread, and the pool is bounded because every in-flight run parks one thread. + */ +public class DeidentifyFileAsyncSample { + public static void main(String[] args) throws SkyflowException, InterruptedException { + Credentials credentials = new Credentials(); + credentials.setPath(""); // Replace with the path to the credentials file + + VaultConfig vaultConfig = new VaultConfig(); + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + + Skyflow skyflowClient = Skyflow.builder() + .setLogLevel(LogLevel.ERROR) + .addVaultConfig(vaultConfig) + .addSkyflowCredentials(credentials) + .build(); + + List files = Arrays.asList("", ""); // Replace with the files to de-identify + + // One thread per concurrent run; size this to how many runs you want in flight at once. + ExecutorService pool = Executors.newFixedThreadPool(2); + List> futures = new ArrayList<>(); + try { + for (String file : files) { + // submit() rather than execute(): the Future carries the response or the SkyflowException, + // and future.cancel(true) interrupts the poll, which returns the last run the SDK saw. + futures.add(pool.submit(() -> skyflowClient.detect().deidentifyFile( + DeidentifyFileRequest.builder() + .filePath(file) // BASE64 and the format are derived from the file + .configurationId("") // Replace with a Detect configuration id + .pollOptions(PollOptions.builder().waitTime(120).build()) + .outputDirectory("") // optional; defaults to the working directory + .build()))); + } + + // The main thread is free until here; block on each result only when it is needed. + for (int i = 0; i < futures.size(); i++) { + String file = files.get(i); + try { + DeidentifyFileResponse response = futures.get(i).get(); + System.out.println(file + ": run " + response.getRunId() + " " + response.getStatus()); + if (response.getStatus() == DetectRunStatus.SUCCESS) { + // Outputs are already on disk as processed-. and processed-entities-.json + System.out.println(" outputs: " + response.getOutput().size() + ", metrics: " + response.getMetrics()); + } else if (response.getStatus() == DetectRunStatus.FAILED) { + System.err.println(" run failed: " + response.getMessage()); + } else { + // IN_PROGRESS or QUEUED: the budget ran out; resume with getRun(runId) + System.out.println(" still running; poll later with getRun(" + response.getRunId() + ")"); + } + } catch (ExecutionException e) { + // The task threw: unwrap the SkyflowException raised inside deidentifyFile. + Throwable cause = e.getCause(); + if (cause instanceof SkyflowException) { + System.err.println(file + ": error during deidentifyFile: " + cause.getMessage()); + } else { + System.err.println(file + ": unexpected error"); + cause.printStackTrace(); + } + } + } + } finally { + pool.shutdown(); + pool.awaitTermination(1, TimeUnit.MINUTES); + } + } +} diff --git a/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java b/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java index c373f181..3f479e3e 100644 --- a/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java +++ b/flowvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java @@ -12,11 +12,17 @@ import com.skyflow.errors.SkyflowException; /** - * De-identifies a local file with the Detect V2 API. The first call submits the run and returns its - * id; the second submits and polls, and writes the outputs next to the input on success. + * De-identifies a local file with the Detect V2 API. With {@code waitForResult} false the sample + * submits the run and returns its id; with it true the sample submits, polls, and on success the + * SDK writes the outputs into {@code outputDirectory} (the working directory when unset). Only one + * path runs, so each execution creates a single run. */ public class DeidentifyFileSample { public static void main(String[] args) throws SkyflowException { + // false: submit only and retrieve the result later with GetRunSample. + // true: submit and poll until the run is terminal or the budget runs out. + boolean waitForResult = true; + Credentials credentials = new Credentials(); credentials.setPath(""); // Replace with the path to the credentials file @@ -32,16 +38,19 @@ public static void main(String[] args) throws SkyflowException { .build(); try { - // Submit only: the API's own behaviour. Keep the run id and retrieve the result with getRun. - DeidentifyFileResponse submitted = skyflowClient.detect().deidentifyFile( - DeidentifyFileRequest.builder() - .filePath("") // BASE64 and the format are derived from the file - .configurationId("") // Replace with a Detect configuration id - .build()); - System.out.println("Submitted run " + submitted.getRunId()); + if (!waitForResult) { + // Submit only: the API's own behaviour. Keep the run id and retrieve the result with getRun. + DeidentifyFileResponse submitted = skyflowClient.detect().deidentifyFile( + DeidentifyFileRequest.builder() + .filePath("") // BASE64 and the format are derived from the file + .configurationId("") // Replace with a Detect configuration id + .build()); + System.out.println("Submitted run " + submitted.getRunId() + "; retrieve it with getRun"); + return; + } // Submit and poll: waits up to 90 seconds with exponential backoff, then writes - // processed-. and processed-.json into the output directory. + // processed-. and processed-entities-.json into the output directory. DeidentifyFileResponse polled = skyflowClient.detect().deidentifyFile( DeidentifyFileRequest.builder() .filePath("") diff --git a/flowvault/samples/src/main/java/com/example/detect/GetRunSample.java b/flowvault/samples/src/main/java/com/example/detect/GetRunSample.java index cc3e7667..9d704f25 100644 --- a/flowvault/samples/src/main/java/com/example/detect/GetRunSample.java +++ b/flowvault/samples/src/main/java/com/example/detect/GetRunSample.java @@ -3,6 +3,7 @@ import com.skyflow.Skyflow; import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; +import com.skyflow.detect.DataSourceType; import com.skyflow.detect.DetectRunStatus; import com.skyflow.detect.FileOutput; import com.skyflow.detect.GetRunRequest; @@ -16,7 +17,9 @@ import java.util.Base64; /** - * Retrieves a Detect file run by id and, once it has succeeded, writes the base64 outputs to disk. + * Retrieves a Detect file run by id and, once it has succeeded, writes its base64 outputs to disk. + * Submit-and-poll (see DeidentifyFileSample) lets the SDK write the files; this sample shows the + * same work for a run that was submitted without polling. */ public class GetRunSample { public static void main(String[] args) throws Exception { @@ -43,8 +46,13 @@ public static void main(String[] args) throws Exception { System.out.println("Run " + run.getRunId() + " status: " + run.getStatus()); if (run.getStatus() == DetectRunStatus.SUCCESS) { for (FileOutput output : run.getOutput()) { + if (run.getOutputType() != DataSourceType.BASE64) { + // PRESIGNED_URL outputs carry a URL, not base64: download them instead of decoding. + System.out.println(output.getProcessedFileType() + " available at " + output.getProcessedFile()); + continue; + } String name = "processed-" + run.getRunId() + "-" + output.getProcessedFileType() - + "." + output.getProcessedFileExtension().name().toLowerCase(); + + "." + extensionOf(output); Files.write(new File(name).toPath(), Base64.getDecoder().decode(output.getProcessedFile())); System.out.println("Wrote " + name); } @@ -59,4 +67,16 @@ public static void main(String[] args) throws Exception { e.printStackTrace(); } } + + /** + * The extension can be absent on an output. Mirror the SDK's own writer: entity outputs fall + * back to json, anything else to bin. + */ + private static String extensionOf(FileOutput output) { + if (output.getProcessedFileExtension() != null) { + return output.getProcessedFileExtension().name().toLowerCase(); + } + String type = output.getProcessedFileType(); + return type != null && type.toUpperCase().contains("ENTITIES") ? "json" : "bin"; + } } diff --git a/flowvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java b/flowvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java index 587d58eb..3e0cd0d8 100644 --- a/flowvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java +++ b/flowvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java @@ -58,11 +58,25 @@ public static void main(String[] args) throws Exception { System.out.println("Status: " + response.getStatus()); if (response.getStatus() == DetectRunStatus.SUCCESS) { + int index = 0; for (FileOutput output : response.getOutput()) { - String name = "reidentified-" + input.getName(); - Files.write(new File(input.getParentFile(), name).toPath(), - Base64.getDecoder().decode(output.getProcessedFile())); - System.out.println("Wrote " + name + " (" + output.getProcessedFileType() + ")"); + index++; + if (response.getOutputType() != DataSourceType.BASE64) { + // PRESIGNED_URL outputs carry a URL, not base64: download them instead of decoding. + System.out.println(output.getProcessedFileType() + " available at " + output.getProcessedFile()); + continue; + } + // One file per output: the output type keeps the names apart, the index guards against + // two outputs of the same type (the SDK's own writer follows the same pattern). + String type = output.getProcessedFileType() == null ? String.valueOf(index) : output.getProcessedFileType(); + String name = "reidentified-" + type + "-" + input.getName(); + File target = new File(input.getParentFile(), name); + if (target.exists()) { + name = "reidentified-" + type + "-" + index + "-" + input.getName(); + target = new File(input.getParentFile(), name); + } + Files.write(target.toPath(), Base64.getDecoder().decode(output.getProcessedFile())); + System.out.println("Wrote " + name); } System.out.println("Metrics: " + response.getMetrics()); } diff --git a/pom.xml b/pom.xml index e9279fd4..c6a27079 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ com.skyflow.generated.rest.*: - com.skyflow.generated.auth.*: + com.skyflow.generated.common.*: diff --git a/skyvault/README.md b/skyvault/README.md index b5302dd5..9a5db651 100644 --- a/skyvault/README.md +++ b/skyvault/README.md @@ -1678,11 +1678,15 @@ Detect configurations are created in Studio or through the management API. The S | `getRun(GetRunRequest)` | `com.skyflow.detect.GetRunRequest` | `com.skyflow.detect.GetRunResponse` | Retrieve the status and outputs of a Detect file run | | `checkGuardrails(CheckGuardrailsRequest)` | `com.skyflow.detect.CheckGuardrailsRequest` | `com.skyflow.detect.CheckGuardrailsResponse` | Screen text for toxicity and denied topics | -> Detect V2 is in beta. +## Before you start +- **Role.** The service account needs the Detect Invoker, Detect Manager or Vault Owner role on the vault. Detect Invoker can de-identify data and write vault tokens into the vault; Detect Manager adds the ability to create, update and delete Detect configurations. Re-identifying values stored as `VAULT_TOKEN` is governed like detokenization: the caller also needs a policy that grants the Detokenization action on the destination table and columns, unless it is a Vault Owner. Detect Invoker or Detect Manager alone is not enough. +- **Configuration.** `configurationId` is the id of a Detect configuration created through the management API; the SDK does not create, update or delete them. The alternative is an inline `DetectConfiguration` passed as `configuration` (see [Detect configuration](#detect-configuration)). +- **Destination for vault tokens.** An entity de-identified with `VAULT_TOKEN` stores its value in the `table.column` named by `destination`. That table and column must already exist in the vault; Detect writes into them but does not create them. +- **API reference.** Every Detect request, response and configuration class is listed in the [API reference](../docs/api_reference.md#detect-api). ## Deidentify string -`DeidentifyStringRequest` takes the text plus, optionally, `configurationId` (a stored Detect configuration) and/or `configuration` (an inline `DetectConfiguration`). Both are optional on the API and are sent exactly as supplied. The SDK fills the vault id from the controller. +`DeidentifyStringRequest` takes the text plus exactly one of `configurationId` (a stored Detect configuration) or `configuration` (an inline `DetectConfiguration`). Both fields are sent exactly as supplied. For an inline configuration the SDK fills the vault id from the controller. ```java import com.skyflow.detect.*; @@ -1730,6 +1734,60 @@ System.out.println(response.getMetrics().getWordCount()); `DeidentifyStringResponse` carries `getProcessedText()`, `getEntities()` (a `List` with token, entity type, location and confidence scores; never `null`) and `getMetrics()`. +## Detect configuration + +`DetectConfiguration` is the inline form of a stored configuration and accepts the same options. `detect` applies to string and file inputs; `fileMapping` and `media` apply to file inputs only. + +| Class | Builder methods | Notes | +|-------|-----------------|-------| +| `Detect` | `entities`, `objectEntities`, `restrict`, `skip`, `customTypes`, `returnEntities` | `restrict` and `skip` are regexes that are always, respectively never, treated as sensitive. `returnEntities` is `EXCLUDE_SENSITIVE_DATA` (server default), `ALL` or `NONE`. | +| `Entity` | `entityType`, `deidentificationType`, `destination`, `transformation` | `entityType` defaults to `ALL`. `deidentificationType` is `ENTITY_UNIQUE_COUNTER` (server default), `ENTITY_ONLY`, `MASK` or `VAULT_TOKEN`. `destination` is used only with `VAULT_TOKEN`. | +| `Transformation` / `ShiftDates` | `shiftDates(ShiftDates)`; `minDays`, `maxDays` | Shifts detected dates by a random number of days within the range. | +| `CustomType` | `label`, `match` | A regex-defined entity type. `label` is reported as the entity type of its matches. | +| `ObjectEntity` | `entityType`, `deidentificationType` | Visual objects in images: `FACE`, `LICENSE_PLATE`, `LOGO`, `SIGNATURE` or `ALL`, handled with `REDACT` or `UNREDACT`. File inputs only. | +| `FileMapping` | `source`, `destination`, `outputFileNameSuffix`, `entitiesDestination`, `objectEntitiesDestination` | Where the processed file and the entity files are written. File inputs only. | +| `Media` | `audio(Audio)`, `document(Document)`, `image(Image)` | Media-type options. File inputs only. | +| `Audio` / `Bleep` | `outputProcessedAudio`, `outputTranscription`, `bleep`; `startPadding`, `stopPadding`, `frequency`, `gain` | `outputTranscription` is `NONE`, `TRANSCRIPTION`, `MEDICAL_TRANSCRIPTION`, `DIARIZED_TRANSCRIPTION` or `MEDICAL_DIARIZED_TRANSCRIPTION`. `Bleep` is the tone laid over detected speech; paddings are in seconds, frequency in Hz. | +| `Document` / `Pdf` | `pdf(Pdf)`; `processingMode`, `density`, `maxResolution` | `processingMode` is `NONE`, `OCR` or `TEXT_LAYER`. `density` is the rendering DPI. | +| `Image` | `outputProcessedImage`, `outputOcrText`, `maskingMethod` | `maskingMethod` is `NONE`, `BLUR` or `BLACKBOX`. | + +```java +DetectConfiguration configuration = DetectConfiguration.builder() + .detect(Detect.builder() + .entities(Arrays.asList( + Entity.builder() + .entityType(EntityType.DOB) + .deidentificationType(DeidentificationType.ENTITY_UNIQUE_COUNTER) + .transformation(Transformation.builder() + .shiftDates(ShiftDates.builder().minDays(10).maxDays(30).build()) + .build()) + .build(), + Entity.builder().entityType(EntityType.ALL).build())) + .objectEntities(Collections.singletonList( + ObjectEntity.builder() + .entityType(ObjectEntityType.FACE) + .deidentificationType(ObjectDeidentificationType.REDACT) + .build())) + .customTypes(Collections.singletonList( + CustomType.builder() + .label("EMPLOYEE_ID") + .match(Collections.singletonList("EMP-[0-9]{6}")) + .build())) + .restrict(Collections.singletonList("[0-9]{3}-[0-9]{2}-[0-9]{4}")) + .build()) + .media(Media.builder() + .image(Image.builder().maskingMethod(MaskingMethod.BLUR).outputOcrText(true).build()) + .document(Document.builder() + .pdf(Pdf.builder().processingMode(PdfProcessingMode.OCR).build()) + .build()) + .audio(Audio.builder() + .outputTranscription(OutputTranscriptionType.TRANSCRIPTION) + .bleep(Bleep.builder().startPadding(0.5f).stopPadding(0.5f).build()) + .build()) + .build()) + .build(); +``` + ## Deidentify file File de-identification is asynchronous on the API: the submit call returns a run id and the result is retrieved from the run. `deidentifyFile` exposes both modes. @@ -1739,6 +1797,10 @@ File de-identification is asynchronous on the API: the submit call returns a run The file is supplied in one of three ways: `dataSource` plus `value` (`BASE64` content, a `SKYFLOW_ID`, or a `PRESIGNED_URL`), or `file(File)` / `filePath(String)`, which read and encode a local file and infer `dataFormat` from its extension. Supply exactly one of `value`, `file` or `filePath`. Either `configurationId` or an inline `configuration` is passed through as given. +`dataFormat` accepts every `FileDataFormat`: `BMP`, `CSV`, `DCM`, `DOC`, `DOCX`, `GIF`, `JPEG`, `JPG`, `JSON`, `JSONL`, `MP3`, `PDF`, `PNG`, `PPT`, `PPTX`, `TIF`, `TIFF`, `TXT`, `WAV`, `XLS`, `XLSX`, `XML` and `ZIP`. The `VAULT_TOKEN` de-identification type is supported only for `TXT`, `CSV`, `JSON`, `JSONL`, `XML`, `DOCX`, `XLSX` and `PPTX`. + +`outputDirectory` is meaningful only when polling. Setting it without `pollOptions` fails client-side validation with a `SkyflowException` before any request is sent. + ```java // Submit only DeidentifyFileResponse submitted = skyflowClient.detect().deidentifyFile( @@ -1778,7 +1840,7 @@ Outputs are written only when polling reached `SUCCESS`, the request was built f With `pollOptions` set, `deidentifyFile` polls on the thread that called it: each lookup is a synchronous `getRun` followed by a sleep, until the run is terminal or the budget runs out. No other thread, lock or connection is held while it waits, so other SDK calls are unaffected, but the calling thread is. If that thread is your main thread, a request thread or an event loop, run the call elsewhere. -**Run the blocking call on a thread you own.** Simplest when you process a few files at a time. The SDK still enforces the budget and writes outputs to disk; your thread is parked for the whole poll. +**Run the blocking call on a thread you own.** Simplest when you process a few files at a time. The SDK still enforces the budget and writes outputs to disk; your thread is parked for the whole poll. [DeidentifyFileAsyncSample.java](samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java) runs several files this way on a bounded pool. ```java ExecutorService pool = Executors.newFixedThreadPool(4); // or Executors.newVirtualThreadPerTaskExecutor() on JDK 21+ @@ -1839,6 +1901,8 @@ Either way the main thread only pays for the submit round trip. Avoid `new Threa ## Reidentify string +Re-identification looks tokens up in the vault, so it applies to values that were de-identified with `VAULT_TOKEN`. Placeholders produced by `ENTITY_UNIQUE_COUNTER`, `ENTITY_ONLY` or `MASK` are not stored anywhere and cannot be re-identified. + `ReidentifyStringRequest` takes the tokenized text and an optional list of `RedactionLevel` rules. For skyvault vaults each rule names an `entityName` and the `redactionType` to apply to it: `PLAIN_TEXT` reveals the original value, `MASKED` masks it, `REDACTED` keeps the token, `DEFAULT` applies the vault's default. Without rules every token is replaced by its original value. ```java @@ -1860,11 +1924,11 @@ System.out.println(response.getProcessedText()); // My name is John Doe and my email is j*******@acme.com. ``` -A `RedactionLevel` is expected to name one source (`entityName`) and one replacement (`redactionType`). Every field is optional on the API, so the SDK passes the list through as given and the server enforces the combination rules. The `tokenGroupName` and `redactionPattern` fields apply to flowvault vaults only. +A `RedactionLevel` names one source and one replacement. On skyvault vaults the source is an `entityName` and the replacement a `redactionType`, the same `com.skyflow.enums.RedactionType` that `get` and `detokenize` use. The `tokenGroupName` and `redactionPattern` fields are the flowvault equivalents and do not apply to skyvault vaults. Every field is optional on the API, so the SDK passes the list through as given and the server rejects invalid combinations. ## Reidentify file -`reidentifyFile` is synchronous: the re-identified file comes back in the response, not through a run id. `ReidentifyFileRequest` takes a `dataSource` (`BASE64`, `SKYFLOW_ID` or `PRESIGNED_URL`), the matching `value`, an optional `dataFormat` and the same optional `RedactionLevel` rules as `reidentifyString`. Re-identification supports text-based formats such as TXT, CSV, JSON, JSONL, XML, DOCX, XLSX and PPTX. +`reidentifyFile` is synchronous: the re-identified file comes back in the response, not through a run id. `ReidentifyFileRequest` takes a `dataSource` (`BASE64`, `SKYFLOW_ID` or `PRESIGNED_URL`), the matching `value`, an optional `dataFormat` and the same optional `RedactionLevel` rules as `reidentifyString`. `dataFormat` is limited to the formats that support `VAULT_TOKEN`: `TXT`, `CSV`, `JSON`, `JSONL`, `XML`, `DOCX`, `XLSX` and `PPTX`. ```java byte[] content = Files.readAllBytes(Paths.get("tokenized.txt")); @@ -1917,7 +1981,7 @@ switch (run.getStatus()) { ## Check guardrails -`checkGuardrails` screens text for toxicity and for a list of denied topics, which makes it a natural pre-LLM check. Each check runs only when requested: `getToxic()` is `null` unless `checkToxicity(true)` was set, and `getDeniedTopic()` is `null` unless `denyTopics` was supplied. `getValidation()` is `FAILED` if any requested check triggered. +`checkGuardrails` screens text for toxicity and for a list of denied topics, which makes it a natural pre-LLM check. `checkToxicity` and `denyTopics` are optional: the SDK sends each one only when you set it and does not fill in a default. The response is passed through as returned, so `getToxic()`, `getDeniedTopic()` and `getValidation()` carry exactly what the API sent back. ```java CheckGuardrailsResponse response = skyflowClient.detect().checkGuardrails( @@ -1934,7 +1998,7 @@ if (response.getValidation() == GuardrailsValidation.FAILED) { All Detect methods throw `SkyflowException` as described in [Error Handling](#error-handling). Client-side validation fails before any network call. -See the samples [DeidentifyStringSample.java](samples/src/main/java/com/example/detect/DeidentifyStringSample.java), [DeidentifyFileSample.java](samples/src/main/java/com/example/detect/DeidentifyFileSample.java), [ReidentifyStringSample.java](samples/src/main/java/com/example/detect/ReidentifyStringSample.java), [ReidentifyFileSample.java](samples/src/main/java/com/example/detect/ReidentifyFileSample.java), [GetRunSample.java](samples/src/main/java/com/example/detect/GetRunSample.java) and [CheckGuardrailsSample.java](samples/src/main/java/com/example/detect/CheckGuardrailsSample.java). +See the samples [DeidentifyStringSample.java](samples/src/main/java/com/example/detect/DeidentifyStringSample.java), [DeidentifyFileSample.java](samples/src/main/java/com/example/detect/DeidentifyFileSample.java), [DeidentifyFileAsyncSample.java](samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java), [ReidentifyStringSample.java](samples/src/main/java/com/example/detect/ReidentifyStringSample.java), [ReidentifyFileSample.java](samples/src/main/java/com/example/detect/ReidentifyFileSample.java), [GetRunSample.java](samples/src/main/java/com/example/detect/GetRunSample.java) and [CheckGuardrailsSample.java](samples/src/main/java/com/example/detect/CheckGuardrailsSample.java). # Connections diff --git a/skyvault/api-report/skyflow-java.baseline.jar b/skyvault/api-report/skyflow-java.baseline.jar index 309482bf..afff0c48 100644 Binary files a/skyvault/api-report/skyflow-java.baseline.jar and b/skyvault/api-report/skyflow-java.baseline.jar differ diff --git a/skyvault/samples/src/main/java/com/example/detect/CheckGuardrailsSample.java b/skyvault/samples/src/main/java/com/example/detect/CheckGuardrailsSample.java index 25947b1a..67d72076 100644 --- a/skyvault/samples/src/main/java/com/example/detect/CheckGuardrailsSample.java +++ b/skyvault/samples/src/main/java/com/example/detect/CheckGuardrailsSample.java @@ -13,17 +13,17 @@ import java.util.Arrays; /** - * Screens text for toxicity and denied topics before it reaches an LLM. + * Screens a prompt for toxicity and denied topics before it is sent to an LLM. */ public class CheckGuardrailsSample { public static void main(String[] args) throws SkyflowException { Credentials credentials = new Credentials(); - credentials.setPath(""); // Replace with the path to the credentials file + credentials.setPath(""); // Replace with the path to the credentials file VaultConfig vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(""); // Replace with the ID of the vault - vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault - vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) Skyflow skyflowClient = Skyflow.builder() .setLogLevel(LogLevel.ERROR) @@ -31,17 +31,18 @@ public static void main(String[] args) throws SkyflowException { .addSkyflowCredentials(credentials) .build(); + String userPrompt = "Which party should I vote for?"; try { CheckGuardrailsResponse response = skyflowClient.detect().checkGuardrails( CheckGuardrailsRequest.builder() - .text("Which candidate should I vote for in the upcoming election?") - .checkToxicity(true) // server default is true when omitted + .text(userPrompt) + .checkToxicity(true) .denyTopics(Arrays.asList("politics", "medical advice")) .build()); - System.out.println("Validation: " + response.getValidation() - + " toxic=" + response.getToxic() + " deniedTopic=" + response.getDeniedTopic()); if (response.getValidation() == GuardrailsValidation.FAILED) { - System.out.println("Blocked by guardrails"); + System.out.println("Blocked: toxic=" + response.getToxic() + " deniedTopic=" + response.getDeniedTopic()); + } else { + System.out.println("Prompt passed guardrails."); } } catch (SkyflowException e) { System.err.println("Error during checkGuardrails:"); diff --git a/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java b/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java new file mode 100644 index 00000000..4d223b12 --- /dev/null +++ b/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileAsyncSample.java @@ -0,0 +1,94 @@ +package com.example.detect; + +import com.skyflow.Skyflow; +import com.skyflow.config.Credentials; +import com.skyflow.config.VaultConfig; +import com.skyflow.detect.DeidentifyFileRequest; +import com.skyflow.detect.DeidentifyFileResponse; +import com.skyflow.detect.DetectRunStatus; +import com.skyflow.detect.PollOptions; +import com.skyflow.enums.Env; +import com.skyflow.enums.LogLevel; +import com.skyflow.errors.SkyflowException; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +/** + * De-identifies several local files concurrently with polling enabled. Each task calls + * deidentifyFile with pollOptions, so the SDK polls the run with exponential backoff and writes + * the outputs to outputDirectory on success. The blocking poll runs on a pool thread, not on the + * caller's thread, and the pool is bounded because every in-flight run parks one thread. + */ +public class DeidentifyFileAsyncSample { + public static void main(String[] args) throws SkyflowException, InterruptedException { + Credentials credentials = new Credentials(); + credentials.setPath(""); // Replace with the path to the credentials file + + VaultConfig vaultConfig = new VaultConfig(); + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + + Skyflow skyflowClient = Skyflow.builder() + .setLogLevel(LogLevel.ERROR) + .addVaultConfig(vaultConfig) + .addSkyflowCredentials(credentials) + .build(); + + List files = Arrays.asList("", ""); // Replace with the files to de-identify + + // One thread per concurrent run; size this to how many runs you want in flight at once. + ExecutorService pool = Executors.newFixedThreadPool(2); + List> futures = new ArrayList<>(); + try { + for (String file : files) { + // submit() rather than execute(): the Future carries the response or the SkyflowException, + // and future.cancel(true) interrupts the poll, which returns the last run the SDK saw. + futures.add(pool.submit(() -> skyflowClient.detect().deidentifyFile( + DeidentifyFileRequest.builder() + .filePath(file) // BASE64 and the format are derived from the file + .configurationId("") // Replace with a Detect configuration id + .pollOptions(PollOptions.builder().waitTime(120).build()) + .outputDirectory("") // optional; defaults to the working directory + .build()))); + } + + // The main thread is free until here; block on each result only when it is needed. + for (int i = 0; i < futures.size(); i++) { + String file = files.get(i); + try { + DeidentifyFileResponse response = futures.get(i).get(); + System.out.println(file + ": run " + response.getRunId() + " " + response.getStatus()); + if (response.getStatus() == DetectRunStatus.SUCCESS) { + // Outputs are already on disk as processed-. and processed-entities-.json + System.out.println(" outputs: " + response.getOutput().size() + ", metrics: " + response.getMetrics()); + } else if (response.getStatus() == DetectRunStatus.FAILED) { + System.err.println(" run failed: " + response.getMessage()); + } else { + // IN_PROGRESS or QUEUED: the budget ran out; resume with getRun(runId) + System.out.println(" still running; poll later with getRun(" + response.getRunId() + ")"); + } + } catch (ExecutionException e) { + // The task threw: unwrap the SkyflowException raised inside deidentifyFile. + Throwable cause = e.getCause(); + if (cause instanceof SkyflowException) { + System.err.println(file + ": error during deidentifyFile: " + cause.getMessage()); + } else { + System.err.println(file + ": unexpected error"); + cause.printStackTrace(); + } + } + } + } finally { + pool.shutdown(); + pool.awaitTermination(1, TimeUnit.MINUTES); + } + } +} diff --git a/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java b/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java index 4b3c8b8d..3f479e3e 100644 --- a/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java +++ b/skyvault/samples/src/main/java/com/example/detect/DeidentifyFileSample.java @@ -6,25 +6,30 @@ import com.skyflow.detect.DeidentifyFileRequest; import com.skyflow.detect.DeidentifyFileResponse; import com.skyflow.detect.DetectRunStatus; -import com.skyflow.detect.FileOutput; import com.skyflow.detect.PollOptions; import com.skyflow.enums.Env; import com.skyflow.enums.LogLevel; import com.skyflow.errors.SkyflowException; /** - * De-identifies a local file. The first call submits the run and returns its id; the second - * submits and polls until the run completes, writing the outputs to disk on success. + * De-identifies a local file with the Detect V2 API. With {@code waitForResult} false the sample + * submits the run and returns its id; with it true the sample submits, polls, and on success the + * SDK writes the outputs into {@code outputDirectory} (the working directory when unset). Only one + * path runs, so each execution creates a single run. */ public class DeidentifyFileSample { public static void main(String[] args) throws SkyflowException { + // false: submit only and retrieve the result later with GetRunSample. + // true: submit and poll until the run is terminal or the budget runs out. + boolean waitForResult = true; + Credentials credentials = new Credentials(); - credentials.setPath(""); // Replace with the path to the credentials file + credentials.setPath(""); // Replace with the path to the credentials file VaultConfig vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(""); // Replace with the ID of the vault - vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault - vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) Skyflow skyflowClient = Skyflow.builder() .setLogLevel(LogLevel.ERROR) @@ -32,42 +37,38 @@ public static void main(String[] args) throws SkyflowException { .addSkyflowCredentials(credentials) .build(); - // 1. Submit only: returns the run id, retrieve the result later with getRun. try { - DeidentifyFileResponse submitted = skyflowClient.detect().deidentifyFile( - DeidentifyFileRequest.builder() - .filePath("") // BASE64 data source, format inferred from the extension - .configurationId("") // Replace with a Detect configuration id - .build()); - System.out.println("Run id: " + submitted.getRunId()); // getStatus() is null, nothing written to disk - } catch (SkyflowException e) { - System.err.println("Error during deidentifyFile (submit only):"); - e.printStackTrace(); - } + if (!waitForResult) { + // Submit only: the API's own behaviour. Keep the run id and retrieve the result with getRun. + DeidentifyFileResponse submitted = skyflowClient.detect().deidentifyFile( + DeidentifyFileRequest.builder() + .filePath("") // BASE64 and the format are derived from the file + .configurationId("") // Replace with a Detect configuration id + .build()); + System.out.println("Submitted run " + submitted.getRunId() + "; retrieve it with getRun"); + return; + } - // 2. Submit and poll: blocks the calling thread until the run is terminal or the budget runs out. - try { - DeidentifyFileResponse response = skyflowClient.detect().deidentifyFile( + // Submit and poll: waits up to 90 seconds with exponential backoff, then writes + // processed-. and processed-entities-.json into the output directory. + DeidentifyFileResponse polled = skyflowClient.detect().deidentifyFile( DeidentifyFileRequest.builder() .filePath("") .configurationId("") - .pollOptions(PollOptions.builder().waitTime(120).build()) // 1..300 s, default 60 - .outputDirectory("") // optional, defaults to the working directory + .pollOptions(PollOptions.builder().waitTime(90).build()) + .outputDirectory("") // optional; defaults to the working directory .build()); - System.out.println("Run id: " + response.getRunId() + " status: " + response.getStatus()); - if (response.getStatus() == DetectRunStatus.SUCCESS) { - // Outputs are already on disk as processed-. and processed-entities-.json - for (FileOutput output : response.getOutput()) { - System.out.println(output.getProcessedFileType() + " -> " + output.getProcessedFileExtension()); - } - System.out.println("Pages: " + response.getMetrics().getPages()); - } else if (response.getStatus() == DetectRunStatus.FAILED) { - System.err.println("Run failed: " + response.getMessage()); + + System.out.println("Run " + polled.getRunId() + " status: " + polled.getStatus()); + if (polled.getStatus() == DetectRunStatus.SUCCESS) { + System.out.println("Outputs: " + polled.getOutput().size() + ", metrics: " + polled.getMetrics()); + } else if (polled.getStatus() == DetectRunStatus.FAILED) { + System.err.println("Run failed: " + polled.getMessage()); } else { - System.out.println("Budget ran out, resume with getRun(" + response.getRunId() + ")"); + System.out.println("Still running; poll later with getRun(" + polled.getRunId() + ")"); } } catch (SkyflowException e) { - System.err.println("Error during deidentifyFile (submit and poll):"); + System.err.println("Error during deidentifyFile:"); e.printStackTrace(); } } diff --git a/skyvault/samples/src/main/java/com/example/detect/DeidentifyStringSample.java b/skyvault/samples/src/main/java/com/example/detect/DeidentifyStringSample.java index d9891753..e5cbaa53 100644 --- a/skyvault/samples/src/main/java/com/example/detect/DeidentifyStringSample.java +++ b/skyvault/samples/src/main/java/com/example/detect/DeidentifyStringSample.java @@ -20,19 +20,18 @@ import java.util.Collections; /** - * De-identifies sensitive data in a string, first with a stored Detect configuration and then - * with an inline configuration. For a skyvault vault a VAULT_TOKEN entity's destination is the - * "table.column" that stores the value. + * De-identifies sensitive data in a string with the Detect V2 API, first with a stored + * configuration id and then with an inline configuration. */ public class DeidentifyStringSample { public static void main(String[] args) throws SkyflowException { Credentials credentials = new Credentials(); - credentials.setPath(""); // Replace with the path to the credentials file + credentials.setPath(""); // Replace with the path to the credentials file VaultConfig vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(""); // Replace with the ID of the vault - vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault - vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) Skyflow skyflowClient = Skyflow.builder() .setLogLevel(LogLevel.ERROR) @@ -47,7 +46,7 @@ public static void main(String[] args) throws SkyflowException { DeidentifyStringResponse response = skyflowClient.detect().deidentifyString( DeidentifyStringRequest.builder() .text(text) - .configurationId("") // Replace with a Detect configuration id + .configurationId("") // Replace with a Detect configuration id .build()); System.out.println("Processed text: " + response.getProcessedText()); } catch (SkyflowException e) { @@ -62,7 +61,7 @@ public static void main(String[] args) throws SkyflowException { Entity.builder() .entityType(EntityType.NAME) .deidentificationType(DeidentificationType.VAULT_TOKEN) - .destination("persons.name") // skyvault: table.column that stores the value + .destination(".") // skyvault: table.column that stores the value .build(), Entity.builder() .entityType(EntityType.ALL) @@ -81,10 +80,12 @@ public static void main(String[] args) throws SkyflowException { .build()); System.out.println("Processed text: " + response.getProcessedText()); for (DetectedEntity entity : response.getEntities()) { - System.out.println(entity.getEntityType() + " " + entity.getToken() - + " [" + entity.getLocation().getStartIndex() + "," + entity.getLocation().getEndIndex() + "]"); + System.out.printf("%-16s %-18s [%d,%d] %s%n", + entity.getEntityType(), entity.getToken(), + entity.getLocation().getStartIndex(), entity.getLocation().getEndIndex(), + entity.getEntityScores()); } - System.out.println("Word count: " + response.getMetrics().getWordCount()); + System.out.println("Metrics: " + response.getMetrics()); } catch (SkyflowException e) { System.err.println("Error during deidentifyString (inline configuration):"); e.printStackTrace(); diff --git a/skyvault/samples/src/main/java/com/example/detect/GetRunSample.java b/skyvault/samples/src/main/java/com/example/detect/GetRunSample.java index 943c92fb..9d704f25 100644 --- a/skyvault/samples/src/main/java/com/example/detect/GetRunSample.java +++ b/skyvault/samples/src/main/java/com/example/detect/GetRunSample.java @@ -3,6 +3,8 @@ import com.skyflow.Skyflow; import com.skyflow.config.Credentials; import com.skyflow.config.VaultConfig; +import com.skyflow.detect.DataSourceType; +import com.skyflow.detect.DetectRunStatus; import com.skyflow.detect.FileOutput; import com.skyflow.detect.GetRunRequest; import com.skyflow.detect.GetRunResponse; @@ -10,19 +12,24 @@ import com.skyflow.enums.LogLevel; import com.skyflow.errors.SkyflowException; +import java.io.File; +import java.nio.file.Files; +import java.util.Base64; + /** - * Retrieves the status and, once complete, the outputs of a file de-identification run submitted - * with deidentifyFile. + * Retrieves a Detect file run by id and, once it has succeeded, writes its base64 outputs to disk. + * Submit-and-poll (see DeidentifyFileSample) lets the SDK write the files; this sample shows the + * same work for a run that was submitted without polling. */ public class GetRunSample { - public static void main(String[] args) throws SkyflowException { + public static void main(String[] args) throws Exception { Credentials credentials = new Credentials(); - credentials.setPath(""); // Replace with the path to the credentials file + credentials.setPath(""); // Replace with the path to the credentials file VaultConfig vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(""); // Replace with the ID of the vault - vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault - vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) Skyflow skyflowClient = Skyflow.builder() .setLogLevel(LogLevel.ERROR) @@ -32,24 +39,44 @@ public static void main(String[] args) throws SkyflowException { try { GetRunResponse run = skyflowClient.detect().getRun( - GetRunRequest.builder().runId("").build()); // Replace with the run id from deidentifyFile - System.out.println("Status: " + run.getStatus()); - switch (run.getStatus()) { - case SUCCESS: - for (FileOutput output : run.getOutput()) { - // output.getProcessedFile() is base64 or a presigned URL, per run.getOutputType() - System.out.println(output.getProcessedFileType() + " -> " + output.getProcessedFileExtension()); + GetRunRequest.builder() + .runId("") // Replace with the run id returned by deidentifyFile + .build()); + + System.out.println("Run " + run.getRunId() + " status: " + run.getStatus()); + if (run.getStatus() == DetectRunStatus.SUCCESS) { + for (FileOutput output : run.getOutput()) { + if (run.getOutputType() != DataSourceType.BASE64) { + // PRESIGNED_URL outputs carry a URL, not base64: download them instead of decoding. + System.out.println(output.getProcessedFileType() + " available at " + output.getProcessedFile()); + continue; } - break; - case FAILED: - System.err.println("Run failed: " + run.getMessage()); - break; - default: // QUEUED, IN_PROGRESS, UNKNOWN: poll again later - break; + String name = "processed-" + run.getRunId() + "-" + output.getProcessedFileType() + + "." + extensionOf(output); + Files.write(new File(name).toPath(), Base64.getDecoder().decode(output.getProcessedFile())); + System.out.println("Wrote " + name); + } + System.out.println("Metrics: " + run.getMetrics()); + } else if (run.getStatus() == DetectRunStatus.FAILED) { + System.err.println("Run failed: " + run.getMessage()); + } else { + System.out.println("Run still pending, poll again later."); } } catch (SkyflowException e) { System.err.println("Error during getRun:"); e.printStackTrace(); } } + + /** + * The extension can be absent on an output. Mirror the SDK's own writer: entity outputs fall + * back to json, anything else to bin. + */ + private static String extensionOf(FileOutput output) { + if (output.getProcessedFileExtension() != null) { + return output.getProcessedFileExtension().name().toLowerCase(); + } + String type = output.getProcessedFileType(); + return type != null && type.toUpperCase().contains("ENTITIES") ? "json" : "bin"; + } } diff --git a/skyvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java b/skyvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java index 443e51dd..41c9d765 100644 --- a/skyvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java +++ b/skyvault/samples/src/main/java/com/example/detect/ReidentifyFileSample.java @@ -9,31 +9,31 @@ import com.skyflow.detect.FileDataFormat; import com.skyflow.detect.FileOutput; import com.skyflow.detect.RedactionLevel; -import com.skyflow.detect.RedactionType; +import com.skyflow.enums.RedactionType; import com.skyflow.detect.ReidentifyFileRequest; import com.skyflow.detect.ReidentifyFileResponse; import com.skyflow.enums.Env; import com.skyflow.enums.LogLevel; import com.skyflow.errors.SkyflowException; +import java.io.File; import java.nio.file.Files; -import java.nio.file.Paths; import java.util.Base64; import java.util.Collections; /** - * Replaces tokens in a de-identified file with their original values, or with a redacted form - * chosen per entity type. Synchronous: the re-identified file comes back in the response. + * Re-identifies the tokens in a text file with the Detect V2 API. The file is sent as base64 and + * the re-identified file is returned synchronously and written next to the input. */ public class ReidentifyFileSample { public static void main(String[] args) throws Exception { Credentials credentials = new Credentials(); - credentials.setPath(""); // Replace with the path to the credentials file + credentials.setPath(""); // Replace with the path to the credentials file VaultConfig vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(""); // Replace with the ID of the vault - vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault - vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) Skyflow skyflowClient = Skyflow.builder() .setLogLevel(LogLevel.ERROR) @@ -41,27 +41,46 @@ public static void main(String[] args) throws Exception { .addSkyflowCredentials(credentials) .build(); - byte[] content = Files.readAllBytes(Paths.get("")); // e.g. processed-notes.txt + File input = new File(""); // Replace with a file produced by deidentification + String base64 = Base64.getEncoder().encodeToString(Files.readAllBytes(input.toPath())); try { ReidentifyFileResponse response = skyflowClient.detect().reidentifyFile( ReidentifyFileRequest.builder() .dataSource(DataSourceType.BASE64) - .value(Base64.getEncoder().encodeToString(content)) + .value(base64) .dataFormat(FileDataFormat.TXT) + // Optional: render one entity type with a redaction type instead of its plain value. .redactionLevel(Collections.singletonList( RedactionLevel.builder() - .entityName(EntityType.NAME) - .redactionType(RedactionType.PLAIN_TEXT) + .entityName(EntityType.NAME) // Entity type to target + .redactionType(RedactionType.PLAIN_TEXT) // PLAIN_TEXT, MASKED, REDACTED or DEFAULT .build())) .build()); + System.out.println("Status: " + response.getStatus()); if (response.getStatus() == DetectRunStatus.SUCCESS) { + int index = 0; for (FileOutput output : response.getOutput()) { - // output.getProcessedFile() is base64 or a presigned URL, per response.getOutputType() - byte[] processed = Base64.getDecoder().decode(output.getProcessedFile()); - System.out.println(output.getProcessedFileType() + ": " + processed.length + " bytes"); + index++; + if (response.getOutputType() != DataSourceType.BASE64) { + // PRESIGNED_URL outputs carry a URL, not base64: download them instead of decoding. + System.out.println(output.getProcessedFileType() + " available at " + output.getProcessedFile()); + continue; + } + // One file per output: the output type keeps the names apart, the index guards against + // two outputs of the same type (the SDK's own writer follows the same pattern). + String type = output.getProcessedFileType() == null ? String.valueOf(index) : output.getProcessedFileType(); + String name = "reidentified-" + type + "-" + input.getName(); + File target = new File(input.getParentFile(), name); + if (target.exists()) { + name = "reidentified-" + type + "-" + index + "-" + input.getName(); + target = new File(input.getParentFile(), name); + } + Files.write(target.toPath(), Base64.getDecoder().decode(output.getProcessedFile())); + System.out.println("Wrote " + name); } + System.out.println("Metrics: " + response.getMetrics()); } } catch (SkyflowException e) { System.err.println("Error during reidentifyFile:"); diff --git a/skyvault/samples/src/main/java/com/example/detect/ReidentifyStringSample.java b/skyvault/samples/src/main/java/com/example/detect/ReidentifyStringSample.java index 8ba28ba0..5db7730c 100644 --- a/skyvault/samples/src/main/java/com/example/detect/ReidentifyStringSample.java +++ b/skyvault/samples/src/main/java/com/example/detect/ReidentifyStringSample.java @@ -5,29 +5,28 @@ import com.skyflow.config.VaultConfig; import com.skyflow.detect.EntityType; import com.skyflow.detect.RedactionLevel; -import com.skyflow.detect.RedactionType; +import com.skyflow.enums.RedactionType; import com.skyflow.detect.ReidentifyStringRequest; import com.skyflow.detect.ReidentifyStringResponse; import com.skyflow.enums.Env; import com.skyflow.enums.LogLevel; import com.skyflow.errors.SkyflowException; -import java.util.Arrays; +import java.util.Collections; /** - * Replaces tokens in a de-identified string with their original values, or with a redacted form - * chosen per entity type. For a skyvault vault each RedactionLevel names an entityName and a - * redactionType. + * Re-identifies tokens in a string with the Detect V2 API. For skyvault vaults, redaction + * levels target an entity type and apply a redaction type. */ public class ReidentifyStringSample { public static void main(String[] args) throws SkyflowException { Credentials credentials = new Credentials(); - credentials.setPath(""); // Replace with the path to the credentials file + credentials.setPath(""); // Replace with the path to the credentials file VaultConfig vaultConfig = new VaultConfig(); - vaultConfig.setVaultId(""); // Replace with the ID of the vault - vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault - vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) + vaultConfig.setVaultId(""); // Replace with the ID of the vault + vaultConfig.setClusterId(""); // Replace with the cluster ID of the vault + vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD) Skyflow skyflowClient = Skyflow.builder() .setLogLevel(LogLevel.ERROR) @@ -36,20 +35,24 @@ public static void main(String[] args) throws SkyflowException { .build(); try { + // Plain re-identification: every token is replaced by its original value. ReidentifyStringResponse response = skyflowClient.detect().reidentifyString( ReidentifyStringRequest.builder() .text("My name is [NAME_1] and my email is [EMAIL_ADDRESS_1].") - .redactionLevel(Arrays.asList( - RedactionLevel.builder() - .entityName(EntityType.NAME) - .redactionType(RedactionType.PLAIN_TEXT) - .build(), + .build()); + System.out.println("Processed text: " + response.getProcessedText()); + + // Targeted rendering: tokens of one entity type are rendered with a redaction type. + ReidentifyStringResponse masked = skyflowClient.detect().reidentifyString( + ReidentifyStringRequest.builder() + .text("My name is [NAME_1].") + .redactionLevel(Collections.singletonList( RedactionLevel.builder() - .entityName(EntityType.EMAIL_ADDRESS) - .redactionType(RedactionType.MASKED) + .entityName(EntityType.NAME) // Entity type to target + .redactionType(RedactionType.MASKED) // PLAIN_TEXT, MASKED, REDACTED or DEFAULT .build())) .build()); - System.out.println("Processed text: " + response.getProcessedText()); + System.out.println("Masked text: " + masked.getProcessedText()); } catch (SkyflowException e) { System.err.println("Error during reidentifyString:"); e.printStackTrace(); diff --git a/skyvault/src/main/java/com/skyflow/enums/RedactionType.java b/skyvault/src/main/java/com/skyflow/enums/RedactionType.java deleted file mode 100644 index 9c76cc7d..00000000 --- a/skyvault/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); - } -}