diff --git a/.sdk-version b/.sdk-version index 1a5a13a..6d07408 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v3.57.2 +v3.58.0 diff --git a/README.md b/README.md index 3578ae3..1317b46 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add this dependency to your project's POM: ai.reveng sdk - 3.57.2 + 3.58.0 compile ``` @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation "ai.reveng:sdk:3.57.2" + implementation "ai.reveng:sdk:3.58.0" } ``` @@ -81,6 +81,7 @@ Class | Method | HTTP request | Description *AnalysesCommentsApi* | [**getAnalysisComments**](docs/AnalysesCommentsApi.md#getAnalysisComments) | **GET** /v2/analyses/{analysis_id}/comments | Get comments for this analysis *AnalysesCommentsApi* | [**updateAnalysisComment**](docs/AnalysesCommentsApi.md#updateAnalysisComment) | **PATCH** /v2/analyses/{analysis_id}/comments/{comment_id} | Update a comment *AnalysesCoreApi* | [**bulkAddAnalysisTags**](docs/AnalysesCoreApi.md#bulkAddAnalysisTags) | **PATCH** /v2/analyses/tags/add | Bulk Add Analysis Tags +*AnalysesCoreApi* | [**bulkDeleteAnalyses**](docs/AnalysesCoreApi.md#bulkDeleteAnalyses) | **PATCH** /v2/analyses/delete | Bulk Delete Analyses *AnalysesCoreApi* | [**createAnalysis**](docs/AnalysesCoreApi.md#createAnalysis) | **POST** /v2/analyses | Create Analysis *AnalysesCoreApi* | [**deleteAnalysis**](docs/AnalysesCoreApi.md#deleteAnalysis) | **DELETE** /v2/analyses/{analysis_id} | Delete Analysis *AnalysesCoreApi* | [**getAnalysisBasicInfo**](docs/AnalysesCoreApi.md#getAnalysisBasicInfo) | **GET** /v2/analyses/{analysis_id}/basic | Gets basic analysis information @@ -320,6 +321,7 @@ Class | Method | HTTP request | Description - [BinaryTaskStatus](docs/BinaryTaskStatus.md) - [Block](docs/Block.md) - [BlockCommentsGenerationForFunctionResponse](docs/BlockCommentsGenerationForFunctionResponse.md) + - [BulkDeleteAnalysesRequest](docs/BulkDeleteAnalysesRequest.md) - [CalleeFunctionInfo](docs/CalleeFunctionInfo.md) - [CalleesCallerFunctionsResponse](docs/CalleesCallerFunctionsResponse.md) - [CallerFunctionInfo](docs/CallerFunctionInfo.md) diff --git a/build.gradle b/build.gradle index ce48301..af95c77 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'ai.reveng' -version = '3.57.2' +version = '3.58.0' @@ -171,7 +171,7 @@ mavenPublishing { publishToMavenCentral(true) signAllPublications() - coordinates("ai.reveng", "sdk", "3.57.2") + coordinates("ai.reveng", "sdk", "3.58.0") pom { name = "sdk" diff --git a/build.sbt b/build.sbt index 0a3c42e..809fd46 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ai.reveng", name := "sdk", - version := "3.57.2", + version := "3.58.0", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/docs/AnalysesCoreApi.md b/docs/AnalysesCoreApi.md index 0984d5e..4ed891b 100644 --- a/docs/AnalysesCoreApi.md +++ b/docs/AnalysesCoreApi.md @@ -5,6 +5,7 @@ All URIs are relative to *https://api.reveng.ai* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**bulkAddAnalysisTags**](AnalysesCoreApi.md#bulkAddAnalysisTags) | **PATCH** /v2/analyses/tags/add | Bulk Add Analysis Tags | +| [**bulkDeleteAnalyses**](AnalysesCoreApi.md#bulkDeleteAnalyses) | **PATCH** /v2/analyses/delete | Bulk Delete Analyses | | [**createAnalysis**](AnalysesCoreApi.md#createAnalysis) | **POST** /v2/analyses | Create Analysis | | [**deleteAnalysis**](AnalysesCoreApi.md#deleteAnalysis) | **DELETE** /v2/analyses/{analysis_id} | Delete Analysis | | [**getAnalysisBasicInfo**](AnalysesCoreApi.md#getAnalysisBasicInfo) | **GET** /v2/analyses/{analysis_id}/basic | Gets basic analysis information | @@ -104,6 +105,90 @@ public class Example { | **200** | Successful Response | - | | **422** | Invalid request parameters | - | + +# **bulkDeleteAnalyses** +> BaseResponseDict bulkDeleteAnalyses(bulkDeleteAnalysesRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts) + +Bulk Delete Analyses + +Deletes multiple analyses. User must be the owner of all analyses. + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AnalysesCoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + AnalysesCoreApi apiInstance = new AnalysesCoreApi(defaultClient); + BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest = new BulkDeleteAnalysesRequest(); // BulkDeleteAnalysesRequest | + String endpointUrl = "endpointUrl_example"; // String | + String localCacheDir = "localCacheDir_example"; // String | + Integer localCacheMaxSizeMb = 56; // Integer | + String customerSamplesBucket = "customerSamplesBucket_example"; // String | + String firmwareSamplesBucket = "firmwareSamplesBucket_example"; // String | + Integer maxRetryAttempts = 5; // Integer | + try { + BaseResponseDict result = apiInstance.bulkDeleteAnalyses(bulkDeleteAnalysesRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AnalysesCoreApi#bulkDeleteAnalyses"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **bulkDeleteAnalysesRequest** | [**BulkDeleteAnalysesRequest**](BulkDeleteAnalysesRequest.md)| | | +| **endpointUrl** | **String**| | [optional] | +| **localCacheDir** | **String**| | [optional] | +| **localCacheMaxSizeMb** | **Integer**| | [optional] | +| **customerSamplesBucket** | **String**| | [optional] | +| **firmwareSamplesBucket** | **String**| | [optional] | +| **maxRetryAttempts** | **Integer**| | [optional] [default to 5] | + +### Return type + +[**BaseResponseDict**](BaseResponseDict.md) + +### Authorization + +[APIKey](../README.md#APIKey) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | +| **404** | Not Found | - | +| **403** | Forbidden | - | + # **createAnalysis** > BaseResponseAnalysisCreateResponse createAnalysis(analysisCreateRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts, xRevEngApplication) diff --git a/docs/BulkDeleteAnalysesRequest.md b/docs/BulkDeleteAnalysesRequest.md new file mode 100644 index 0000000..be70bd5 --- /dev/null +++ b/docs/BulkDeleteAnalysesRequest.md @@ -0,0 +1,13 @@ + + +# BulkDeleteAnalysesRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**analysisIds** | **List<Integer>** | | | + + + diff --git a/pom.xml b/pom.xml index a8108e6..2210f26 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ sdk jar sdk - 3.57.2 + 3.58.0 https://github.com/RevEngAI/sdk-java Java SDK for the RevEng.AI API diff --git a/src/main/java/ai/reveng/api/AnalysesCoreApi.java b/src/main/java/ai/reveng/api/AnalysesCoreApi.java index 80a386e..03ada00 100644 --- a/src/main/java/ai/reveng/api/AnalysesCoreApi.java +++ b/src/main/java/ai/reveng/api/AnalysesCoreApi.java @@ -45,6 +45,7 @@ import ai.reveng.model.BaseResponseRecent; import ai.reveng.model.BaseResponseStatus; import ai.reveng.model.BaseResponseUploadResponse; +import ai.reveng.model.BulkDeleteAnalysesRequest; import ai.reveng.model.DynamicExecutionStatusInput; import java.io.File; import ai.reveng.model.InsertAnalysisLogRequest; @@ -278,6 +279,193 @@ public okhttp3.Call bulkAddAnalysisTagsAsync(@javax.annotation.Nonnull AnalysisB localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for bulkDeleteAnalyses + * @param bulkDeleteAnalysesRequest (required) + * @param endpointUrl (optional) + * @param localCacheDir (optional) + * @param localCacheMaxSizeMb (optional) + * @param customerSamplesBucket (optional) + * @param firmwareSamplesBucket (optional) + * @param maxRetryAttempts (optional, default to 5) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
404 Not Found -
403 Forbidden -
+ */ + public okhttp3.Call bulkDeleteAnalysesCall(@javax.annotation.Nonnull BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest, @javax.annotation.Nullable String endpointUrl, @javax.annotation.Nullable String localCacheDir, @javax.annotation.Nullable Integer localCacheMaxSizeMb, @javax.annotation.Nullable String customerSamplesBucket, @javax.annotation.Nullable String firmwareSamplesBucket, @javax.annotation.Nullable Integer maxRetryAttempts, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = bulkDeleteAnalysesRequest; + + // create path and map variables + String localVarPath = "/v2/analyses/delete"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (endpointUrl != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("endpoint_url", endpointUrl)); + } + + if (localCacheDir != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("local_cache_dir", localCacheDir)); + } + + if (localCacheMaxSizeMb != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("local_cache_max_size_mb", localCacheMaxSizeMb)); + } + + if (customerSamplesBucket != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("customer_samples_bucket", customerSamplesBucket)); + } + + if (firmwareSamplesBucket != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("firmware_samples_bucket", firmwareSamplesBucket)); + } + + if (maxRetryAttempts != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("max_retry_attempts", maxRetryAttempts)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey" }; + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call bulkDeleteAnalysesValidateBeforeCall(@javax.annotation.Nonnull BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest, @javax.annotation.Nullable String endpointUrl, @javax.annotation.Nullable String localCacheDir, @javax.annotation.Nullable Integer localCacheMaxSizeMb, @javax.annotation.Nullable String customerSamplesBucket, @javax.annotation.Nullable String firmwareSamplesBucket, @javax.annotation.Nullable Integer maxRetryAttempts, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'bulkDeleteAnalysesRequest' is set + if (bulkDeleteAnalysesRequest == null) { + throw new ApiException("Missing the required parameter 'bulkDeleteAnalysesRequest' when calling bulkDeleteAnalyses(Async)"); + } + + return bulkDeleteAnalysesCall(bulkDeleteAnalysesRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts, _callback); + + } + + /** + * Bulk Delete Analyses + * Deletes multiple analyses. User must be the owner of all analyses. + * @param bulkDeleteAnalysesRequest (required) + * @param endpointUrl (optional) + * @param localCacheDir (optional) + * @param localCacheMaxSizeMb (optional) + * @param customerSamplesBucket (optional) + * @param firmwareSamplesBucket (optional) + * @param maxRetryAttempts (optional, default to 5) + * @return BaseResponseDict + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
404 Not Found -
403 Forbidden -
+ */ + public BaseResponseDict bulkDeleteAnalyses(@javax.annotation.Nonnull BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest, @javax.annotation.Nullable String endpointUrl, @javax.annotation.Nullable String localCacheDir, @javax.annotation.Nullable Integer localCacheMaxSizeMb, @javax.annotation.Nullable String customerSamplesBucket, @javax.annotation.Nullable String firmwareSamplesBucket, @javax.annotation.Nullable Integer maxRetryAttempts) throws ApiException { + ApiResponse localVarResp = bulkDeleteAnalysesWithHttpInfo(bulkDeleteAnalysesRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts); + return localVarResp.getData(); + } + + /** + * Bulk Delete Analyses + * Deletes multiple analyses. User must be the owner of all analyses. + * @param bulkDeleteAnalysesRequest (required) + * @param endpointUrl (optional) + * @param localCacheDir (optional) + * @param localCacheMaxSizeMb (optional) + * @param customerSamplesBucket (optional) + * @param firmwareSamplesBucket (optional) + * @param maxRetryAttempts (optional, default to 5) + * @return ApiResponse<BaseResponseDict> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
404 Not Found -
403 Forbidden -
+ */ + public ApiResponse bulkDeleteAnalysesWithHttpInfo(@javax.annotation.Nonnull BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest, @javax.annotation.Nullable String endpointUrl, @javax.annotation.Nullable String localCacheDir, @javax.annotation.Nullable Integer localCacheMaxSizeMb, @javax.annotation.Nullable String customerSamplesBucket, @javax.annotation.Nullable String firmwareSamplesBucket, @javax.annotation.Nullable Integer maxRetryAttempts) throws ApiException { + okhttp3.Call localVarCall = bulkDeleteAnalysesValidateBeforeCall(bulkDeleteAnalysesRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Bulk Delete Analyses (asynchronously) + * Deletes multiple analyses. User must be the owner of all analyses. + * @param bulkDeleteAnalysesRequest (required) + * @param endpointUrl (optional) + * @param localCacheDir (optional) + * @param localCacheMaxSizeMb (optional) + * @param customerSamplesBucket (optional) + * @param firmwareSamplesBucket (optional) + * @param maxRetryAttempts (optional, default to 5) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
404 Not Found -
403 Forbidden -
+ */ + public okhttp3.Call bulkDeleteAnalysesAsync(@javax.annotation.Nonnull BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest, @javax.annotation.Nullable String endpointUrl, @javax.annotation.Nullable String localCacheDir, @javax.annotation.Nullable Integer localCacheMaxSizeMb, @javax.annotation.Nullable String customerSamplesBucket, @javax.annotation.Nullable String firmwareSamplesBucket, @javax.annotation.Nullable Integer maxRetryAttempts, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = bulkDeleteAnalysesValidateBeforeCall(bulkDeleteAnalysesRequest, endpointUrl, localCacheDir, localCacheMaxSizeMb, customerSamplesBucket, firmwareSamplesBucket, maxRetryAttempts, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for createAnalysis * @param analysisCreateRequest (required) diff --git a/src/main/java/ai/reveng/invoker/ApiClient.java b/src/main/java/ai/reveng/invoker/ApiClient.java index 3471fcf..6e4cd3a 100644 --- a/src/main/java/ai/reveng/invoker/ApiClient.java +++ b/src/main/java/ai/reveng/invoker/ApiClient.java @@ -146,7 +146,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/3.57.2/java"); + setUserAgent("OpenAPI-Generator/3.58.0/java"); authentications = new HashMap(); } diff --git a/src/main/java/ai/reveng/invoker/Configuration.java b/src/main/java/ai/reveng/invoker/Configuration.java index bd416e3..9e398bf 100644 --- a/src/main/java/ai/reveng/invoker/Configuration.java +++ b/src/main/java/ai/reveng/invoker/Configuration.java @@ -18,7 +18,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - public static final String VERSION = "3.57.2"; + public static final String VERSION = "3.58.0"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/src/main/java/ai/reveng/invoker/JSON.java b/src/main/java/ai/reveng/invoker/JSON.java index 2532c52..131ffd7 100644 --- a/src/main/java/ai/reveng/invoker/JSON.java +++ b/src/main/java/ai/reveng/invoker/JSON.java @@ -217,6 +217,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BinarySearchResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Block.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BlockCommentsGenerationForFunctionResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.BulkDeleteAnalysesRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CalleeFunctionInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CalleesCallerFunctionsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.CallerFunctionInfo.CustomTypeAdapterFactory()); diff --git a/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java b/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java new file mode 100644 index 0000000..578f398 --- /dev/null +++ b/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java @@ -0,0 +1,307 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import ai.reveng.invoker.JSON; + +/** + * BulkDeleteAnalysesRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BulkDeleteAnalysesRequest { + public static final String SERIALIZED_NAME_ANALYSIS_IDS = "analysis_ids"; + @SerializedName(SERIALIZED_NAME_ANALYSIS_IDS) + @javax.annotation.Nonnull + private List analysisIds = new ArrayList<>(); + + public BulkDeleteAnalysesRequest() { + } + + public BulkDeleteAnalysesRequest analysisIds(@javax.annotation.Nonnull List analysisIds) { + this.analysisIds = analysisIds; + return this; + } + + public BulkDeleteAnalysesRequest addAnalysisIdsItem(Integer analysisIdsItem) { + if (this.analysisIds == null) { + this.analysisIds = new ArrayList<>(); + } + this.analysisIds.add(analysisIdsItem); + return this; + } + + /** + * Get analysisIds + * @return analysisIds + */ + @javax.annotation.Nonnull + public List getAnalysisIds() { + return analysisIds; + } + + public void setAnalysisIds(@javax.annotation.Nonnull List analysisIds) { + this.analysisIds = analysisIds; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkDeleteAnalysesRequest instance itself + */ + public BulkDeleteAnalysesRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BulkDeleteAnalysesRequest bulkDeleteAnalysesRequest = (BulkDeleteAnalysesRequest) o; + return Objects.equals(this.analysisIds, bulkDeleteAnalysesRequest.analysisIds)&& + Objects.equals(this.additionalProperties, bulkDeleteAnalysesRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(analysisIds, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BulkDeleteAnalysesRequest {\n"); + sb.append(" analysisIds: ").append(toIndentedString(analysisIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("analysis_ids")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("analysis_ids")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BulkDeleteAnalysesRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!BulkDeleteAnalysesRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BulkDeleteAnalysesRequest is not found in the empty JSON string", BulkDeleteAnalysesRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : BulkDeleteAnalysesRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("analysis_ids") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("analysis_ids").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_ids` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_ids").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BulkDeleteAnalysesRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BulkDeleteAnalysesRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BulkDeleteAnalysesRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, BulkDeleteAnalysesRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public BulkDeleteAnalysesRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkDeleteAnalysesRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of BulkDeleteAnalysesRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of BulkDeleteAnalysesRequest + * @throws IOException if the JSON string is invalid with respect to BulkDeleteAnalysesRequest + */ + public static BulkDeleteAnalysesRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BulkDeleteAnalysesRequest.class); + } + + /** + * Convert an instance of BulkDeleteAnalysesRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +