From ec700805d95a32fd0af1d46a18044a57141bbeb9 Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Wed, 24 Jan 2024 11:40:00 -0500 Subject: [PATCH 1/5] add global control plane code --- build.gradle | 9 + .../{ => Index}/ConfigureIndexTest.java | 2 +- .../CreateListAndDeleteIndexTest.java | 2 +- .../PineconeCollectionOperationClient.java | 5 + .../org/openapitools/client/ApiCallback.java | 60 + .../org/openapitools/client/ApiClient.java | 1551 +++++++++++++++++ .../org/openapitools/client/ApiException.java | 165 ++ .../org/openapitools/client/ApiResponse.java | 76 + .../openapitools/client/Configuration.java | 41 + .../client/GzipRequestInterceptor.java | 85 + .../java/org/openapitools/client/JSON.java | 416 +++++ .../java/org/openapitools/client/Pair.java | 57 + .../client/ProgressRequestBody.java | 73 + .../client/ProgressResponseBody.java | 70 + .../client/ServerConfiguration.java | 58 + .../openapitools/client/ServerVariable.java | 23 + .../org/openapitools/client/StringUtil.java | 83 + .../client/api/ManageIndexesApi.java | 1308 ++++++++++++++ .../openapitools/client/auth/ApiKeyAuth.java | 80 + .../client/auth/Authentication.java | 36 + .../client/auth/HttpBasicAuth.java | 55 + .../client/auth/HttpBearerAuth.java | 63 + .../client/model/AbstractOpenApiSchema.java | 146 ++ .../openapitools/client/model/AwsRegions.java | 71 + .../client/model/CollectionList.java | 216 +++ .../client/model/CollectionModel.java | 401 +++++ .../client/model/ConfigureIndexRequest.java | 201 +++ .../model/ConfigureIndexRequestSpec.java | 201 +++ .../model/ConfigureIndexRequestSpecPod.java | 223 +++ .../client/model/CreateCollectionRequest.java | 234 +++ .../client/model/CreateIndexRequest.java | 293 ++++ .../client/model/CreateIndexRequestSpec.java | 225 +++ .../model/CreateIndexRequestSpecPod.java | 384 ++++ .../client/model/ErrorResponse.java | 230 +++ .../client/model/ErrorResponseError.java | 342 ++++ .../openapitools/client/model/GcpRegions.java | 77 + .../openapitools/client/model/IndexList.java | 216 +++ .../client/model/IndexMetric.java | 71 + .../openapitools/client/model/IndexModel.java | 356 ++++ .../client/model/IndexModelSpec.java | 227 +++ .../client/model/IndexModelStatus.java | 291 ++++ .../openapitools/client/model/PodSpec.java | 387 ++++ .../client/model/PodSpecMetadataConfig.java | 205 +++ .../client/model/ServerlessSpec.java | 284 +++ 44 files changed, 9597 insertions(+), 2 deletions(-) rename src/integration/java/io/pinecone/integration/controlPlane/{ => Index}/ConfigureIndexTest.java (99%) rename src/integration/java/io/pinecone/integration/controlPlane/{ => Index}/CreateListAndDeleteIndexTest.java (97%) create mode 100644 src/main/java/io/pinecone/PineconeCollectionOperationClient.java create mode 100644 src/main/java/org/openapitools/client/ApiCallback.java create mode 100644 src/main/java/org/openapitools/client/ApiClient.java create mode 100644 src/main/java/org/openapitools/client/ApiException.java create mode 100644 src/main/java/org/openapitools/client/ApiResponse.java create mode 100644 src/main/java/org/openapitools/client/Configuration.java create mode 100644 src/main/java/org/openapitools/client/GzipRequestInterceptor.java create mode 100644 src/main/java/org/openapitools/client/JSON.java create mode 100644 src/main/java/org/openapitools/client/Pair.java create mode 100644 src/main/java/org/openapitools/client/ProgressRequestBody.java create mode 100644 src/main/java/org/openapitools/client/ProgressResponseBody.java create mode 100644 src/main/java/org/openapitools/client/ServerConfiguration.java create mode 100644 src/main/java/org/openapitools/client/ServerVariable.java create mode 100644 src/main/java/org/openapitools/client/StringUtil.java create mode 100644 src/main/java/org/openapitools/client/api/ManageIndexesApi.java create mode 100644 src/main/java/org/openapitools/client/auth/ApiKeyAuth.java create mode 100644 src/main/java/org/openapitools/client/auth/Authentication.java create mode 100644 src/main/java/org/openapitools/client/auth/HttpBasicAuth.java create mode 100644 src/main/java/org/openapitools/client/auth/HttpBearerAuth.java create mode 100644 src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java create mode 100644 src/main/java/org/openapitools/client/model/AwsRegions.java create mode 100644 src/main/java/org/openapitools/client/model/CollectionList.java create mode 100644 src/main/java/org/openapitools/client/model/CollectionModel.java create mode 100644 src/main/java/org/openapitools/client/model/ConfigureIndexRequest.java create mode 100644 src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpec.java create mode 100644 src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpecPod.java create mode 100644 src/main/java/org/openapitools/client/model/CreateCollectionRequest.java create mode 100644 src/main/java/org/openapitools/client/model/CreateIndexRequest.java create mode 100644 src/main/java/org/openapitools/client/model/CreateIndexRequestSpec.java create mode 100644 src/main/java/org/openapitools/client/model/CreateIndexRequestSpecPod.java create mode 100644 src/main/java/org/openapitools/client/model/ErrorResponse.java create mode 100644 src/main/java/org/openapitools/client/model/ErrorResponseError.java create mode 100644 src/main/java/org/openapitools/client/model/GcpRegions.java create mode 100644 src/main/java/org/openapitools/client/model/IndexList.java create mode 100644 src/main/java/org/openapitools/client/model/IndexMetric.java create mode 100644 src/main/java/org/openapitools/client/model/IndexModel.java create mode 100644 src/main/java/org/openapitools/client/model/IndexModelSpec.java create mode 100644 src/main/java/org/openapitools/client/model/IndexModelStatus.java create mode 100644 src/main/java/org/openapitools/client/model/PodSpec.java create mode 100644 src/main/java/org/openapitools/client/model/PodSpecMetadataConfig.java create mode 100644 src/main/java/org/openapitools/client/model/ServerlessSpec.java diff --git a/build.gradle b/build.gradle index 47c17e2d..b11083a1 100644 --- a/build.gradle +++ b/build.gradle @@ -47,8 +47,13 @@ dependencies { implementation 'org.slf4j:slf4j-api:2.0.5' implementation 'com.google.api.grpc:proto-google-common-protos:2.14.3' implementation 'com.squareup.okhttp3:okhttp:4.10.0' + // ToDo: Clean next two lines implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.2' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.14.2' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' + implementation 'io.gsonfire:gson-fire:1.8.5' + implementation 'org.openapitools:jackson-databind-nullable:0.2.6' compileOnly "org.apache.tomcat:annotations-api:6.0.53" // necessary for Java 9+ testImplementation("com.squareup.okhttp3:mockwebserver:4.10.0") @@ -61,6 +66,10 @@ dependencies { testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0' } +javadoc { + options.tags = [ "http.response.details:a:Http Response Details" ] +} + configurations { integrationTestImplementation.extendsFrom testImplementation integrationTestRuntimeOnly.extendsFrom testRuntimeOnly diff --git a/src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/Index/ConfigureIndexTest.java similarity index 99% rename from src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java rename to src/integration/java/io/pinecone/integration/controlPlane/Index/ConfigureIndexTest.java index b0ce960a..1b38e596 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/Index/ConfigureIndexTest.java @@ -1,4 +1,4 @@ -package io.pinecone.integration.controlPlane; +package io.pinecone.integration.controlPlane.Index; import io.pinecone.PineconeClientConfig; import io.pinecone.integration.dataplane.PineconeClientLiveIntegTest; diff --git a/src/integration/java/io/pinecone/integration/controlPlane/CreateListAndDeleteIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/Index/CreateListAndDeleteIndexTest.java similarity index 97% rename from src/integration/java/io/pinecone/integration/controlPlane/CreateListAndDeleteIndexTest.java rename to src/integration/java/io/pinecone/integration/controlPlane/Index/CreateListAndDeleteIndexTest.java index 4a4ca58b..0c54adbf 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/CreateListAndDeleteIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/Index/CreateListAndDeleteIndexTest.java @@ -1,4 +1,4 @@ -package io.pinecone.integration.controlPlane; +package io.pinecone.integration.controlPlane.Index; import io.pinecone.PineconeClientConfig; import io.pinecone.PineconeIndexOperationClient; diff --git a/src/main/java/io/pinecone/PineconeCollectionOperationClient.java b/src/main/java/io/pinecone/PineconeCollectionOperationClient.java new file mode 100644 index 00000000..a2dbd4a7 --- /dev/null +++ b/src/main/java/io/pinecone/PineconeCollectionOperationClient.java @@ -0,0 +1,5 @@ +package io.pinecone; + +public class PineconeCollectionOperationClient { + // ToDo: add collection code here +} diff --git a/src/main/java/org/openapitools/client/ApiCallback.java b/src/main/java/org/openapitools/client/ApiCallback.java new file mode 100644 index 00000000..fe606e58 --- /dev/null +++ b/src/main/java/org/openapitools/client/ApiCallback.java @@ -0,0 +1,60 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/src/main/java/org/openapitools/client/ApiClient.java b/src/main/java/org/openapitools/client/ApiClient.java new file mode 100644 index 00000000..1915a3ce --- /dev/null +++ b/src/main/java/org/openapitools/client/ApiClient.java @@ -0,0 +1,1551 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.openapitools.client.auth.Authentication; +import org.openapitools.client.auth.HttpBasicAuth; +import org.openapitools.client.auth.ApiKeyAuth; + +/** + *

ApiClient class.

+ */ +public class ApiClient { + + private String basePath = "https://api.pinecone.io"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + "https://api.pinecone.io", + "No description provided", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("ApiKeyAuth", new ApiKeyAuth("header", "Api-Key")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("ApiKeyAuth", new ApiKeyAuth("header", "Api-Key")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + private void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor: interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + private void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/1.0/java"); + + authentications = new HashMap(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://api.pinecone.io + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link DateFormat} object + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + JSON.setDateFormat(dateFormat); + return this; + } + + /** + *

Set SqlDateFormat.

+ * + * @param dateFormat a {@link DateFormat} object + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

Set OffsetDateTimeFormat.

+ * + * @param dateFormat a {@link DateTimeFormatter} object + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setOffsetDateTimeFormat(dateFormat); + return this; + } + + /** + *

Set LocalDateFormat.

+ * + * @param dateFormat a {@link DateTimeFormatter} object + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(".*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * returns null. If it matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws org.openapitools.client.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) + prefix = "download-"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws org.openapitools.client.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. + * @throws org.openapitools.client.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or + * fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws org.openapitools.client.ApiException If fail to serialize the request body object + */ + public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws org.openapitools.client.ApiException If fail to serialize the request body object + */ + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create("", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws org.openapitools.client.ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + FormBody.Builder formBuilder = new FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + private Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws org.openapitools.client.ApiException If fail to serialize the request body object into a string + */ + private String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/src/main/java/org/openapitools/client/ApiException.java b/src/main/java/org/openapitools/client/ApiException.java new file mode 100644 index 00000000..c3ed8b66 --- /dev/null +++ b/src/main/java/org/openapitools/client/ApiException.java @@ -0,0 +1,165 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import java.util.Map; +import java.util.List; + + +/** + *

ApiException class.

+ */ +@SuppressWarnings("serial") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ApiException extends Exception { + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

+ */ + public ApiException() {} + + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this("Response Code: " + code + " Response Body: " + responseBody, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } +} diff --git a/src/main/java/org/openapitools/client/ApiResponse.java b/src/main/java/org/openapitools/client/ApiResponse.java new file mode 100644 index 00000000..1bcb3418 --- /dev/null +++ b/src/main/java/org/openapitools/client/ApiResponse.java @@ -0,0 +1,76 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + /** + *

Get the status code.

+ * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + *

Get the headers.

+ * + * @return a {@link Map} of headers + */ + public Map> getHeaders() { + return headers; + } + + /** + *

Get the data.

+ * + * @return the data + */ + public T getData() { + return data; + } +} diff --git a/src/main/java/org/openapitools/client/Configuration.java b/src/main/java/org/openapitools/client/Configuration.java new file mode 100644 index 00000000..d2951ec6 --- /dev/null +++ b/src/main/java/org/openapitools/client/Configuration.java @@ -0,0 +1,41 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class Configuration { + public static final String VERSION = "1.0"; + + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/src/main/java/org/openapitools/client/GzipRequestInterceptor.java b/src/main/java/org/openapitools/client/GzipRequestInterceptor.java new file mode 100644 index 00000000..cd4035ca --- /dev/null +++ b/src/main/java/org/openapitools/client/GzipRequestInterceptor.java @@ -0,0 +1,85 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/src/main/java/org/openapitools/client/JSON.java b/src/main/java/org/openapitools/client/JSON.java new file mode 100644 index 00000000..a3d1926d --- /dev/null +++ b/src/main/java/org/openapitools/client/JSON.java @@ -0,0 +1,416 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + +import okio.ByteString; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Map; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CollectionList.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CollectionModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ConfigureIndexRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ConfigureIndexRequestSpec.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ConfigureIndexRequestSpecPod.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CreateCollectionRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CreateIndexRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CreateIndexRequestSpec.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CreateIndexRequestSpecPod.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ErrorResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ErrorResponseError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.IndexList.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.IndexModel.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.IndexModelSpec.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.IndexModelStatus.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.PodSpec.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.PodSpecMetadataConfig.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ServerlessSpec.CustomTypeAdapterFactory()); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/src/main/java/org/openapitools/client/Pair.java b/src/main/java/org/openapitools/client/Pair.java new file mode 100644 index 00000000..54ca663b --- /dev/null +++ b/src/main/java/org/openapitools/client/Pair.java @@ -0,0 +1,57 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} diff --git a/src/main/java/org/openapitools/client/ProgressRequestBody.java b/src/main/java/org/openapitools/client/ProgressRequestBody.java new file mode 100644 index 00000000..3afd59e6 --- /dev/null +++ b/src/main/java/org/openapitools/client/ProgressRequestBody.java @@ -0,0 +1,73 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/src/main/java/org/openapitools/client/ProgressResponseBody.java b/src/main/java/org/openapitools/client/ProgressResponseBody.java new file mode 100644 index 00000000..080970ef --- /dev/null +++ b/src/main/java/org/openapitools/client/ProgressResponseBody.java @@ -0,0 +1,70 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/src/main/java/org/openapitools/client/ServerConfiguration.java b/src/main/java/org/openapitools/client/ServerConfiguration.java new file mode 100644 index 00000000..59edc528 --- /dev/null +++ b/src/main/java/org/openapitools/client/ServerConfiguration.java @@ -0,0 +1,58 @@ +package org.openapitools.client; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/src/main/java/org/openapitools/client/ServerVariable.java b/src/main/java/org/openapitools/client/ServerVariable.java new file mode 100644 index 00000000..c2f13e21 --- /dev/null +++ b/src/main/java/org/openapitools/client/ServerVariable.java @@ -0,0 +1,23 @@ +package org.openapitools.client; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/src/main/java/org/openapitools/client/StringUtil.java b/src/main/java/org/openapitools/client/StringUtil.java new file mode 100644 index 00000000..4548fae9 --- /dev/null +++ b/src/main/java/org/openapitools/client/StringUtil.java @@ -0,0 +1,83 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/src/main/java/org/openapitools/client/api/ManageIndexesApi.java b/src/main/java/org/openapitools/client/api/ManageIndexesApi.java new file mode 100644 index 00000000..231a53dc --- /dev/null +++ b/src/main/java/org/openapitools/client/api/ManageIndexesApi.java @@ -0,0 +1,1308 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.ApiCallback; +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; +import org.openapitools.client.ProgressRequestBody; +import org.openapitools.client.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import org.openapitools.client.model.CollectionList; +import org.openapitools.client.model.CollectionModel; +import org.openapitools.client.model.ConfigureIndexRequest; +import org.openapitools.client.model.CreateCollectionRequest; +import org.openapitools.client.model.CreateIndexRequest; +import org.openapitools.client.model.ErrorResponse; +import org.openapitools.client.model.IndexList; +import org.openapitools.client.model.IndexModel; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ManageIndexesApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public ManageIndexesApi() { + this(Configuration.getDefaultApiClient()); + } + + public ManageIndexesApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for configureIndex + * @param indexName The name of the index to configure (required) + * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Status Code Description Response Headers
202 The request to configure the index has been accepted. Check the index status to see when the change has been applied. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
405 The requested operation is not supported for serverless indexes. -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
500 Internal server error -
+ */ + public okhttp3.Call configureIndexCall(String indexName, ConfigureIndexRequest configureIndexRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = configureIndexRequest; + + // create path and map variables + String localVarPath = "/indexes/{index_name}" + .replace("{" + "index_name" + "}", localVarApiClient.escapeString(indexName.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + 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[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call configureIndexValidateBeforeCall(String indexName, ConfigureIndexRequest configureIndexRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException("Missing the required parameter 'indexName' when calling configureIndex(Async)"); + } + + // verify the required parameter 'configureIndexRequest' is set + if (configureIndexRequest == null) { + throw new ApiException("Missing the required parameter 'configureIndexRequest' when calling configureIndex(Async)"); + } + + return configureIndexCall(indexName, configureIndexRequest, _callback); + + } + + /** + * + * This operation specifies the pod type and number of replicas for an index. + * @param indexName The name of the index to configure (required) + * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @return IndexModel + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Status Code Description Response Headers
202 The request to configure the index has been accepted. Check the index status to see when the change has been applied. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
405 The requested operation is not supported for serverless indexes. -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
500 Internal server error -
+ */ + public IndexModel configureIndex(String indexName, ConfigureIndexRequest configureIndexRequest) throws ApiException { + ApiResponse localVarResp = configureIndexWithHttpInfo(indexName, configureIndexRequest); + return localVarResp.getData(); + } + + /** + * + * This operation specifies the pod type and number of replicas for an index. + * @param indexName The name of the index to configure (required) + * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @return ApiResponse<IndexModel> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Status Code Description Response Headers
202 The request to configure the index has been accepted. Check the index status to see when the change has been applied. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
405 The requested operation is not supported for serverless indexes. -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
500 Internal server error -
+ */ + public ApiResponse configureIndexWithHttpInfo(String indexName, ConfigureIndexRequest configureIndexRequest) throws ApiException { + okhttp3.Call localVarCall = configureIndexValidateBeforeCall(indexName, configureIndexRequest, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation specifies the pod type and number of replicas for an index. + * @param indexName The name of the index to configure (required) + * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @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 + + + + + + + + + + +
Status Code Description Response Headers
202 The request to configure the index has been accepted. Check the index status to see when the change has been applied. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
405 The requested operation is not supported for serverless indexes. -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
500 Internal server error -
+ */ + public okhttp3.Call configureIndexAsync(String indexName, ConfigureIndexRequest configureIndexRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = configureIndexValidateBeforeCall(indexName, configureIndexRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createCollection + * @param createCollectionRequest The desired configuration for the collection. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + +
Status Code Description Response Headers
201 The collection has been successfully created. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
405 The requested operation is not supported for serverless indexes. -
409 A collection already exists with the name provided. -
422 Unprocessable entity. The request body could not be deserialized. -
500 Internal server error -
+ */ + public okhttp3.Call createCollectionCall(CreateCollectionRequest createCollectionRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = createCollectionRequest; + + // create path and map variables + String localVarPath = "/collections"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + 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[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createCollectionValidateBeforeCall(CreateCollectionRequest createCollectionRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'createCollectionRequest' is set + if (createCollectionRequest == null) { + throw new ApiException("Missing the required parameter 'createCollectionRequest' when calling createCollection(Async)"); + } + + return createCollectionCall(createCollectionRequest, _callback); + + } + + /** + * + * This operation creates a Pinecone collection. + * @param createCollectionRequest The desired configuration for the collection. (required) + * @return CollectionModel + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Status Code Description Response Headers
201 The collection has been successfully created. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
405 The requested operation is not supported for serverless indexes. -
409 A collection already exists with the name provided. -
422 Unprocessable entity. The request body could not be deserialized. -
500 Internal server error -
+ */ + public CollectionModel createCollection(CreateCollectionRequest createCollectionRequest) throws ApiException { + ApiResponse localVarResp = createCollectionWithHttpInfo(createCollectionRequest); + return localVarResp.getData(); + } + + /** + * + * This operation creates a Pinecone collection. + * @param createCollectionRequest The desired configuration for the collection. (required) + * @return ApiResponse<CollectionModel> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + +
Status Code Description Response Headers
201 The collection has been successfully created. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
405 The requested operation is not supported for serverless indexes. -
409 A collection already exists with the name provided. -
422 Unprocessable entity. The request body could not be deserialized. -
500 Internal server error -
+ */ + public ApiResponse createCollectionWithHttpInfo(CreateCollectionRequest createCollectionRequest) throws ApiException { + okhttp3.Call localVarCall = createCollectionValidateBeforeCall(createCollectionRequest, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation creates a Pinecone collection. + * @param createCollectionRequest The desired configuration for the collection. (required) + * @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 + + + + + + + + + +
Status Code Description Response Headers
201 The collection has been successfully created. -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
405 The requested operation is not supported for serverless indexes. -
409 A collection already exists with the name provided. -
422 Unprocessable entity. The request body could not be deserialized. -
500 Internal server error -
+ */ + public okhttp3.Call createCollectionAsync(CreateCollectionRequest createCollectionRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createCollectionValidateBeforeCall(createCollectionRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createIndex + * @param createIndexRequest The desired configuration for the index. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + +
Status Code Description Response Headers
201 The index has been successfully created -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Unknown cloud or region when creating a serverless index -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
409 Index of given name already exists. -
500 Internal server error -
+ */ + public okhttp3.Call createIndexCall(CreateIndexRequest createIndexRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = createIndexRequest; + + // create path and map variables + String localVarPath = "/indexes"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + 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[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createIndexValidateBeforeCall(CreateIndexRequest createIndexRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'createIndexRequest' is set + if (createIndexRequest == null) { + throw new ApiException("Missing the required parameter 'createIndexRequest' when calling createIndex(Async)"); + } + + return createIndexCall(createIndexRequest, _callback); + + } + + /** + * + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. + * @param createIndexRequest The desired configuration for the index. (required) + * @return IndexModel + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Status Code Description Response Headers
201 The index has been successfully created -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Unknown cloud or region when creating a serverless index -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
409 Index of given name already exists. -
500 Internal server error -
+ */ + public IndexModel createIndex(CreateIndexRequest createIndexRequest) throws ApiException { + ApiResponse localVarResp = createIndexWithHttpInfo(createIndexRequest); + return localVarResp.getData(); + } + + /** + * + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. + * @param createIndexRequest The desired configuration for the index. (required) + * @return ApiResponse<IndexModel> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + +
Status Code Description Response Headers
201 The index has been successfully created -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Unknown cloud or region when creating a serverless index -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
409 Index of given name already exists. -
500 Internal server error -
+ */ + public ApiResponse createIndexWithHttpInfo(CreateIndexRequest createIndexRequest) throws ApiException { + okhttp3.Call localVarCall = createIndexValidateBeforeCall(createIndexRequest, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. + * @param createIndexRequest The desired configuration for the index. (required) + * @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 + + + + + + + + + + +
Status Code Description Response Headers
201 The index has been successfully created -
400 Bad request. The request body included invalid request parameters. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Unknown cloud or region when creating a serverless index -
422 Unprocessable entity. The request body could not be deserialized. -
429 Not enough available quota to complete this operation -
409 Index of given name already exists. -
500 Internal server error -
+ */ + public okhttp3.Call createIndexAsync(CreateIndexRequest createIndexRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createIndexValidateBeforeCall(createIndexRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteCollection + * @param collectionName The name of the collection (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
202 The index has been successfully deleted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public okhttp3.Call deleteCollectionCall(String collectionName, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/collections/{collection_name}" + .replace("{" + "collection_name" + "}", localVarApiClient.escapeString(collectionName.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "text/plain", + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteCollectionValidateBeforeCall(String collectionName, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'collectionName' is set + if (collectionName == null) { + throw new ApiException("Missing the required parameter 'collectionName' when calling deleteCollection(Async)"); + } + + return deleteCollectionCall(collectionName, _callback); + + } + + /** + * + * This operation deletes an existing collection. + * @param collectionName The name of the collection (required) + * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
202 The index has been successfully deleted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public String deleteCollection(String collectionName) throws ApiException { + ApiResponse localVarResp = deleteCollectionWithHttpInfo(collectionName); + return localVarResp.getData(); + } + + /** + * + * This operation deletes an existing collection. + * @param collectionName The name of the collection (required) + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
202 The index has been successfully deleted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public ApiResponse deleteCollectionWithHttpInfo(String collectionName) throws ApiException { + okhttp3.Call localVarCall = deleteCollectionValidateBeforeCall(collectionName, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation deletes an existing collection. + * @param collectionName The name of the collection (required) + * @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 + + + + + + +
Status Code Description Response Headers
202 The index has been successfully deleted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public okhttp3.Call deleteCollectionAsync(String collectionName, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteCollectionValidateBeforeCall(collectionName, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteIndex + * @param indexName The name of the index to delete (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
202 The request to delete the index has been accepted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public okhttp3.Call deleteIndexCall(String indexName, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/indexes/{index_name}" + .replace("{" + "index_name" + "}", localVarApiClient.escapeString(indexName.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteIndexValidateBeforeCall(String indexName, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException("Missing the required parameter 'indexName' when calling deleteIndex(Async)"); + } + + return deleteIndexCall(indexName, _callback); + + } + + /** + * + * This operation deletes an existing index. + * @param indexName The name of the index to delete (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
202 The request to delete the index has been accepted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public void deleteIndex(String indexName) throws ApiException { + deleteIndexWithHttpInfo(indexName); + } + + /** + * + * This operation deletes an existing index. + * @param indexName The name of the index to delete (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
202 The request to delete the index has been accepted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public ApiResponse deleteIndexWithHttpInfo(String indexName) throws ApiException { + okhttp3.Call localVarCall = deleteIndexValidateBeforeCall(indexName, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * This operation deletes an existing index. + * @param indexName The name of the index to delete (required) + * @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 + + + + + + +
Status Code Description Response Headers
202 The request to delete the index has been accepted. -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public okhttp3.Call deleteIndexAsync(String indexName, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteIndexValidateBeforeCall(indexName, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for describeCollection + * @param collectionName The name of the collection to be described (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the collection -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public okhttp3.Call describeCollectionCall(String collectionName, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/collections/{collection_name}" + .replace("{" + "collection_name" + "}", localVarApiClient.escapeString(collectionName.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call describeCollectionValidateBeforeCall(String collectionName, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'collectionName' is set + if (collectionName == null) { + throw new ApiException("Missing the required parameter 'collectionName' when calling describeCollection(Async)"); + } + + return describeCollectionCall(collectionName, _callback); + + } + + /** + * + * This operation gets a description of a collection. + * @param collectionName The name of the collection to be described (required) + * @return CollectionModel + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the collection -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public CollectionModel describeCollection(String collectionName) throws ApiException { + ApiResponse localVarResp = describeCollectionWithHttpInfo(collectionName); + return localVarResp.getData(); + } + + /** + * + * This operation gets a description of a collection. + * @param collectionName The name of the collection to be described (required) + * @return ApiResponse<CollectionModel> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the collection -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public ApiResponse describeCollectionWithHttpInfo(String collectionName) throws ApiException { + okhttp3.Call localVarCall = describeCollectionValidateBeforeCall(collectionName, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation gets a description of a collection. + * @param collectionName The name of the collection to be described (required) + * @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 + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the collection -
401 Unauthorized. Possible causes: Invalid API key. -
404 Collection not found -
500 Internal server error -
+ */ + public okhttp3.Call describeCollectionAsync(String collectionName, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = describeCollectionValidateBeforeCall(collectionName, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for describeIndex + * @param indexName The name of the index to be described (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the index -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public okhttp3.Call describeIndexCall(String indexName, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/indexes/{index_name}" + .replace("{" + "index_name" + "}", localVarApiClient.escapeString(indexName.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call describeIndexValidateBeforeCall(String indexName, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException("Missing the required parameter 'indexName' when calling describeIndex(Async)"); + } + + return describeIndexCall(indexName, _callback); + + } + + /** + * + * Get a description of an index. + * @param indexName The name of the index to be described (required) + * @return IndexModel + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the index -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public IndexModel describeIndex(String indexName) throws ApiException { + ApiResponse localVarResp = describeIndexWithHttpInfo(indexName); + return localVarResp.getData(); + } + + /** + * + * Get a description of an index. + * @param indexName The name of the index to be described (required) + * @return ApiResponse<IndexModel> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the index -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public ApiResponse describeIndexWithHttpInfo(String indexName) throws ApiException { + okhttp3.Call localVarCall = describeIndexValidateBeforeCall(indexName, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * Get a description of an index. + * @param indexName The name of the index to be described (required) + * @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 + + + + + + +
Status Code Description Response Headers
200 Configuration information and deployment status of the index -
401 Unauthorized. Possible causes: Invalid API key. -
404 Index not found -
500 Internal server error -
+ */ + public okhttp3.Call describeIndexAsync(String indexName, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = describeIndexValidateBeforeCall(indexName, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for listCollections + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 This operation returns a list of all the collections in your current project. -
+ */ + public okhttp3.Call listCollectionsCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/collections"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listCollectionsValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return listCollectionsCall(_callback); + + } + + /** + * + * This operation returns a list of your Pinecone collections. + * @return CollectionList + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 This operation returns a list of all the collections in your current project. -
+ */ + public CollectionList listCollections() throws ApiException { + ApiResponse localVarResp = listCollectionsWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * + * This operation returns a list of your Pinecone collections. + * @return ApiResponse<CollectionList> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 This operation returns a list of all the collections in your current project. -
+ */ + public ApiResponse listCollectionsWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = listCollectionsValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation returns a list of your Pinecone collections. + * @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 + + + +
Status Code Description Response Headers
200 This operation returns a list of all the collections in your current project. -
+ */ + public okhttp3.Call listCollectionsAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listCollectionsValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for listIndexes + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + +
Status Code Description Response Headers
200 This operation returns a list of all the indexes that you have previously created, and which are associated with the given project -
401 Unauthorized. Possible causes: Invalid API key. -
+ */ + public okhttp3.Call listIndexesCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.pinecone.io" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/indexes"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "ApiKeyAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listIndexesValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return listIndexesCall(_callback); + + } + + /** + * + * This operation returns a list of your Pinecone indexes. + * @return IndexList + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Status Code Description Response Headers
200 This operation returns a list of all the indexes that you have previously created, and which are associated with the given project -
401 Unauthorized. Possible causes: Invalid API key. -
+ */ + public IndexList listIndexes() throws ApiException { + ApiResponse localVarResp = listIndexesWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * + * This operation returns a list of your Pinecone indexes. + * @return ApiResponse<IndexList> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Status Code Description Response Headers
200 This operation returns a list of all the indexes that you have previously created, and which are associated with the given project -
401 Unauthorized. Possible causes: Invalid API key. -
+ */ + public ApiResponse listIndexesWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = listIndexesValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * This operation returns a list of your Pinecone indexes. + * @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 + + + + +
Status Code Description Response Headers
200 This operation returns a list of all the indexes that you have previously created, and which are associated with the given project -
401 Unauthorized. Possible causes: Invalid API key. -
+ */ + public okhttp3.Call listIndexesAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listIndexesValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java b/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java new file mode 100644 index 00000000..353347e2 --- /dev/null +++ b/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java @@ -0,0 +1,80 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.auth; + +import org.openapitools.client.ApiException; +import org.openapitools.client.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/src/main/java/org/openapitools/client/auth/Authentication.java b/src/main/java/org/openapitools/client/auth/Authentication.java new file mode 100644 index 00000000..97b0fef4 --- /dev/null +++ b/src/main/java/org/openapitools/client/auth/Authentication.java @@ -0,0 +1,36 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.auth; + +import org.openapitools.client.Pair; +import org.openapitools.client.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} diff --git a/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java b/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java new file mode 100644 index 00000000..b5dc1eca --- /dev/null +++ b/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java @@ -0,0 +1,55 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.auth; + +import org.openapitools.client.Pair; +import org.openapitools.client.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java b/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java new file mode 100644 index 00000000..7dbd0a52 --- /dev/null +++ b/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java @@ -0,0 +1,63 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.auth; + +import org.openapitools.client.ApiException; +import org.openapitools.client.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java new file mode 100644 index 00000000..39b895ec --- /dev/null +++ b/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java @@ -0,0 +1,146 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Map; + +//import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + //@JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/src/main/java/org/openapitools/client/model/AwsRegions.java b/src/main/java/org/openapitools/client/model/AwsRegions.java new file mode 100644 index 00000000..80af2470 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/AwsRegions.java @@ -0,0 +1,71 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Regions available with the AWS cloud provider + */ +@JsonAdapter(AwsRegions.Adapter.class) +public enum AwsRegions { + + EAST_1("us-east-1"), + + WEST_1("us-west-1"), + + WEST_2("us-west-2"); + + private String value; + + AwsRegions(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AwsRegions fromValue(String value) { + for (AwsRegions b : AwsRegions.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final AwsRegions enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AwsRegions read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return AwsRegions.fromValue(value); + } + } +} + diff --git a/src/main/java/org/openapitools/client/model/CollectionList.java b/src/main/java/org/openapitools/client/model/CollectionList.java new file mode 100644 index 00000000..699874ca --- /dev/null +++ b/src/main/java/org/openapitools/client/model/CollectionList.java @@ -0,0 +1,216 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +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.List; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The list of collections that exist in the project. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class CollectionList { + public static final String SERIALIZED_NAME_COLLECTIONS = "collections"; + @SerializedName(SERIALIZED_NAME_COLLECTIONS) + private List collections; + + public CollectionList() { + } + + public CollectionList collections(List collections) { + + this.collections = collections; + return this; + } + + public CollectionList addCollectionsItem(CollectionModel collectionsItem) { + if (this.collections == null) { + this.collections = new ArrayList<>(); + } + this.collections.add(collectionsItem); + return this; + } + + /** + * Get collections + * @return collections + **/ + @javax.annotation.Nullable + public List getCollections() { + return collections; + } + + + public void setCollections(List collections) { + this.collections = collections; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CollectionList collectionList = (CollectionList) o; + return Objects.equals(this.collections, collectionList.collections); + } + + @Override + public int hashCode() { + return Objects.hash(collections); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CollectionList {\n"); + sb.append(" collections: ").append(toIndentedString(collections)).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(); + openapiFields.add("collections"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 CollectionList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CollectionList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CollectionList is not found in the empty JSON string", CollectionList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CollectionList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CollectionList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("collections") != null && !jsonObj.get("collections").isJsonNull()) { + JsonArray jsonArraycollections = jsonObj.getAsJsonArray("collections"); + if (jsonArraycollections != null) { + // ensure the json data is an array + if (!jsonObj.get("collections").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `collections` to be an array in the JSON string but got `%s`", jsonObj.get("collections").toString())); + } + + // validate the optional field `collections` (array) + for (int i = 0; i < jsonArraycollections.size(); i++) { + CollectionModel.validateJsonElement(jsonArraycollections.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CollectionList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CollectionList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CollectionList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CollectionList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CollectionList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CollectionList given an JSON string + * + * @param jsonString JSON string + * @return An instance of CollectionList + * @throws IOException if the JSON string is invalid with respect to CollectionList + */ + public static CollectionList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CollectionList.class); + } + + /** + * Convert an instance of CollectionList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/CollectionModel.java b/src/main/java/org/openapitools/client/model/CollectionModel.java new file mode 100644 index 00000000..a179c10d --- /dev/null +++ b/src/main/java/org/openapitools/client/model/CollectionModel.java @@ -0,0 +1,401 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +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 com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The CollectionModel describes the configuration and status of a Pinecone collection. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class CollectionModel { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + private Long size; + + /** + * The status of the collection. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + INITIALIZING("Initializing"), + + READY("Ready"), + + TERMINATING("Terminating"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public static final String SERIALIZED_NAME_DIMENSION = "dimension"; + @SerializedName(SERIALIZED_NAME_DIMENSION) + private Integer dimension; + + public static final String SERIALIZED_NAME_VECTOR_COUNT = "vector_count"; + @SerializedName(SERIALIZED_NAME_VECTOR_COUNT) + private Integer vectorCount; + + public static final String SERIALIZED_NAME_ENVIRONMENT = "environment"; + @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + private String environment; + + public CollectionModel() { + } + + public CollectionModel name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public CollectionModel size(Long size) { + + this.size = size; + return this; + } + + /** + * The size of the collection in bytes. + * @return size + **/ + @javax.annotation.Nullable + public Long getSize() { + return size; + } + + + public void setSize(Long size) { + this.size = size; + } + + + public CollectionModel status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * The status of the collection. + * @return status + **/ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + public CollectionModel dimension(Integer dimension) { + + this.dimension = dimension; + return this; + } + + /** + * The dimension of the vectors stored in each record held in the collection + * minimum: 1 + * maximum: 2000 + * @return dimension + **/ + @javax.annotation.Nullable + public Integer getDimension() { + return dimension; + } + + + public void setDimension(Integer dimension) { + this.dimension = dimension; + } + + + public CollectionModel vectorCount(Integer vectorCount) { + + this.vectorCount = vectorCount; + return this; + } + + /** + * The number of records stored in the collection + * @return vectorCount + **/ + @javax.annotation.Nullable + public Integer getVectorCount() { + return vectorCount; + } + + + public void setVectorCount(Integer vectorCount) { + this.vectorCount = vectorCount; + } + + + public CollectionModel environment(String environment) { + + this.environment = environment; + return this; + } + + /** + * The environment where the collection is hosted. + * @return environment + **/ + @javax.annotation.Nullable + public String getEnvironment() { + return environment; + } + + + public void setEnvironment(String environment) { + this.environment = environment; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CollectionModel collectionModel = (CollectionModel) o; + return Objects.equals(this.name, collectionModel.name) && + Objects.equals(this.size, collectionModel.size) && + Objects.equals(this.status, collectionModel.status) && + Objects.equals(this.dimension, collectionModel.dimension) && + Objects.equals(this.vectorCount, collectionModel.vectorCount) && + Objects.equals(this.environment, collectionModel.environment); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, status, dimension, vectorCount, environment); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CollectionModel {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" dimension: ").append(toIndentedString(dimension)).append("\n"); + sb.append(" vectorCount: ").append(toIndentedString(vectorCount)).append("\n"); + sb.append(" environment: ").append(toIndentedString(environment)).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(); + openapiFields.add("name"); + openapiFields.add("size"); + openapiFields.add("status"); + openapiFields.add("dimension"); + openapiFields.add("vector_count"); + openapiFields.add("environment"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("status"); + } + + /** + * 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 CollectionModel + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CollectionModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CollectionModel is not found in the empty JSON string", CollectionModel.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CollectionModel.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CollectionModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CollectionModel.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } + if ((jsonObj.get("environment") != null && !jsonObj.get("environment").isJsonNull()) && !jsonObj.get("environment").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `environment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("environment").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CollectionModel.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CollectionModel' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CollectionModel.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CollectionModel value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CollectionModel read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CollectionModel given an JSON string + * + * @param jsonString JSON string + * @return An instance of CollectionModel + * @throws IOException if the JSON string is invalid with respect to CollectionModel + */ + public static CollectionModel fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CollectionModel.class); + } + + /** + * Convert an instance of CollectionModel to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/ConfigureIndexRequest.java b/src/main/java/org/openapitools/client/model/ConfigureIndexRequest.java new file mode 100644 index 00000000..9282a9a9 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/ConfigureIndexRequest.java @@ -0,0 +1,201 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Configuration used to scale an index. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ConfigureIndexRequest { + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private ConfigureIndexRequestSpec spec; + + public ConfigureIndexRequest() { + } + + public ConfigureIndexRequest spec(ConfigureIndexRequestSpec spec) { + + this.spec = spec; + return this; + } + + /** + * Get spec + * @return spec + **/ + @javax.annotation.Nonnull + public ConfigureIndexRequestSpec getSpec() { + return spec; + } + + + public void setSpec(ConfigureIndexRequestSpec spec) { + this.spec = spec; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConfigureIndexRequest configureIndexRequest = (ConfigureIndexRequest) o; + return Objects.equals(this.spec, configureIndexRequest.spec); + } + + @Override + public int hashCode() { + return Objects.hash(spec); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConfigureIndexRequest {\n"); + sb.append(" spec: ").append(toIndentedString(spec)).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(); + openapiFields.add("spec"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("spec"); + } + + /** + * 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 ConfigureIndexRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ConfigureIndexRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ConfigureIndexRequest is not found in the empty JSON string", ConfigureIndexRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConfigureIndexRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ConfigureIndexRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ConfigureIndexRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `spec` + ConfigureIndexRequestSpec.validateJsonElement(jsonObj.get("spec")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConfigureIndexRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConfigureIndexRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ConfigureIndexRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ConfigureIndexRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ConfigureIndexRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ConfigureIndexRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConfigureIndexRequest + * @throws IOException if the JSON string is invalid with respect to ConfigureIndexRequest + */ + public static ConfigureIndexRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConfigureIndexRequest.class); + } + + /** + * Convert an instance of ConfigureIndexRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpec.java b/src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpec.java new file mode 100644 index 00000000..a6e8ba80 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpec.java @@ -0,0 +1,201 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * ConfigureIndexRequestSpec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ConfigureIndexRequestSpec { + public static final String SERIALIZED_NAME_POD = "pod"; + @SerializedName(SERIALIZED_NAME_POD) + private ConfigureIndexRequestSpecPod pod; + + public ConfigureIndexRequestSpec() { + } + + public ConfigureIndexRequestSpec pod(ConfigureIndexRequestSpecPod pod) { + + this.pod = pod; + return this; + } + + /** + * Get pod + * @return pod + **/ + @javax.annotation.Nonnull + public ConfigureIndexRequestSpecPod getPod() { + return pod; + } + + + public void setPod(ConfigureIndexRequestSpecPod pod) { + this.pod = pod; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConfigureIndexRequestSpec configureIndexRequestSpec = (ConfigureIndexRequestSpec) o; + return Objects.equals(this.pod, configureIndexRequestSpec.pod); + } + + @Override + public int hashCode() { + return Objects.hash(pod); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConfigureIndexRequestSpec {\n"); + sb.append(" pod: ").append(toIndentedString(pod)).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(); + openapiFields.add("pod"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("pod"); + } + + /** + * 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 ConfigureIndexRequestSpec + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ConfigureIndexRequestSpec.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ConfigureIndexRequestSpec is not found in the empty JSON string", ConfigureIndexRequestSpec.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConfigureIndexRequestSpec.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ConfigureIndexRequestSpec` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ConfigureIndexRequestSpec.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `pod` + ConfigureIndexRequestSpecPod.validateJsonElement(jsonObj.get("pod")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConfigureIndexRequestSpec.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConfigureIndexRequestSpec' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ConfigureIndexRequestSpec.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ConfigureIndexRequestSpec value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ConfigureIndexRequestSpec read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ConfigureIndexRequestSpec given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConfigureIndexRequestSpec + * @throws IOException if the JSON string is invalid with respect to ConfigureIndexRequestSpec + */ + public static ConfigureIndexRequestSpec fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConfigureIndexRequestSpec.class); + } + + /** + * Convert an instance of ConfigureIndexRequestSpec to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpecPod.java b/src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpecPod.java new file mode 100644 index 00000000..6a1ff6e6 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/ConfigureIndexRequestSpecPod.java @@ -0,0 +1,223 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * ConfigureIndexRequestSpecPod + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ConfigureIndexRequestSpecPod { + public static final String SERIALIZED_NAME_REPLICAS = "replicas"; + @SerializedName(SERIALIZED_NAME_REPLICAS) + private Integer replicas = 1; + + public static final String SERIALIZED_NAME_POD_TYPE = "pod_type"; + @SerializedName(SERIALIZED_NAME_POD_TYPE) + private String podType = "p1.x1"; + + public ConfigureIndexRequestSpecPod() { + } + + public ConfigureIndexRequestSpecPod replicas(Integer replicas) { + + this.replicas = replicas; + return this; + } + + /** + * The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. + * minimum: 1 + * @return replicas + **/ + @javax.annotation.Nullable + public Integer getReplicas() { + return replicas; + } + + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + + public ConfigureIndexRequestSpecPod podType(String podType) { + + this.podType = podType; + return this; + } + + /** + * The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. + * @return podType + **/ + @javax.annotation.Nullable + public String getPodType() { + return podType; + } + + + public void setPodType(String podType) { + this.podType = podType; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConfigureIndexRequestSpecPod configureIndexRequestSpecPod = (ConfigureIndexRequestSpecPod) o; + return Objects.equals(this.replicas, configureIndexRequestSpecPod.replicas) && + Objects.equals(this.podType, configureIndexRequestSpecPod.podType); + } + + @Override + public int hashCode() { + return Objects.hash(replicas, podType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConfigureIndexRequestSpecPod {\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb.append(" podType: ").append(toIndentedString(podType)).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(); + openapiFields.add("replicas"); + openapiFields.add("pod_type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 ConfigureIndexRequestSpecPod + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ConfigureIndexRequestSpecPod.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ConfigureIndexRequestSpecPod is not found in the empty JSON string", ConfigureIndexRequestSpecPod.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConfigureIndexRequestSpecPod.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ConfigureIndexRequestSpecPod` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pod_type") != null && !jsonObj.get("pod_type").isJsonNull()) && !jsonObj.get("pod_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `pod_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("pod_type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConfigureIndexRequestSpecPod.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConfigureIndexRequestSpecPod' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ConfigureIndexRequestSpecPod.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ConfigureIndexRequestSpecPod value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ConfigureIndexRequestSpecPod read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ConfigureIndexRequestSpecPod given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConfigureIndexRequestSpecPod + * @throws IOException if the JSON string is invalid with respect to ConfigureIndexRequestSpecPod + */ + public static ConfigureIndexRequestSpecPod fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConfigureIndexRequestSpecPod.class); + } + + /** + * Convert an instance of ConfigureIndexRequestSpecPod to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/CreateCollectionRequest.java b/src/main/java/org/openapitools/client/model/CreateCollectionRequest.java new file mode 100644 index 00000000..af475fe3 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/CreateCollectionRequest.java @@ -0,0 +1,234 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The configuration needed to create a Pinecone collection. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class CreateCollectionRequest { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + private String source; + + public CreateCollectionRequest() { + } + + public CreateCollectionRequest name(String name) { + + this.name = name; + return this; + } + + /** + * The name of the collection to be created. + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public CreateCollectionRequest source(String source) { + + this.source = source; + return this; + } + + /** + * The name of the index to be used as the source for the collection. + * @return source + **/ + @javax.annotation.Nonnull + public String getSource() { + return source; + } + + + public void setSource(String source) { + this.source = source; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateCollectionRequest createCollectionRequest = (CreateCollectionRequest) o; + return Objects.equals(this.name, createCollectionRequest.name) && + Objects.equals(this.source, createCollectionRequest.source); + } + + @Override + public int hashCode() { + return Objects.hash(name, source); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateCollectionRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).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(); + openapiFields.add("name"); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("source"); + } + + /** + * 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 CreateCollectionRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateCollectionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateCollectionRequest is not found in the empty JSON string", CreateCollectionRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateCollectionRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateCollectionRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateCollectionRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateCollectionRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateCollectionRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateCollectionRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateCollectionRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateCollectionRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateCollectionRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateCollectionRequest + * @throws IOException if the JSON string is invalid with respect to CreateCollectionRequest + */ + public static CreateCollectionRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateCollectionRequest.class); + } + + /** + * Convert an instance of CreateCollectionRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/CreateIndexRequest.java b/src/main/java/org/openapitools/client/model/CreateIndexRequest.java new file mode 100644 index 00000000..29c2d9b9 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/CreateIndexRequest.java @@ -0,0 +1,293 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The configuration needed to create a Pinecone index. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class CreateIndexRequest { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DIMENSION = "dimension"; + @SerializedName(SERIALIZED_NAME_DIMENSION) + private Integer dimension; + + public static final String SERIALIZED_NAME_METRIC = "metric"; + @SerializedName(SERIALIZED_NAME_METRIC) + private IndexMetric metric; + + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private CreateIndexRequestSpec spec; + + public CreateIndexRequest() { + } + + public CreateIndexRequest name(String name) { + + this.name = name; + return this; + } + + /** + * The name of the index. The maximum length is 45 characters. It may contain lowercase alphanumeric characters or hyphens, and must not begin or end with a hyphen. + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public CreateIndexRequest dimension(Integer dimension) { + + this.dimension = dimension; + return this; + } + + /** + * The dimensions of the vectors to be inserted in the index + * minimum: 1 + * maximum: 20000 + * @return dimension + **/ + @javax.annotation.Nonnull + public Integer getDimension() { + return dimension; + } + + + public void setDimension(Integer dimension) { + this.dimension = dimension; + } + + + public CreateIndexRequest metric(IndexMetric metric) { + + this.metric = metric; + return this; + } + + /** + * Get metric + * @return metric + **/ + @javax.annotation.Nonnull + public IndexMetric getMetric() { + return metric; + } + + + public void setMetric(IndexMetric metric) { + this.metric = metric; + } + + + public CreateIndexRequest spec(CreateIndexRequestSpec spec) { + + this.spec = spec; + return this; + } + + /** + * Get spec + * @return spec + **/ + @javax.annotation.Nullable + public CreateIndexRequestSpec getSpec() { + return spec; + } + + + public void setSpec(CreateIndexRequestSpec spec) { + this.spec = spec; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateIndexRequest createIndexRequest = (CreateIndexRequest) o; + return Objects.equals(this.name, createIndexRequest.name) && + Objects.equals(this.dimension, createIndexRequest.dimension) && + Objects.equals(this.metric, createIndexRequest.metric) && + Objects.equals(this.spec, createIndexRequest.spec); + } + + @Override + public int hashCode() { + return Objects.hash(name, dimension, metric, spec); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateIndexRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" dimension: ").append(toIndentedString(dimension)).append("\n"); + sb.append(" metric: ").append(toIndentedString(metric)).append("\n"); + sb.append(" spec: ").append(toIndentedString(spec)).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(); + openapiFields.add("name"); + openapiFields.add("dimension"); + openapiFields.add("metric"); + openapiFields.add("spec"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("dimension"); + openapiRequiredFields.add("metric"); + openapiRequiredFields.add("spec"); + } + + /** + * 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 CreateIndexRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateIndexRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateIndexRequest is not found in the empty JSON string", CreateIndexRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateIndexRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateIndexRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateIndexRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `spec` + CreateIndexRequestSpec.validateJsonElement(jsonObj.get("spec")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateIndexRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateIndexRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateIndexRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateIndexRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateIndexRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateIndexRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateIndexRequest + * @throws IOException if the JSON string is invalid with respect to CreateIndexRequest + */ + public static CreateIndexRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateIndexRequest.class); + } + + /** + * Convert an instance of CreateIndexRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/CreateIndexRequestSpec.java b/src/main/java/org/openapitools/client/model/CreateIndexRequestSpec.java new file mode 100644 index 00000000..9ef453c2 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/CreateIndexRequestSpec.java @@ -0,0 +1,225 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Spec objects describe how the index should be deployed + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class CreateIndexRequestSpec { + public static final String SERIALIZED_NAME_SERVERLESS = "serverless"; + @SerializedName(SERIALIZED_NAME_SERVERLESS) + private ServerlessSpec serverless; + + public static final String SERIALIZED_NAME_POD = "pod"; + @SerializedName(SERIALIZED_NAME_POD) + private CreateIndexRequestSpecPod pod; + + public CreateIndexRequestSpec() { + } + + public CreateIndexRequestSpec serverless(ServerlessSpec serverless) { + + this.serverless = serverless; + return this; + } + + /** + * Get serverless + * @return serverless + **/ + @javax.annotation.Nullable + public ServerlessSpec getServerless() { + return serverless; + } + + + public void setServerless(ServerlessSpec serverless) { + this.serverless = serverless; + } + + + public CreateIndexRequestSpec pod(CreateIndexRequestSpecPod pod) { + + this.pod = pod; + return this; + } + + /** + * Get pod + * @return pod + **/ + @javax.annotation.Nullable + public CreateIndexRequestSpecPod getPod() { + return pod; + } + + + public void setPod(CreateIndexRequestSpecPod pod) { + this.pod = pod; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateIndexRequestSpec createIndexRequestSpec = (CreateIndexRequestSpec) o; + return Objects.equals(this.serverless, createIndexRequestSpec.serverless) && + Objects.equals(this.pod, createIndexRequestSpec.pod); + } + + @Override + public int hashCode() { + return Objects.hash(serverless, pod); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateIndexRequestSpec {\n"); + sb.append(" serverless: ").append(toIndentedString(serverless)).append("\n"); + sb.append(" pod: ").append(toIndentedString(pod)).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(); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 CreateIndexRequestSpec + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateIndexRequestSpec.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateIndexRequestSpec is not found in the empty JSON string", CreateIndexRequestSpec.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateIndexRequestSpec.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateIndexRequestSpec` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `serverless` + if (jsonObj.get("serverless") != null && !jsonObj.get("serverless").isJsonNull()) { + ServerlessSpec.validateJsonElement(jsonObj.get("serverless")); + } + // validate the optional field `pod` + if (jsonObj.get("pod") != null && !jsonObj.get("pod").isJsonNull()) { + CreateIndexRequestSpecPod.validateJsonElement(jsonObj.get("pod")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateIndexRequestSpec.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateIndexRequestSpec' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateIndexRequestSpec.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateIndexRequestSpec value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateIndexRequestSpec read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateIndexRequestSpec given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateIndexRequestSpec + * @throws IOException if the JSON string is invalid with respect to CreateIndexRequestSpec + */ + public static CreateIndexRequestSpec fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateIndexRequestSpec.class); + } + + /** + * Convert an instance of CreateIndexRequestSpec to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/CreateIndexRequestSpecPod.java b/src/main/java/org/openapitools/client/model/CreateIndexRequestSpecPod.java new file mode 100644 index 00000000..70a2aa53 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/CreateIndexRequestSpecPod.java @@ -0,0 +1,384 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Configuration needed to deploy a pod index + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class CreateIndexRequestSpecPod { + public static final String SERIALIZED_NAME_ENVIRONMENT = "environment"; + @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + private String environment; + + public static final String SERIALIZED_NAME_REPLICAS = "replicas"; + @SerializedName(SERIALIZED_NAME_REPLICAS) + private Integer replicas = 1; + + public static final String SERIALIZED_NAME_POD_TYPE = "pod_type"; + @SerializedName(SERIALIZED_NAME_POD_TYPE) + private String podType = "p1.x1"; + + public static final String SERIALIZED_NAME_PODS = "pods"; + @SerializedName(SERIALIZED_NAME_PODS) + private Integer pods; + + public static final String SERIALIZED_NAME_SHARDS = "shards"; + @SerializedName(SERIALIZED_NAME_SHARDS) + private Integer shards = 1; + + public static final String SERIALIZED_NAME_METADATA_CONFIG = "metadata_config"; + @SerializedName(SERIALIZED_NAME_METADATA_CONFIG) + private PodSpecMetadataConfig metadataConfig; + + public static final String SERIALIZED_NAME_SOURCE_COLLECTION = "source_collection"; + @SerializedName(SERIALIZED_NAME_SOURCE_COLLECTION) + private String sourceCollection; + + public CreateIndexRequestSpecPod() { + } + + public CreateIndexRequestSpecPod environment(String environment) { + + this.environment = environment; + return this; + } + + /** + * The environment where the index is hosted. + * @return environment + **/ + @javax.annotation.Nonnull + public String getEnvironment() { + return environment; + } + + + public void setEnvironment(String environment) { + this.environment = environment; + } + + + public CreateIndexRequestSpecPod replicas(Integer replicas) { + + this.replicas = replicas; + return this; + } + + /** + * The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. + * minimum: 1 + * @return replicas + **/ + @javax.annotation.Nullable + public Integer getReplicas() { + return replicas; + } + + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + + public CreateIndexRequestSpecPod podType(String podType) { + + this.podType = podType; + return this; + } + + /** + * The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. + * @return podType + **/ + @javax.annotation.Nonnull + public String getPodType() { + return podType; + } + + + public void setPodType(String podType) { + this.podType = podType; + } + + + public CreateIndexRequestSpecPod pods(Integer pods) { + + this.pods = pods; + return this; + } + + /** + * The number of pods to be used in the index. This should be equal to `shards` x `replicas`. + * minimum: 1 + * @return pods + **/ + @javax.annotation.Nullable + public Integer getPods() { + return pods; + } + + + public void setPods(Integer pods) { + this.pods = pods; + } + + + public CreateIndexRequestSpecPod shards(Integer shards) { + + this.shards = shards; + return this; + } + + /** + * The number of shards. Shards split your data across multiple pods so you can fit more data into an index. + * minimum: 1 + * @return shards + **/ + @javax.annotation.Nullable + public Integer getShards() { + return shards; + } + + + public void setShards(Integer shards) { + this.shards = shards; + } + + + public CreateIndexRequestSpecPod metadataConfig(PodSpecMetadataConfig metadataConfig) { + + this.metadataConfig = metadataConfig; + return this; + } + + /** + * Get metadataConfig + * @return metadataConfig + **/ + @javax.annotation.Nullable + public PodSpecMetadataConfig getMetadataConfig() { + return metadataConfig; + } + + + public void setMetadataConfig(PodSpecMetadataConfig metadataConfig) { + this.metadataConfig = metadataConfig; + } + + + public CreateIndexRequestSpecPod sourceCollection(String sourceCollection) { + + this.sourceCollection = sourceCollection; + return this; + } + + /** + * The name of the collection to be used as the source for the index. + * @return sourceCollection + **/ + @javax.annotation.Nullable + public String getSourceCollection() { + return sourceCollection; + } + + + public void setSourceCollection(String sourceCollection) { + this.sourceCollection = sourceCollection; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateIndexRequestSpecPod createIndexRequestSpecPod = (CreateIndexRequestSpecPod) o; + return Objects.equals(this.environment, createIndexRequestSpecPod.environment) && + Objects.equals(this.replicas, createIndexRequestSpecPod.replicas) && + Objects.equals(this.podType, createIndexRequestSpecPod.podType) && + Objects.equals(this.pods, createIndexRequestSpecPod.pods) && + Objects.equals(this.shards, createIndexRequestSpecPod.shards) && + Objects.equals(this.metadataConfig, createIndexRequestSpecPod.metadataConfig) && + Objects.equals(this.sourceCollection, createIndexRequestSpecPod.sourceCollection); + } + + @Override + public int hashCode() { + return Objects.hash(environment, replicas, podType, pods, shards, metadataConfig, sourceCollection); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateIndexRequestSpecPod {\n"); + sb.append(" environment: ").append(toIndentedString(environment)).append("\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb.append(" podType: ").append(toIndentedString(podType)).append("\n"); + sb.append(" pods: ").append(toIndentedString(pods)).append("\n"); + sb.append(" shards: ").append(toIndentedString(shards)).append("\n"); + sb.append(" metadataConfig: ").append(toIndentedString(metadataConfig)).append("\n"); + sb.append(" sourceCollection: ").append(toIndentedString(sourceCollection)).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(); + openapiFields.add("environment"); + openapiFields.add("replicas"); + openapiFields.add("pod_type"); + openapiFields.add("pods"); + openapiFields.add("shards"); + openapiFields.add("metadata_config"); + openapiFields.add("source_collection"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("environment"); + openapiRequiredFields.add("pod_type"); + } + + /** + * 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 CreateIndexRequestSpecPod + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateIndexRequestSpecPod.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateIndexRequestSpecPod is not found in the empty JSON string", CreateIndexRequestSpecPod.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateIndexRequestSpecPod.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateIndexRequestSpecPod` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateIndexRequestSpecPod.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("environment").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `environment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("environment").toString())); + } + if (!jsonObj.get("pod_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `pod_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("pod_type").toString())); + } + // validate the optional field `metadata_config` + if (jsonObj.get("metadata_config") != null && !jsonObj.get("metadata_config").isJsonNull()) { + PodSpecMetadataConfig.validateJsonElement(jsonObj.get("metadata_config")); + } + if ((jsonObj.get("source_collection") != null && !jsonObj.get("source_collection").isJsonNull()) && !jsonObj.get("source_collection").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_collection` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_collection").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateIndexRequestSpecPod.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateIndexRequestSpecPod' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateIndexRequestSpecPod.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateIndexRequestSpecPod value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateIndexRequestSpecPod read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateIndexRequestSpecPod given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateIndexRequestSpecPod + * @throws IOException if the JSON string is invalid with respect to CreateIndexRequestSpecPod + */ + public static CreateIndexRequestSpecPod fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateIndexRequestSpecPod.class); + } + + /** + * Convert an instance of CreateIndexRequestSpecPod to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/ErrorResponse.java b/src/main/java/org/openapitools/client/model/ErrorResponse.java new file mode 100644 index 00000000..673ee66f --- /dev/null +++ b/src/main/java/org/openapitools/client/model/ErrorResponse.java @@ -0,0 +1,230 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The response shape used for all error responses + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ErrorResponse { + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private Integer status; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + private ErrorResponseError error; + + public ErrorResponse() { + } + + public ErrorResponse status(Integer status) { + + this.status = status; + return this; + } + + /** + * The HTTP status code of the error + * @return status + **/ + @javax.annotation.Nonnull + public Integer getStatus() { + return status; + } + + + public void setStatus(Integer status) { + this.status = status; + } + + + public ErrorResponse error(ErrorResponseError error) { + + this.error = error; + return this; + } + + /** + * Get error + * @return error + **/ + @javax.annotation.Nonnull + public ErrorResponseError getError() { + return error; + } + + + public void setError(ErrorResponseError error) { + this.error = error; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.status, errorResponse.status) && + Objects.equals(this.error, errorResponse.error); + } + + @Override + public int hashCode() { + return Objects.hash(status, error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponse {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).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(); + openapiFields.add("status"); + openapiFields.add("error"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("status"); + openapiRequiredFields.add("error"); + } + + /** + * 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 ErrorResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ErrorResponse is not found in the empty JSON string", ErrorResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ErrorResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ErrorResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `error` + ErrorResponseError.validateJsonElement(jsonObj.get("error")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ErrorResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ErrorResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponse + * @throws IOException if the JSON string is invalid with respect to ErrorResponse + */ + public static ErrorResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponse.class); + } + + /** + * Convert an instance of ErrorResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/ErrorResponseError.java b/src/main/java/org/openapitools/client/model/ErrorResponseError.java new file mode 100644 index 00000000..e596b6c3 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/ErrorResponseError.java @@ -0,0 +1,342 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +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 com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Detailed information about the error that occurred + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ErrorResponseError { + /** + * Gets or Sets code + */ + @JsonAdapter(CodeEnum.Adapter.class) + public enum CodeEnum { + QUOTA_EXCEEDED("QUOTA_EXCEEDED"), + + BAD_PARAMS("BAD_PARAMS"), + + CANCELLED("CANCELLED"), + + UNKNOWN("UNKNOWN"), + + INVALID_ARGUMENT("INVALID_ARGUMENT"), + + DEADLINE_EXCEEDED("DEADLINE_EXCEEDED"), + + NOT_FOUND("NOT_FOUND"), + + ALREADY_EXISTS("ALREADY_EXISTS"), + + PERMISSION_DENIED("PERMISSION_DENIED"), + + UNAUTHENTICATED("UNAUTHENTICATED"), + + RESOURCE_EXHAUSTED("RESOURCE_EXHAUSTED"), + + FAILED_PRECONDITION("FAILED_PRECONDITION"), + + ABORTED("ABORTED"), + + OUT_OF_RANGE("OUT_OF_RANGE"), + + UNIMPLEMENTED("UNIMPLEMENTED"), + + INTERNAL("INTERNAL"), + + UNAVAILABLE("UNAVAILABLE"), + + DATA_LOSS("DATA_LOSS"); + + private String value; + + CodeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CodeEnum fromValue(String value) { + for (CodeEnum b : CodeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CodeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CodeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CodeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_CODE = "code"; + @SerializedName(SERIALIZED_NAME_CODE) + private CodeEnum code; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_DETAILS = "details"; + @SerializedName(SERIALIZED_NAME_DETAILS) + private Object details; + + public ErrorResponseError() { + } + + public ErrorResponseError code(CodeEnum code) { + + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @javax.annotation.Nonnull + public CodeEnum getCode() { + return code; + } + + + public void setCode(CodeEnum code) { + this.code = code; + } + + + public ErrorResponseError message(String message) { + + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public ErrorResponseError details(Object details) { + + this.details = details; + return this; + } + + /** + * Additional information about the error. This field is not guaranteed to be present. + * @return details + **/ + @javax.annotation.Nullable + public Object getDetails() { + return details; + } + + + public void setDetails(Object details) { + this.details = details; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorResponseError errorResponseError = (ErrorResponseError) o; + return Objects.equals(this.code, errorResponseError.code) && + Objects.equals(this.message, errorResponseError.message) && + Objects.equals(this.details, errorResponseError.details); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, details); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponseError {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).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(); + openapiFields.add("code"); + openapiFields.add("message"); + openapiFields.add("details"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("code"); + openapiRequiredFields.add("message"); + } + + /** + * 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 ErrorResponseError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorResponseError.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ErrorResponseError is not found in the empty JSON string", ErrorResponseError.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ErrorResponseError.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ErrorResponseError` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorResponseError.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("code").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponseError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponseError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorResponseError.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponseError value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ErrorResponseError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ErrorResponseError given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponseError + * @throws IOException if the JSON string is invalid with respect to ErrorResponseError + */ + public static ErrorResponseError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponseError.class); + } + + /** + * Convert an instance of ErrorResponseError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/GcpRegions.java b/src/main/java/org/openapitools/client/model/GcpRegions.java new file mode 100644 index 00000000..5655bfc8 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/GcpRegions.java @@ -0,0 +1,77 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Regions available with the GCP cloud provider + */ +@JsonAdapter(GcpRegions.Adapter.class) +public enum GcpRegions { + + US_WEST1("us-west1"), + + US_WEST2("us-west2"), + + EU_WEST4("eu-west4"), + + NORTHAMERICA_NORTHEAST1("northamerica-northeast1"), + + ASIA_NORTHEAST1("asia-northeast1"), + + ASIA_SOUTHEAST1C("asia-southeast1C"); + + private String value; + + GcpRegions(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static GcpRegions fromValue(String value) { + for (GcpRegions b : GcpRegions.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final GcpRegions enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public GcpRegions read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return GcpRegions.fromValue(value); + } + } +} + diff --git a/src/main/java/org/openapitools/client/model/IndexList.java b/src/main/java/org/openapitools/client/model/IndexList.java new file mode 100644 index 00000000..1fd6358b --- /dev/null +++ b/src/main/java/org/openapitools/client/model/IndexList.java @@ -0,0 +1,216 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +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.List; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The list of indexes that exist in the project. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class IndexList { + public static final String SERIALIZED_NAME_INDEXES = "indexes"; + @SerializedName(SERIALIZED_NAME_INDEXES) + private List indexes; + + public IndexList() { + } + + public IndexList indexes(List indexes) { + + this.indexes = indexes; + return this; + } + + public IndexList addIndexesItem(IndexModel indexesItem) { + if (this.indexes == null) { + this.indexes = new ArrayList<>(); + } + this.indexes.add(indexesItem); + return this; + } + + /** + * Get indexes + * @return indexes + **/ + @javax.annotation.Nullable + public List getIndexes() { + return indexes; + } + + + public void setIndexes(List indexes) { + this.indexes = indexes; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IndexList indexList = (IndexList) o; + return Objects.equals(this.indexes, indexList.indexes); + } + + @Override + public int hashCode() { + return Objects.hash(indexes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IndexList {\n"); + sb.append(" indexes: ").append(toIndentedString(indexes)).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(); + openapiFields.add("indexes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 IndexList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!IndexList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in IndexList is not found in the empty JSON string", IndexList.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!IndexList.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `IndexList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("indexes") != null && !jsonObj.get("indexes").isJsonNull()) { + JsonArray jsonArrayindexes = jsonObj.getAsJsonArray("indexes"); + if (jsonArrayindexes != null) { + // ensure the json data is an array + if (!jsonObj.get("indexes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `indexes` to be an array in the JSON string but got `%s`", jsonObj.get("indexes").toString())); + } + + // validate the optional field `indexes` (array) + for (int i = 0; i < jsonArrayindexes.size(); i++) { + IndexModel.validateJsonElement(jsonArrayindexes.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!IndexList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'IndexList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(IndexList.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, IndexList value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public IndexList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of IndexList given an JSON string + * + * @param jsonString JSON string + * @return An instance of IndexList + * @throws IOException if the JSON string is invalid with respect to IndexList + */ + public static IndexList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, IndexList.class); + } + + /** + * Convert an instance of IndexList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/IndexMetric.java b/src/main/java/org/openapitools/client/model/IndexMetric.java new file mode 100644 index 00000000..980eea79 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/IndexMetric.java @@ -0,0 +1,71 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. + */ +@JsonAdapter(IndexMetric.Adapter.class) +public enum IndexMetric { + + COSINE("cosine"), + + EUCLIDEAN("euclidean"), + + DOTPRODUCT("dotproduct"); + + private String value; + + IndexMetric(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static IndexMetric fromValue(String value) { + for (IndexMetric b : IndexMetric.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final IndexMetric enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public IndexMetric read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return IndexMetric.fromValue(value); + } + } +} + diff --git a/src/main/java/org/openapitools/client/model/IndexModel.java b/src/main/java/org/openapitools/client/model/IndexModel.java new file mode 100644 index 00000000..9caaef97 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/IndexModel.java @@ -0,0 +1,356 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * The IndexModel describes the configuration and deployment status of a Pinecone index. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class IndexModel { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DIMENSION = "dimension"; + @SerializedName(SERIALIZED_NAME_DIMENSION) + private Integer dimension; + + public static final String SERIALIZED_NAME_METRIC = "metric"; + @SerializedName(SERIALIZED_NAME_METRIC) + private IndexMetric metric; + + public static final String SERIALIZED_NAME_HOST = "host"; + @SerializedName(SERIALIZED_NAME_HOST) + private String host; + + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private IndexModelSpec spec; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private IndexModelStatus status; + + public IndexModel() { + } + + public IndexModel name(String name) { + + this.name = name; + return this; + } + + /** + * The name of the index. The maximum length is 45 characters. It may contain lowercase alphanumeric characters or hyphens, and must not begin or end with a hyphen. + * @return name + **/ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public IndexModel dimension(Integer dimension) { + + this.dimension = dimension; + return this; + } + + /** + * The dimensions of the vectors to be inserted in the index + * minimum: 1 + * maximum: 20000 + * @return dimension + **/ + @javax.annotation.Nonnull + public Integer getDimension() { + return dimension; + } + + + public void setDimension(Integer dimension) { + this.dimension = dimension; + } + + + public IndexModel metric(IndexMetric metric) { + + this.metric = metric; + return this; + } + + /** + * Get metric + * @return metric + **/ + @javax.annotation.Nonnull + public IndexMetric getMetric() { + return metric; + } + + + public void setMetric(IndexMetric metric) { + this.metric = metric; + } + + + public IndexModel host(String host) { + + this.host = host; + return this; + } + + /** + * The URL address where the index is hosted. + * @return host + **/ + @javax.annotation.Nonnull + public String getHost() { + return host; + } + + + public void setHost(String host) { + this.host = host; + } + + + public IndexModel spec(IndexModelSpec spec) { + + this.spec = spec; + return this; + } + + /** + * Get spec + * @return spec + **/ + @javax.annotation.Nonnull + public IndexModelSpec getSpec() { + return spec; + } + + + public void setSpec(IndexModelSpec spec) { + this.spec = spec; + } + + + public IndexModel status(IndexModelStatus status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + public IndexModelStatus getStatus() { + return status; + } + + + public void setStatus(IndexModelStatus status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IndexModel indexModel = (IndexModel) o; + return Objects.equals(this.name, indexModel.name) && + Objects.equals(this.dimension, indexModel.dimension) && + Objects.equals(this.metric, indexModel.metric) && + Objects.equals(this.host, indexModel.host) && + Objects.equals(this.spec, indexModel.spec) && + Objects.equals(this.status, indexModel.status); + } + + @Override + public int hashCode() { + return Objects.hash(name, dimension, metric, host, spec, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IndexModel {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" dimension: ").append(toIndentedString(dimension)).append("\n"); + sb.append(" metric: ").append(toIndentedString(metric)).append("\n"); + sb.append(" host: ").append(toIndentedString(host)).append("\n"); + sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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(); + openapiFields.add("name"); + openapiFields.add("dimension"); + openapiFields.add("metric"); + openapiFields.add("host"); + openapiFields.add("spec"); + openapiFields.add("status"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("name"); + openapiRequiredFields.add("dimension"); + openapiRequiredFields.add("metric"); + openapiRequiredFields.add("host"); + openapiRequiredFields.add("spec"); + openapiRequiredFields.add("status"); + } + + /** + * 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 IndexModel + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!IndexModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in IndexModel is not found in the empty JSON string", IndexModel.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!IndexModel.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `IndexModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : IndexModel.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("host").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `host` to be a primitive type in the JSON string but got `%s`", jsonObj.get("host").toString())); + } + // validate the required field `spec` + IndexModelSpec.validateJsonElement(jsonObj.get("spec")); + // validate the required field `status` + IndexModelStatus.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!IndexModel.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'IndexModel' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(IndexModel.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, IndexModel value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public IndexModel read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of IndexModel given an JSON string + * + * @param jsonString JSON string + * @return An instance of IndexModel + * @throws IOException if the JSON string is invalid with respect to IndexModel + */ + public static IndexModel fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, IndexModel.class); + } + + /** + * Convert an instance of IndexModel to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/IndexModelSpec.java b/src/main/java/org/openapitools/client/model/IndexModelSpec.java new file mode 100644 index 00000000..e6fac63c --- /dev/null +++ b/src/main/java/org/openapitools/client/model/IndexModelSpec.java @@ -0,0 +1,227 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * IndexModelSpec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class IndexModelSpec { + public static final String SERIALIZED_NAME_POD = "pod"; + @SerializedName(SERIALIZED_NAME_POD) + private PodSpec pod; + + public static final String SERIALIZED_NAME_SERVERLESS = "serverless"; + @SerializedName(SERIALIZED_NAME_SERVERLESS) + private ServerlessSpec serverless; + + public IndexModelSpec() { + } + + public IndexModelSpec pod(PodSpec pod) { + + this.pod = pod; + return this; + } + + /** + * Get pod + * @return pod + **/ + @javax.annotation.Nullable + public PodSpec getPod() { + return pod; + } + + + public void setPod(PodSpec pod) { + this.pod = pod; + } + + + public IndexModelSpec serverless(ServerlessSpec serverless) { + + this.serverless = serverless; + return this; + } + + /** + * Get serverless + * @return serverless + **/ + @javax.annotation.Nullable + public ServerlessSpec getServerless() { + return serverless; + } + + + public void setServerless(ServerlessSpec serverless) { + this.serverless = serverless; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IndexModelSpec indexModelSpec = (IndexModelSpec) o; + return Objects.equals(this.pod, indexModelSpec.pod) && + Objects.equals(this.serverless, indexModelSpec.serverless); + } + + @Override + public int hashCode() { + return Objects.hash(pod, serverless); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IndexModelSpec {\n"); + sb.append(" pod: ").append(toIndentedString(pod)).append("\n"); + sb.append(" serverless: ").append(toIndentedString(serverless)).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(); + openapiFields.add("pod"); + openapiFields.add("serverless"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 IndexModelSpec + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!IndexModelSpec.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in IndexModelSpec is not found in the empty JSON string", IndexModelSpec.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!IndexModelSpec.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `IndexModelSpec` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `pod` + if (jsonObj.get("pod") != null && !jsonObj.get("pod").isJsonNull()) { + PodSpec.validateJsonElement(jsonObj.get("pod")); + } + // validate the optional field `serverless` + if (jsonObj.get("serverless") != null && !jsonObj.get("serverless").isJsonNull()) { + ServerlessSpec.validateJsonElement(jsonObj.get("serverless")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!IndexModelSpec.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'IndexModelSpec' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(IndexModelSpec.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, IndexModelSpec value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public IndexModelSpec read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of IndexModelSpec given an JSON string + * + * @param jsonString JSON string + * @return An instance of IndexModelSpec + * @throws IOException if the JSON string is invalid with respect to IndexModelSpec + */ + public static IndexModelSpec fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, IndexModelSpec.class); + } + + /** + * Convert an instance of IndexModelSpec to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/IndexModelStatus.java b/src/main/java/org/openapitools/client/model/IndexModelStatus.java new file mode 100644 index 00000000..f5d55c79 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/IndexModelStatus.java @@ -0,0 +1,291 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +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 com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * IndexModelStatus + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class IndexModelStatus { + public static final String SERIALIZED_NAME_READY = "ready"; + @SerializedName(SERIALIZED_NAME_READY) + private Boolean ready; + + /** + * Gets or Sets state + */ + @JsonAdapter(StateEnum.Adapter.class) + public enum StateEnum { + INITIALIZING("Initializing"), + + INITIALIZATIONFAILED("InitializationFailed"), + + SCALINGUP("ScalingUp"), + + SCALINGDOWN("ScalingDown"), + + SCALINGUPPODSIZE("ScalingUpPodSize"), + + SCALINGDOWNPODSIZE("ScalingDownPodSize"), + + TERMINATING("Terminating"), + + READY("Ready"); + + private String value; + + StateEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StateEnum fromValue(String value) { + for (StateEnum b : StateEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StateEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StateEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StateEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATE = "state"; + @SerializedName(SERIALIZED_NAME_STATE) + private StateEnum state; + + public IndexModelStatus() { + } + + public IndexModelStatus ready(Boolean ready) { + + this.ready = ready; + return this; + } + + /** + * Get ready + * @return ready + **/ + @javax.annotation.Nonnull + public Boolean getReady() { + return ready; + } + + + public void setReady(Boolean ready) { + this.ready = ready; + } + + + public IndexModelStatus state(StateEnum state) { + + this.state = state; + return this; + } + + /** + * Get state + * @return state + **/ + @javax.annotation.Nonnull + public StateEnum getState() { + return state; + } + + + public void setState(StateEnum state) { + this.state = state; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IndexModelStatus indexModelStatus = (IndexModelStatus) o; + return Objects.equals(this.ready, indexModelStatus.ready) && + Objects.equals(this.state, indexModelStatus.state); + } + + @Override + public int hashCode() { + return Objects.hash(ready, state); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IndexModelStatus {\n"); + sb.append(" ready: ").append(toIndentedString(ready)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).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(); + openapiFields.add("ready"); + openapiFields.add("state"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("ready"); + openapiRequiredFields.add("state"); + } + + /** + * 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 IndexModelStatus + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!IndexModelStatus.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in IndexModelStatus is not found in the empty JSON string", IndexModelStatus.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!IndexModelStatus.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `IndexModelStatus` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : IndexModelStatus.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!IndexModelStatus.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'IndexModelStatus' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(IndexModelStatus.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, IndexModelStatus value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public IndexModelStatus read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of IndexModelStatus given an JSON string + * + * @param jsonString JSON string + * @return An instance of IndexModelStatus + * @throws IOException if the JSON string is invalid with respect to IndexModelStatus + */ + public static IndexModelStatus fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, IndexModelStatus.class); + } + + /** + * Convert an instance of IndexModelStatus to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/PodSpec.java b/src/main/java/org/openapitools/client/model/PodSpec.java new file mode 100644 index 00000000..ff2a10c1 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/PodSpec.java @@ -0,0 +1,387 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Configuration needed to deploy a pod index + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class PodSpec { + public static final String SERIALIZED_NAME_ENVIRONMENT = "environment"; + @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + private String environment; + + public static final String SERIALIZED_NAME_REPLICAS = "replicas"; + @SerializedName(SERIALIZED_NAME_REPLICAS) + private Integer replicas = 1; + + public static final String SERIALIZED_NAME_SHARDS = "shards"; + @SerializedName(SERIALIZED_NAME_SHARDS) + private Integer shards = 1; + + public static final String SERIALIZED_NAME_POD_TYPE = "pod_type"; + @SerializedName(SERIALIZED_NAME_POD_TYPE) + private String podType = "p1.x1"; + + public static final String SERIALIZED_NAME_PODS = "pods"; + @SerializedName(SERIALIZED_NAME_PODS) + private Integer pods = 1; + + public static final String SERIALIZED_NAME_METADATA_CONFIG = "metadata_config"; + @SerializedName(SERIALIZED_NAME_METADATA_CONFIG) + private PodSpecMetadataConfig metadataConfig; + + public static final String SERIALIZED_NAME_SOURCE_COLLECTION = "source_collection"; + @SerializedName(SERIALIZED_NAME_SOURCE_COLLECTION) + private String sourceCollection; + + public PodSpec() { + } + + public PodSpec environment(String environment) { + + this.environment = environment; + return this; + } + + /** + * The environment where the index is hosted. + * @return environment + **/ + @javax.annotation.Nonnull + public String getEnvironment() { + return environment; + } + + + public void setEnvironment(String environment) { + this.environment = environment; + } + + + public PodSpec replicas(Integer replicas) { + + this.replicas = replicas; + return this; + } + + /** + * The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. + * minimum: 1 + * @return replicas + **/ + @javax.annotation.Nonnull + public Integer getReplicas() { + return replicas; + } + + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + + public PodSpec shards(Integer shards) { + + this.shards = shards; + return this; + } + + /** + * The number of shards. Shards split your data across multiple pods so you can fit more data into an index. + * minimum: 1 + * @return shards + **/ + @javax.annotation.Nonnull + public Integer getShards() { + return shards; + } + + + public void setShards(Integer shards) { + this.shards = shards; + } + + + public PodSpec podType(String podType) { + + this.podType = podType; + return this; + } + + /** + * The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. + * @return podType + **/ + @javax.annotation.Nonnull + public String getPodType() { + return podType; + } + + + public void setPodType(String podType) { + this.podType = podType; + } + + + public PodSpec pods(Integer pods) { + + this.pods = pods; + return this; + } + + /** + * The number of pods to be used in the index. This should be equal to `shards` x `replicas`. + * minimum: 1 + * @return pods + **/ + @javax.annotation.Nonnull + public Integer getPods() { + return pods; + } + + + public void setPods(Integer pods) { + this.pods = pods; + } + + + public PodSpec metadataConfig(PodSpecMetadataConfig metadataConfig) { + + this.metadataConfig = metadataConfig; + return this; + } + + /** + * Get metadataConfig + * @return metadataConfig + **/ + @javax.annotation.Nullable + public PodSpecMetadataConfig getMetadataConfig() { + return metadataConfig; + } + + + public void setMetadataConfig(PodSpecMetadataConfig metadataConfig) { + this.metadataConfig = metadataConfig; + } + + + public PodSpec sourceCollection(String sourceCollection) { + + this.sourceCollection = sourceCollection; + return this; + } + + /** + * The name of the collection to be used as the source for the index. + * @return sourceCollection + **/ + @javax.annotation.Nullable + public String getSourceCollection() { + return sourceCollection; + } + + + public void setSourceCollection(String sourceCollection) { + this.sourceCollection = sourceCollection; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PodSpec podSpec = (PodSpec) o; + return Objects.equals(this.environment, podSpec.environment) && + Objects.equals(this.replicas, podSpec.replicas) && + Objects.equals(this.shards, podSpec.shards) && + Objects.equals(this.podType, podSpec.podType) && + Objects.equals(this.pods, podSpec.pods) && + Objects.equals(this.metadataConfig, podSpec.metadataConfig) && + Objects.equals(this.sourceCollection, podSpec.sourceCollection); + } + + @Override + public int hashCode() { + return Objects.hash(environment, replicas, shards, podType, pods, metadataConfig, sourceCollection); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PodSpec {\n"); + sb.append(" environment: ").append(toIndentedString(environment)).append("\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb.append(" shards: ").append(toIndentedString(shards)).append("\n"); + sb.append(" podType: ").append(toIndentedString(podType)).append("\n"); + sb.append(" pods: ").append(toIndentedString(pods)).append("\n"); + sb.append(" metadataConfig: ").append(toIndentedString(metadataConfig)).append("\n"); + sb.append(" sourceCollection: ").append(toIndentedString(sourceCollection)).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(); + openapiFields.add("environment"); + openapiFields.add("replicas"); + openapiFields.add("shards"); + openapiFields.add("pod_type"); + openapiFields.add("pods"); + openapiFields.add("metadata_config"); + openapiFields.add("source_collection"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("environment"); + openapiRequiredFields.add("replicas"); + openapiRequiredFields.add("shards"); + openapiRequiredFields.add("pod_type"); + openapiRequiredFields.add("pods"); + } + + /** + * 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 PodSpec + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PodSpec.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PodSpec is not found in the empty JSON string", PodSpec.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PodSpec.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PodSpec` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PodSpec.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("environment").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `environment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("environment").toString())); + } + if (!jsonObj.get("pod_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `pod_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("pod_type").toString())); + } + // validate the optional field `metadata_config` + if (jsonObj.get("metadata_config") != null && !jsonObj.get("metadata_config").isJsonNull()) { + PodSpecMetadataConfig.validateJsonElement(jsonObj.get("metadata_config")); + } + if ((jsonObj.get("source_collection") != null && !jsonObj.get("source_collection").isJsonNull()) && !jsonObj.get("source_collection").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_collection` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_collection").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PodSpec.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PodSpec' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PodSpec.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PodSpec value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PodSpec read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PodSpec given an JSON string + * + * @param jsonString JSON string + * @return An instance of PodSpec + * @throws IOException if the JSON string is invalid with respect to PodSpec + */ + public static PodSpec fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PodSpec.class); + } + + /** + * Convert an instance of PodSpec to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/PodSpecMetadataConfig.java b/src/main/java/org/openapitools/client/model/PodSpecMetadataConfig.java new file mode 100644 index 00000000..24e0b8b6 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/PodSpecMetadataConfig.java @@ -0,0 +1,205 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +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.List; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. These configurations are only valid for use with pod indexes. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class PodSpecMetadataConfig { + public static final String SERIALIZED_NAME_INDEXED = "indexed"; + @SerializedName(SERIALIZED_NAME_INDEXED) + private List indexed; + + public PodSpecMetadataConfig() { + } + + public PodSpecMetadataConfig indexed(List indexed) { + + this.indexed = indexed; + return this; + } + + public PodSpecMetadataConfig addIndexedItem(String indexedItem) { + if (this.indexed == null) { + this.indexed = new ArrayList<>(); + } + this.indexed.add(indexedItem); + return this; + } + + /** + * By default, all metadata is indexed; to change this behavior, use this property to specify an array of metadata fields which should be indexed. + * @return indexed + **/ + @javax.annotation.Nullable + public List getIndexed() { + return indexed; + } + + + public void setIndexed(List indexed) { + this.indexed = indexed; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PodSpecMetadataConfig podSpecMetadataConfig = (PodSpecMetadataConfig) o; + return Objects.equals(this.indexed, podSpecMetadataConfig.indexed); + } + + @Override + public int hashCode() { + return Objects.hash(indexed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PodSpecMetadataConfig {\n"); + sb.append(" indexed: ").append(toIndentedString(indexed)).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(); + openapiFields.add("indexed"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 PodSpecMetadataConfig + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PodSpecMetadataConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PodSpecMetadataConfig is not found in the empty JSON string", PodSpecMetadataConfig.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PodSpecMetadataConfig.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PodSpecMetadataConfig` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("indexed") != null && !jsonObj.get("indexed").isJsonNull() && !jsonObj.get("indexed").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `indexed` to be an array in the JSON string but got `%s`", jsonObj.get("indexed").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PodSpecMetadataConfig.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PodSpecMetadataConfig' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PodSpecMetadataConfig.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PodSpecMetadataConfig value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PodSpecMetadataConfig read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PodSpecMetadataConfig given an JSON string + * + * @param jsonString JSON string + * @return An instance of PodSpecMetadataConfig + * @throws IOException if the JSON string is invalid with respect to PodSpecMetadataConfig + */ + public static PodSpecMetadataConfig fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PodSpecMetadataConfig.class); + } + + /** + * Convert an instance of PodSpecMetadataConfig to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/org/openapitools/client/model/ServerlessSpec.java b/src/main/java/org/openapitools/client/model/ServerlessSpec.java new file mode 100644 index 00000000..3ee07699 --- /dev/null +++ b/src/main/java/org/openapitools/client/model/ServerlessSpec.java @@ -0,0 +1,284 @@ +/* + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +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 com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Configuration needed to deploy a serverless index + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-01-24T09:47:15.815963-05:00[America/New_York]") +public class ServerlessSpec { + /** + * The public cloud where you would like your index hosted + */ + @JsonAdapter(CloudEnum.Adapter.class) + public enum CloudEnum { + GCP("gcp"), + + AWS("aws"), + + AZURE("azure"); + + private String value; + + CloudEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static CloudEnum fromValue(String value) { + for (CloudEnum b : CloudEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final CloudEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public CloudEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return CloudEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_CLOUD = "cloud"; + @SerializedName(SERIALIZED_NAME_CLOUD) + private CloudEnum cloud; + + public static final String SERIALIZED_NAME_REGION = "region"; + @SerializedName(SERIALIZED_NAME_REGION) + private String region; + + public ServerlessSpec() { + } + + public ServerlessSpec cloud(CloudEnum cloud) { + + this.cloud = cloud; + return this; + } + + /** + * The public cloud where you would like your index hosted + * @return cloud + **/ + @javax.annotation.Nonnull + public CloudEnum getCloud() { + return cloud; + } + + + public void setCloud(CloudEnum cloud) { + this.cloud = cloud; + } + + + public ServerlessSpec region(String region) { + + this.region = region; + return this; + } + + /** + * The region where you would like your index to be created. Different cloud providers have different regions available. See AwsRegions and GcpRegions for a list of available options. + * @return region + **/ + @javax.annotation.Nonnull + public String getRegion() { + return region; + } + + + public void setRegion(String region) { + this.region = region; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServerlessSpec serverlessSpec = (ServerlessSpec) o; + return Objects.equals(this.cloud, serverlessSpec.cloud) && + Objects.equals(this.region, serverlessSpec.region); + } + + @Override + public int hashCode() { + return Objects.hash(cloud, region); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServerlessSpec {\n"); + sb.append(" cloud: ").append(toIndentedString(cloud)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).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(); + openapiFields.add("cloud"); + openapiFields.add("region"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("cloud"); + openapiRequiredFields.add("region"); + } + + /** + * 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 ServerlessSpec + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ServerlessSpec.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ServerlessSpec is not found in the empty JSON string", ServerlessSpec.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ServerlessSpec.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ServerlessSpec` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ServerlessSpec.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("cloud").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `cloud` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cloud").toString())); + } + if (!jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `region` to be a primitive type in the JSON string but got `%s`", jsonObj.get("region").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ServerlessSpec.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ServerlessSpec' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ServerlessSpec.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ServerlessSpec value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ServerlessSpec read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ServerlessSpec given an JSON string + * + * @param jsonString JSON string + * @return An instance of ServerlessSpec + * @throws IOException if the JSON string is invalid with respect to ServerlessSpec + */ + public static ServerlessSpec fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ServerlessSpec.class); + } + + /** + * Convert an instance of ServerlessSpec to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + From 563e9ba43a9b7157d857bf4399354bacf38828e0 Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Wed, 24 Jan 2024 11:41:55 -0500 Subject: [PATCH 2/5] clean up deps in build.gradle --- build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b11083a1..8524b8b8 100644 --- a/build.gradle +++ b/build.gradle @@ -47,9 +47,8 @@ dependencies { implementation 'org.slf4j:slf4j-api:2.0.5' implementation 'com.google.api.grpc:proto-google-common-protos:2.14.3' implementation 'com.squareup.okhttp3:okhttp:4.10.0' - // ToDo: Clean next two lines - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.2' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.14.2' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2' + implementation 'com.fasterxml.jackson.core:jackson-core:2.14.2' implementation 'com.google.code.gson:gson:2.9.1' implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' implementation 'io.gsonfire:gson-fire:1.8.5' From 51d2f7bd775bf1faa1d4227d635641dadc89c1ef Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Wed, 24 Jan 2024 13:53:19 -0500 Subject: [PATCH 3/5] rename directories and add clean to gradle build --- .github/workflows/pr.yml | 2 +- .../controlPlane/{Index => index}/ConfigureIndexTest.java | 2 +- .../{Index => index}/CreateListAndDeleteIndexTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/integration/java/io/pinecone/integration/controlPlane/{Index => index}/ConfigureIndexTest.java (99%) rename src/integration/java/io/pinecone/integration/controlPlane/{Index => index}/CreateListAndDeleteIndexTest.java (97%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 53b7531c..d92cbdeb 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,7 +39,7 @@ jobs: echo "org.gradle.jvmargs=-Xmx4096m --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED" >> gradle.properties - name: Execute Gradle build - run: gradle build + run: gradle clean build - name: Build jar run: gradle jar diff --git a/src/integration/java/io/pinecone/integration/controlPlane/Index/ConfigureIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/index/ConfigureIndexTest.java similarity index 99% rename from src/integration/java/io/pinecone/integration/controlPlane/Index/ConfigureIndexTest.java rename to src/integration/java/io/pinecone/integration/controlPlane/index/ConfigureIndexTest.java index 1b38e596..8d0895a4 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/Index/ConfigureIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/index/ConfigureIndexTest.java @@ -1,4 +1,4 @@ -package io.pinecone.integration.controlPlane.Index; +package io.pinecone.integration.controlPlane.index; import io.pinecone.PineconeClientConfig; import io.pinecone.integration.dataplane.PineconeClientLiveIntegTest; diff --git a/src/integration/java/io/pinecone/integration/controlPlane/Index/CreateListAndDeleteIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/index/CreateListAndDeleteIndexTest.java similarity index 97% rename from src/integration/java/io/pinecone/integration/controlPlane/Index/CreateListAndDeleteIndexTest.java rename to src/integration/java/io/pinecone/integration/controlPlane/index/CreateListAndDeleteIndexTest.java index 0c54adbf..8092b590 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/Index/CreateListAndDeleteIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/index/CreateListAndDeleteIndexTest.java @@ -1,4 +1,4 @@ -package io.pinecone.integration.controlPlane.Index; +package io.pinecone.integration.controlPlane.index; import io.pinecone.PineconeClientConfig; import io.pinecone.PineconeIndexOperationClient; From cd83c3a16e8e48e01390e9e1f94cb169cb66eca3 Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Fri, 26 Jan 2024 13:52:19 -0500 Subject: [PATCH 4/5] silent the doclint errors for now --- build.gradle | 1 + .../java/io/pinecone/PineconeCollectionOperationClient.java | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 src/main/java/io/pinecone/PineconeCollectionOperationClient.java diff --git a/build.gradle b/build.gradle index 8524b8b8..dd01b849 100644 --- a/build.gradle +++ b/build.gradle @@ -67,6 +67,7 @@ dependencies { javadoc { options.tags = [ "http.response.details:a:Http Response Details" ] + options.addStringOption('Xdoclint:none', '-quiet') } configurations { diff --git a/src/main/java/io/pinecone/PineconeCollectionOperationClient.java b/src/main/java/io/pinecone/PineconeCollectionOperationClient.java deleted file mode 100644 index a2dbd4a7..00000000 --- a/src/main/java/io/pinecone/PineconeCollectionOperationClient.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.pinecone; - -public class PineconeCollectionOperationClient { - // ToDo: add collection code here -} From 299de6a72eb92d13082930745e198db58ebb9e66 Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Mon, 29 Jan 2024 14:42:26 -0500 Subject: [PATCH 5/5] update gradle build to gradle clean build --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d92cbdeb..0533b18d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -76,7 +76,7 @@ jobs: echo "org.gradle.jvmargs=-Xmx4096m --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED" >> gradle.properties - name: Execute Gradle build - run: gradle build + run: gradle clean build - name: Run integration tests run: gradle integrationTest