From 2ce9ac56db86221bf7be455fffeda6a84fd67266 Mon Sep 17 00:00:00 2001 From: Rohan Shah Date: Wed, 17 Jul 2024 14:47:33 -0400 Subject: [PATCH] Add support for deletion protection (#141) ## Problem Add support for deletion protection. ## Solution Generated code using the following commands: ``` git submodule init && git submodule update ./codegen/build-oas.sh 2024-07 ``` Next, as a part of this PR, I have: 1. Added deletionProtection enum as an argument to createPodsIndex() and createServerlessIndex() 2. Renamed configureIndex() to configurePodsIndex() and added deletionProtection enum as an argument. 3. Added configureServerlessIndex() that accepts deletionProtection enum only. ## Type of Change - [X] New feature (non-breaking change which adds functionality) ## Test Plan Added integration tests --- codegen/apis | 2 +- .../helpers/TestResourcesManager.java | 2 +- .../controlPlane/pod/ConfigureIndexTest.java | 13 +- .../pod/DeletionProtectionTest.java | 48 ++++++ .../CreateDescribeListAndDeleteIndexTest.java | 8 +- .../serverless/DeletionProtectionTest.java | 45 +++++ .../java/io/pinecone/clients/Pinecone.java | 161 ++++++++++++++---- .../control/client/ApiException.java | 2 +- .../control/client/Configuration.java | 2 +- .../org/openapitools/control/client/JSON.java | 4 +- .../org/openapitools/control/client/Pair.java | 2 +- .../control/client/StringUtil.java | 2 +- .../control/client/api/InferenceApi.java | 2 +- .../control/client/api/ManageIndexesApi.java | 16 +- .../control/client/auth/ApiKeyAuth.java | 2 +- .../control/client/auth/HttpBearerAuth.java | 2 +- .../client/model/AbstractOpenApiSchema.java | 2 +- .../control/client/model/CollectionList.java | 2 +- .../control/client/model/CollectionModel.java | 2 +- .../client/model/ConfigureIndexRequest.java | 51 ++++-- .../model/ConfigureIndexRequestSpec.java | 2 +- .../model/ConfigureIndexRequestSpecPod.java | 2 +- .../client/model/CreateCollectionRequest.java | 2 +- .../client/model/CreateIndexRequest.java | 33 +++- .../client/model/DeletionProtection.java | 72 ++++++++ .../control/client/model/EmbedRequest.java | 2 +- .../client/model/EmbedRequestInputsInner.java | 2 +- .../client/model/EmbedRequestParameters.java | 2 +- .../control/client/model/Embedding.java | 2 +- .../control/client/model/EmbeddingsList.java | 2 +- .../client/model/EmbeddingsListUsage.java | 2 +- ...xes401Response.java => ErrorResponse.java} | 70 ++++---- ...onseError.java => ErrorResponseError.java} | 68 ++++---- .../control/client/model/IndexList.java | 2 +- .../control/client/model/IndexModel.java | 33 +++- .../control/client/model/IndexModelSpec.java | 2 +- .../client/model/IndexModelStatus.java | 2 +- .../control/client/model/IndexSpec.java | 4 +- .../control/client/model/PodSpec.java | 8 +- .../client/model/PodSpecMetadataConfig.java | 2 +- .../control/client/model/ServerlessSpec.java | 8 +- .../pinecone/PineconeIndexOperationsTest.java | 39 ++--- 42 files changed, 539 insertions(+), 192 deletions(-) create mode 100644 src/integration/java/io/pinecone/integration/controlPlane/pod/DeletionProtectionTest.java create mode 100644 src/integration/java/io/pinecone/integration/controlPlane/serverless/DeletionProtectionTest.java create mode 100644 src/main/java/org/openapitools/control/client/model/DeletionProtection.java rename src/main/java/org/openapitools/control/client/model/{ListIndexes401Response.java => ErrorResponse.java} (79%) rename src/main/java/org/openapitools/control/client/model/{ListIndexes401ResponseError.java => ErrorResponseError.java} (83%) diff --git a/codegen/apis b/codegen/apis index fbd9d8d4..3e5739b4 160000 --- a/codegen/apis +++ b/codegen/apis @@ -1 +1 @@ -Subproject commit fbd9d8d48c95b12c6b28aea4e496b6f28666d2d1 +Subproject commit 3e5739b49a9592a0a7da935e4247e377bd5d1e8a diff --git a/src/integration/java/io/pinecone/helpers/TestResourcesManager.java b/src/integration/java/io/pinecone/helpers/TestResourcesManager.java index 302b7ea9..5da24484 100644 --- a/src/integration/java/io/pinecone/helpers/TestResourcesManager.java +++ b/src/integration/java/io/pinecone/helpers/TestResourcesManager.java @@ -317,7 +317,7 @@ public String getOrCreateServerlessIndex() throws InterruptedException, Pinecone String indexName = RandomStringBuilder.build("serverless-index", 8); serverlessIndexModel = pineconeClient.createServerlessIndex(indexName, metric, dimension, cloud, - region); + region, DeletionProtection.DISABLED); waitUntilIndexIsReady(pineconeClient, indexName); // Explicitly wait after ready to avoid the "no healthy upstream" issue diff --git a/src/integration/java/io/pinecone/integration/controlPlane/pod/ConfigureIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/pod/ConfigureIndexTest.java index fedda54a..c709eb51 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/pod/ConfigureIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/pod/ConfigureIndexTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.openapitools.control.client.model.DeletionProtection; import org.openapitools.control.client.model.IndexModel; import org.openapitools.control.client.model.IndexModelStatus; import org.openapitools.control.client.model.PodSpec; @@ -55,7 +56,7 @@ public void afterEach() throws InterruptedException { @Test public void configureIndexWithInvalidIndexName() { try { - controlPlaneClient.configureIndex("non-existent-index", 3); + controlPlaneClient.configurePodsIndex("non-existent-index", 3, DeletionProtection.DISABLED); fail("Expected to throw PineconeNotFoundException"); } catch (PineconeNotFoundException expected) { @@ -66,7 +67,7 @@ public void configureIndexWithInvalidIndexName() { @Test public void configureIndexExceedingQuota() { try { - controlPlaneClient.configureIndex(indexName, 600); + controlPlaneClient.configurePodsIndex(indexName, 30, DeletionProtection.DISABLED); fail("Expected to throw PineconeForbiddenException"); } catch (PineconeForbiddenException expected) { assertTrue(expected.getLocalizedMessage().contains("reached the max pods allowed")); @@ -81,7 +82,7 @@ public void scaleUpAndDown() throws InterruptedException { // Verify the scaled up replicas assertWithRetry(() -> { - controlPlaneClient.configureIndex(indexName, 3); + controlPlaneClient.configurePodsIndex(indexName, 3, DeletionProtection.DISABLED); PodSpec podSpec = controlPlaneClient.describeIndex(indexName).getSpec().getPod(); assertNotNull(podSpec); assertEquals(podSpec.getReplicas(), 3); @@ -91,7 +92,7 @@ public void scaleUpAndDown() throws InterruptedException { // Verify replicas were scaled down assertWithRetry(() -> { - controlPlaneClient.configureIndex(indexName, 1); + controlPlaneClient.configurePodsIndex(indexName, 1, DeletionProtection.DISABLED); PodSpec podSpec = controlPlaneClient.describeIndex(indexName).getSpec().getPod(); assertNotNull(podSpec); assertEquals(podSpec.getReplicas(), 1); @@ -107,7 +108,7 @@ public void changingBasePodType() throws InterruptedException { assertEquals(1, indexModel.getSpec().getPod().getReplicas()); // Try to change the base pod type - controlPlaneClient.configureIndex(indexName, "p2.x2"); + controlPlaneClient.configurePodsIndex(indexName, "p2.x2"); fail("Expected to throw PineconeBadRequestException"); } catch (PineconeBadRequestException expected) { @@ -125,7 +126,7 @@ public void sizeIncrease() throws InterruptedException { // Change the pod type to a larger one // Get the index description to verify the new pod type assertWithRetry(() -> { - controlPlaneClient.configureIndex(indexName, "p1.x2"); + controlPlaneClient.configurePodsIndex(indexName, "p1.x2"); PodSpec podSpec = controlPlaneClient.describeIndex(indexName).getSpec().getPod(); assertNotNull(podSpec); assertEquals(podSpec.getPodType(), "p1.x2"); diff --git a/src/integration/java/io/pinecone/integration/controlPlane/pod/DeletionProtectionTest.java b/src/integration/java/io/pinecone/integration/controlPlane/pod/DeletionProtectionTest.java new file mode 100644 index 00000000..d084856a --- /dev/null +++ b/src/integration/java/io/pinecone/integration/controlPlane/pod/DeletionProtectionTest.java @@ -0,0 +1,48 @@ +package io.pinecone.integration.controlPlane.pod; + +import io.pinecone.clients.Pinecone; +import io.pinecone.helpers.RandomStringBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.openapitools.control.client.model.DeletionProtection; +import org.openapitools.control.client.model.IndexModel; + +public class DeletionProtectionTest { + private static final Pinecone controlPlaneClient = new Pinecone + .Builder(System.getenv("PINECONE_API_KEY")) + .withSourceTag("pinecone_test") + .build(); + + @Test + public void createPodIndexWithDeletionProtectionEnabled() { + String indexName = RandomStringBuilder.build("create-pod", 8); + // Create pod index with deletion protection enabled + controlPlaneClient.createPodsIndex(indexName, 3, "us-east-1-aws", "p1.x1", DeletionProtection.ENABLED); + IndexModel indexModel = controlPlaneClient.describeIndex(indexName); + DeletionProtection deletionProtection = indexModel.getDeletionProtection(); + Assertions.assertEquals(deletionProtection, DeletionProtection.ENABLED); + // Configure index to disable deletionProtection + controlPlaneClient.configurePodsIndex(indexName, DeletionProtection.DISABLED); + // Delete index + controlPlaneClient.deleteIndex(indexName); + } + + @Test + public void createPodIndexWithDeletionProtectionDisabled() { + String indexName = RandomStringBuilder.build("create-pod", 8); + // Create pod index with deletion protection disabled + controlPlaneClient.createPodsIndex(indexName, 3, "us-east-1-aws", "p1.x1"); + IndexModel indexModel = controlPlaneClient.describeIndex(indexName); + DeletionProtection deletionProtection = indexModel.getDeletionProtection(); + Assertions.assertEquals(deletionProtection, DeletionProtection.DISABLED); + // Configure index to enable deletionProtection + controlPlaneClient.configurePodsIndex(indexName, DeletionProtection.ENABLED); + indexModel = controlPlaneClient.describeIndex(indexName); + deletionProtection = indexModel.getDeletionProtection(); + Assertions.assertEquals(deletionProtection, DeletionProtection.ENABLED); + // Configure index to disable deletionProtection + controlPlaneClient.configurePodsIndex(indexName, DeletionProtection.DISABLED); + // Delete index + controlPlaneClient.deleteIndex(indexName); + } +} diff --git a/src/integration/java/io/pinecone/integration/controlPlane/serverless/CreateDescribeListAndDeleteIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/serverless/CreateDescribeListAndDeleteIndexTest.java index 077908ff..a8feea06 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/serverless/CreateDescribeListAndDeleteIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/serverless/CreateDescribeListAndDeleteIndexTest.java @@ -48,7 +48,7 @@ public void describeAndListIndex() { @Test public void createServerlessIndexWithInvalidName() { try { - controlPlaneClient.createServerlessIndex("Invalid-name", "cosine", 3, "aws", "us-west-2"); + controlPlaneClient.createServerlessIndex("Invalid-name", "cosine", 3, "aws", "us-west-2", DeletionProtection.DISABLED); fail("Expected to throw PineconeBadRequestException"); } catch (PineconeBadRequestException expected) { @@ -59,7 +59,7 @@ public void createServerlessIndexWithInvalidName() { @Test public void createServerlessIndexWithInvalidDimension() { try { - controlPlaneClient.createServerlessIndex("serverless-test-index", "cosine", -3, "aws", "us-west-2"); + controlPlaneClient.createServerlessIndex("serverless-test-index", "cosine", -3, "aws", "us-west-2", DeletionProtection.DISABLED); fail("Expected to throw PineconeValidationException"); } catch (PineconeValidationException expected) { assertTrue(expected.getLocalizedMessage().contains("Dimension must be greater than 0")); @@ -69,7 +69,7 @@ public void createServerlessIndexWithInvalidDimension() { @Test public void createServerlessIndexWithInvalidCloud() { try { - controlPlaneClient.createServerlessIndex("serverless-test-index", "cosine", 3, "blah", "us-west-2"); + controlPlaneClient.createServerlessIndex("serverless-test-index", "cosine", 3, "blah", "us-west-2", DeletionProtection.DISABLED); fail("Expected to throw PineconeValidationException"); } catch (PineconeValidationException expected) { assertTrue(expected.getLocalizedMessage().contains("Cloud cannot be null or empty. Must be one of " + Arrays.toString(ServerlessSpec.CloudEnum.values()))); @@ -79,7 +79,7 @@ public void createServerlessIndexWithInvalidCloud() { @Test public void createServerlessIndexWithInvalidRegion() { try { - controlPlaneClient.createServerlessIndex("serverless-test-index", "cosine", 3, "aws", "invalid-region"); + controlPlaneClient.createServerlessIndex("serverless-test-index", "cosine", 3, "aws", "invalid-region", DeletionProtection.DISABLED); fail("Expected to throw PineconeNotFoundException"); } catch (PineconeNotFoundException expected) { assertTrue(expected.getLocalizedMessage().contains("Resource cloud: aws region: invalid-region not found")); diff --git a/src/integration/java/io/pinecone/integration/controlPlane/serverless/DeletionProtectionTest.java b/src/integration/java/io/pinecone/integration/controlPlane/serverless/DeletionProtectionTest.java new file mode 100644 index 00000000..94cd805e --- /dev/null +++ b/src/integration/java/io/pinecone/integration/controlPlane/serverless/DeletionProtectionTest.java @@ -0,0 +1,45 @@ +package io.pinecone.integration.controlPlane.serverless; + +import io.pinecone.clients.Pinecone; +import io.pinecone.helpers.RandomStringBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.openapitools.control.client.model.DeletionProtection; +import org.openapitools.control.client.model.IndexModel; + +public class DeletionProtectionTest { + private static final Pinecone controlPlaneClient = new Pinecone + .Builder(System.getenv("PINECONE_API_KEY")) + .withSourceTag("pinecone_test") + .build(); + + @Test + public void createIndexWithDeletionProtectionEnabled() { + String indexName = RandomStringBuilder.build("create-serv", 8); + // Create serverless index with deletion protection enabled + controlPlaneClient.createServerlessIndex(indexName, "cosine", 3, "aws", "us-west-2", DeletionProtection.ENABLED); + // Describe index to verify deletion protection is enabled + IndexModel indexModel = controlPlaneClient.describeIndex(indexName); + DeletionProtection deletionProtection = indexModel.getDeletionProtection(); + Assertions.assertEquals(deletionProtection, DeletionProtection.ENABLED); + } + + @Test + public void createPodIndexWithDeletionProtectionDisabled() { + String indexName = RandomStringBuilder.build("create-pod", 8); + // Create serverless index with deletion protection disabled + controlPlaneClient.createServerlessIndex(indexName, "cosine", 3, "aws", "us-west-2", DeletionProtection.DISABLED); + IndexModel indexModel = controlPlaneClient.describeIndex(indexName); + DeletionProtection deletionProtection = indexModel.getDeletionProtection(); + Assertions.assertEquals(deletionProtection, DeletionProtection.DISABLED); + // Configure index to enable deletionProtection + controlPlaneClient.configureServerlessIndex(indexName, DeletionProtection.ENABLED); + indexModel = controlPlaneClient.describeIndex(indexName); + deletionProtection = indexModel.getDeletionProtection(); + Assertions.assertEquals(deletionProtection, DeletionProtection.ENABLED); + // Configure index to disable deletionProtection + controlPlaneClient.configureServerlessIndex(indexName, DeletionProtection.DISABLED); + // Delete index + controlPlaneClient.deleteIndex(indexName); + } +} diff --git a/src/main/java/io/pinecone/clients/Pinecone.java b/src/main/java/io/pinecone/clients/Pinecone.java index cd77cbdc..3523383a 100644 --- a/src/main/java/io/pinecone/clients/Pinecone.java +++ b/src/main/java/io/pinecone/clients/Pinecone.java @@ -56,7 +56,7 @@ PineconeConfig getConfig() { *

* Example: *

{@code 
-     *     client.createServerlessIndex("YOUR-INDEX", "cosine", 1536, "aws", "us-west-2");
+     *     client.createServerlessIndex("YOUR-INDEX", "cosine", 1536, "aws", "us-west-2", DeletionProtection.ENABLED);
      * }
* * @param indexName The name of the index to be created. @@ -64,11 +64,16 @@ PineconeConfig getConfig() { * @param dimension The number of dimensions for the index. * @param cloud The cloud provider for the index. * @param region The cloud region for the index. + * @param deletionProtection Enable or disable deletion protection for the index. * @return {@link IndexModel} representing the created serverless index. * @throws PineconeException if the API encounters an error during index creation or if any of the arguments are invalid. */ - public IndexModel createServerlessIndex(String indexName, String metric, int dimension, String cloud, - String region) throws PineconeException { + public IndexModel createServerlessIndex(String indexName, + String metric, + int dimension, + String cloud, + String region, + DeletionProtection deletionProtection) throws PineconeException { if (indexName == null || indexName.isEmpty()) { throw new PineconeValidationException("Index name cannot be null or empty"); } @@ -115,7 +120,8 @@ public IndexModel createServerlessIndex(String indexName, String metric, int dim .name(indexName) .metric(userMetric) .dimension(dimension) - .spec(createServerlessIndexRequestSpec)); + .spec(createServerlessIndexRequestSpec) + .deletionProtection(deletionProtection)); } catch (ApiException apiException) { handleApiException(apiException); } @@ -138,7 +144,33 @@ public IndexModel createServerlessIndex(String indexName, String metric, int dim * @throws PineconeException if the API encounters an error during index creation or if any of the arguments are invalid. */ public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType) { - return createPodsIndex(indexName, dimension, environment, podType, null, null, null, null, null, null); + return createPodsIndex(indexName, dimension, environment, podType, null, null, null, + null, null, null, DeletionProtection.DISABLED); + } + + /** + * Overload for creating a new pods index with environment, podType, and deletion protection. + *

+ * Example: + *

{@code
+     *     client.createPodsIndex("YOUR-INDEX", 1536, "us-east4-gcp", "p1.x2", DeletionProtection.ENABLED);
+     * }
+ * + * @param indexName The name of the index to be created. + * @param dimension The number of dimensions for the index. + * @param environment The cloud environment where you want the index to be hosted. + * @param podType The type of pod to use. A string with one of s1, p1, or p2 appended with a "." and one of x1, x2, x4, or x8. + * @param deletionProtection Enable or disable deletion protection for the index. + * @return {@link IndexModel} representing the created serverless index. + * @throws PineconeException if the API encounters an error during index creation or if any of the arguments are invalid. + */ + public IndexModel createPodsIndex(String indexName, + Integer dimension, + String environment, + String podType, + DeletionProtection deletionProtection) { + return createPodsIndex(indexName, dimension, environment, podType, null, null, null, + null, null, null, deletionProtection); } /** @@ -159,7 +191,8 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en */ public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, String metric) { - return createPodsIndex(indexName, dimension, environment, podType, metric, null, null, null, null, null); + return createPodsIndex(indexName, dimension, environment, podType, metric, null, null, + null, null, null, DeletionProtection.DISABLED); } /** @@ -189,8 +222,8 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en */ public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, String metric, PodSpecMetadataConfig metadataConfig) { - return createPodsIndex(indexName, dimension, environment, podType, metric, null, null, null, metadataConfig, - null); + return createPodsIndex(indexName, dimension, environment, podType, metric, null, null, null, + metadataConfig,null, DeletionProtection.DISABLED); } /** @@ -213,7 +246,7 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, String metric, String sourceCollection) { return createPodsIndex(indexName, dimension, environment, podType, metric, null, null, null, null, - sourceCollection); + sourceCollection, DeletionProtection.DISABLED); } /** @@ -234,7 +267,8 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en */ public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, Integer pods) { - return createPodsIndex(indexName, dimension, environment, podType, null, null, null, pods, null, null); + return createPodsIndex(indexName, dimension, environment, podType, null, null, null, pods, + null, null, DeletionProtection.DISABLED); } /** @@ -263,7 +297,7 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en String podType, Integer pods, PodSpecMetadataConfig metadataConfig) { return createPodsIndex(indexName, dimension, environment, podType, null, null, null, pods, metadataConfig, - null); + null, DeletionProtection.DISABLED); } /** @@ -286,7 +320,8 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, Integer replicas, Integer shards) { - return createPodsIndex(indexName, dimension, environment, podType, null, replicas, shards, null, null, null); + return createPodsIndex(indexName, dimension, environment, podType, null, replicas, shards, null, + null, null, DeletionProtection.DISABLED); } /** @@ -315,9 +350,10 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, Integer replicas, Integer shards, PodSpecMetadataConfig metadataConfig) { - return createPodsIndex(indexName, dimension, environment, podType, null, replicas, shards, null, - metadataConfig, - null); + return createPodsIndex(indexName, dimension, environment, + podType, null, replicas, + shards, null, metadataConfig, + null, DeletionProtection.DISABLED); } /** @@ -331,7 +367,7 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en * PodSpecMetadataConfig metadataConfig = * new PodSpecMetadataConfig() * .fields(Arrays.asList("genre", "year")); - * client.createPodsIndex("YOUR-INDEX", 1536, "us-east4-gcp", "p1.x2", "cosine", 2, 2, 4, null, null); + * client.createPodsIndex("YOUR-INDEX", 1536, "us-east4-gcp", "p1.x2", "cosine", 2, 2, 4, null, null, DeletionProtection.DISABLED); * } * * @param indexName The name of the index to be created. @@ -345,13 +381,15 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en * @param metadataConfig The configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; * when metadataConfig is present, only specified metadata fields are indexed. * @param sourceCollection The name of the collection to be used as the source for the index. Collections are snapshots of an index at a point in time. + * @param deletionProtection Enable or disable deletion protection for the index. * @return {@link IndexModel} representing the created serverless index. * @throws PineconeException if the API encounters an error during index creation or if any of the arguments are invalid. */ public IndexModel createPodsIndex(String indexName, Integer dimension, String environment, String podType, String metric, Integer replicas, Integer shards, Integer pods, - PodSpecMetadataConfig metadataConfig, String sourceCollection) throws PineconeException { + PodSpecMetadataConfig metadataConfig, String sourceCollection, + DeletionProtection deletionProtection) throws PineconeException { validatePodIndexParams(indexName, dimension, environment, podType, metric, replicas, shards, pods); PodSpec podSpec = new PodSpec().environment(environment) @@ -366,7 +404,8 @@ public IndexModel createPodsIndex(String indexName, Integer dimension, String en .name(indexName) .dimension(dimension) .metric(metric != null ? CreateIndexRequest.MetricEnum.fromValue(metric) : CreateIndexRequest.MetricEnum.COSINE) - .spec(createIndexRequestSpec); + .spec(createIndexRequestSpec) + .deletionProtection(deletionProtection); IndexModel indexModel = null; try { @@ -457,7 +496,7 @@ public IndexModel describeIndex(String indexName) throws PineconeException { * ... * * // Make a configuration change - * IndexModel indexModel = client.configureIndex("YOUR-INDEX", "p1.x2", 4); + * IndexModel indexModel = client.configurePodsIndex("YOUR-INDEX", "p1.x2", 4, DeletionProtection.ENABLED); * * // Call describeIndex to see the index status as the change is applied. * indexModel = client.describeIndex("YOUR-INDEX"); @@ -466,18 +505,15 @@ public IndexModel describeIndex(String indexName) throws PineconeException { * @param indexName The name of the index to configure. * @param podType The new podType for the index. Can be null if not changing the pod type. * @param replicas The desired number of replicas for the index, lowest value is 0. Can be null if not changing the number of replicas. + * @param deletionProtection Enable or disable deletion protection for the index. * @return {@link IndexModel} representing the configured index. * @throws PineconeException if an error occurs during the operation, the index does not exist, or if any of the arguments are invalid. */ - public IndexModel configureIndex(String indexName, String podType, Integer replicas) throws PineconeException { + public IndexModel configurePodsIndex(String indexName, String podType, Integer replicas, DeletionProtection deletionProtection) throws PineconeException { if (indexName == null || indexName.isEmpty()) { throw new PineconeValidationException("indexName cannot be null or empty"); } - if (podType == null && replicas == null) { - throw new PineconeValidationException("Must provide either podType or replicas"); - } - // If you pass a # replicas, but they're < 1, throw an exception if (replicas != null) { if (replicas < 1) { @@ -492,7 +528,7 @@ public IndexModel configureIndex(String indexName, String podType, Integer repli .replicas(replicas) .podType(podType) ) - ); + ).deletionProtection(deletionProtection); IndexModel indexModel = null; try { @@ -504,34 +540,35 @@ public IndexModel configureIndex(String indexName, String podType, Integer repli } /** - * Overload for configureIndex to only change the number of replicas for an index. + * Overload for configurePodsIndex to change the number of replicas and deletion protection for an index. *

* Example: *

{@code 
      *     import org.openapitools.control.client.model.IndexModel;
      *     ...
      *
-     *     IndexModel indexModel = client.configureIndex("YOUR-INDEX", 4);
+     *     IndexModel indexModel = client.configurePodsIndex("YOUR-INDEX", 4, DeletionProtection.ENABLED);
      * }
* * @param indexName The name of the index. * @param replicas The desired number of replicas for the index, lowest value is 0. + * @param deletionProtection Enable or disable deletion protection for the index. * @return {@link IndexModel} of the configured index. * @throws PineconeException if an error occurs during the operation, the index does not exist, or if the number of replicas is invalid. */ - public IndexModel configureIndex(String indexName, Integer replicas) throws PineconeException { - return configureIndex(indexName, null, replicas); + public IndexModel configurePodsIndex(String indexName, Integer replicas, DeletionProtection deletionProtection) throws PineconeException { + return configurePodsIndex(indexName, null, replicas, deletionProtection); } /** - * Overload for configureIndex to only change the podType of an index. + * Overload for configurePodsIndex to only change the podType of an index. *

* Example: *

{@code 
      *     import org.openapitools.control.client.model.IndexModel;
      *     ...
      *
-     *     IndexModel indexModel = client.configureIndex("YOUR-INDEX", "p1.x2");
+     *     IndexModel indexModel = client.configurePodsIndex("YOUR-INDEX", "p1.x2");
      * }
* * @param indexName The name of the index. @@ -539,8 +576,66 @@ public IndexModel configureIndex(String indexName, Integer replicas) throws Pine * @return {@link IndexModel} of the configured index. * @throws PineconeException if an error occurs during the operation, the index does not exist, or if the podType is invalid. */ - public IndexModel configureIndex(String indexName, String podType) throws PineconeException { - return configureIndex(indexName, podType, null); + public IndexModel configurePodsIndex(String indexName, String podType) throws PineconeException { + DeletionProtection deletionProtection = describeIndex(indexName).getDeletionProtection(); + return configurePodsIndex(indexName, podType, null, deletionProtection); + } + + /** + * Overload for configurePodsIndex to only change the deletion protection of an index. + *

+ * Example: + *

{@code
+     *     import org.openapitools.control.client.model.IndexModel;
+     *     ...
+     *
+     *     IndexModel indexModel = client.configurePodsIndex("YOUR-INDEX", DeletionProtection.ENABLED);
+     * }
+ * + * @param indexName The name of the index. + * @param deletionProtection Enable or disable deletion protection for the index. + * @return {@link IndexModel} of the configured index. + * @throws PineconeException if an error occurs during the operation, the index does not exist, or if the podType is invalid. + */ + public IndexModel configurePodsIndex(String indexName, DeletionProtection deletionProtection) throws PineconeException { + return configurePodsIndex(indexName, null, null, deletionProtection); + } + + /** + * Configures an existing serverless index with deletion protection. + *

+ * Example: + *

{@code
+     *     import org.openapitools.control.client.model.IndexModel;
+     *     ...
+     *
+     *     // Make a configuration change
+     *     IndexModel indexModel = client.configureServerlessIndex("YOUR-INDEX", DeletionProtection.ENABLED);
+     *
+     *     // Call describeIndex to see the index status as the change is applied.
+     *     indexModel = client.describeIndex("YOUR-INDEX");
+     * }
+ * + * @param indexName The name of the index to configure. + * @param deletionProtection Enable or disable deletion protection for the index. + * @return {@link IndexModel} representing the configured index. + * @throws PineconeException if an error occurs during the operation, the index does not exist, or if any of the arguments are invalid. + */ + public IndexModel configureServerlessIndex(String indexName, DeletionProtection deletionProtection) throws PineconeException { + if (indexName == null || indexName.isEmpty()) { + throw new PineconeValidationException("indexName cannot be null or empty"); + } + + // Build ConfigureIndexRequest object + ConfigureIndexRequest configureIndexRequest = new ConfigureIndexRequest().deletionProtection(deletionProtection); + + IndexModel indexModel = null; + try { + indexModel = manageIndexesApi.configureIndex(indexName, configureIndexRequest); + } catch (ApiException apiException) { + handleApiException(apiException); + } + return indexModel; } /** diff --git a/src/main/java/org/openapitools/control/client/ApiException.java b/src/main/java/org/openapitools/control/client/ApiException.java index 5a57cb1e..d5d59025 100644 --- a/src/main/java/org/openapitools/control/client/ApiException.java +++ b/src/main/java/org/openapitools/control/client/ApiException.java @@ -21,7 +21,7 @@ *

ApiException class.

*/ @SuppressWarnings("serial") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/src/main/java/org/openapitools/control/client/Configuration.java b/src/main/java/org/openapitools/control/client/Configuration.java index 328c1fe2..fa487481 100644 --- a/src/main/java/org/openapitools/control/client/Configuration.java +++ b/src/main/java/org/openapitools/control/client/Configuration.java @@ -13,7 +13,7 @@ package org.openapitools.control.client; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class Configuration { public static final String VERSION = "2024-07"; diff --git a/src/main/java/org/openapitools/control/client/JSON.java b/src/main/java/org/openapitools/control/client/JSON.java index ab4aff2b..63391d2a 100644 --- a/src/main/java/org/openapitools/control/client/JSON.java +++ b/src/main/java/org/openapitools/control/client/JSON.java @@ -106,13 +106,13 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.Embedding.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.EmbeddingsList.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.EmbeddingsListUsage.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.ErrorResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.ErrorResponseError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.IndexList.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.IndexModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.IndexModelSpec.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.IndexModelStatus.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.IndexSpec.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.ListIndexes401Response.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.ListIndexes401ResponseError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.PodSpec.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.PodSpecMetadataConfig.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.control.client.model.ServerlessSpec.CustomTypeAdapterFactory()); diff --git a/src/main/java/org/openapitools/control/client/Pair.java b/src/main/java/org/openapitools/control/client/Pair.java index c9e0c9cf..74a4e948 100644 --- a/src/main/java/org/openapitools/control/client/Pair.java +++ b/src/main/java/org/openapitools/control/client/Pair.java @@ -13,7 +13,7 @@ package org.openapitools.control.client; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class Pair { private String name = ""; private String value = ""; diff --git a/src/main/java/org/openapitools/control/client/StringUtil.java b/src/main/java/org/openapitools/control/client/StringUtil.java index 742ac477..dc56e8ec 100644 --- a/src/main/java/org/openapitools/control/client/StringUtil.java +++ b/src/main/java/org/openapitools/control/client/StringUtil.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.Iterator; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/src/main/java/org/openapitools/control/client/api/InferenceApi.java b/src/main/java/org/openapitools/control/client/api/InferenceApi.java index 3a644ae3..c9726176 100644 --- a/src/main/java/org/openapitools/control/client/api/InferenceApi.java +++ b/src/main/java/org/openapitools/control/client/api/InferenceApi.java @@ -29,7 +29,7 @@ import org.openapitools.control.client.model.EmbedRequest; import org.openapitools.control.client.model.EmbeddingsList; -import org.openapitools.control.client.model.ListIndexes401Response; +import org.openapitools.control.client.model.ErrorResponse; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/org/openapitools/control/client/api/ManageIndexesApi.java b/src/main/java/org/openapitools/control/client/api/ManageIndexesApi.java index c9e08537..f6aaccbb 100644 --- a/src/main/java/org/openapitools/control/client/api/ManageIndexesApi.java +++ b/src/main/java/org/openapitools/control/client/api/ManageIndexesApi.java @@ -32,9 +32,9 @@ import org.openapitools.control.client.model.ConfigureIndexRequest; import org.openapitools.control.client.model.CreateCollectionRequest; import org.openapitools.control.client.model.CreateIndexRequest; +import org.openapitools.control.client.model.ErrorResponse; import org.openapitools.control.client.model.IndexList; import org.openapitools.control.client.model.IndexModel; -import org.openapitools.control.client.model.ListIndexes401Response; import java.lang.reflect.Type; import java.util.ArrayList; @@ -82,7 +82,7 @@ public void setCustomBaseUrl(String 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 configureIndexRequest The desired pod size 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 @@ -162,9 +162,9 @@ private okhttp3.Call configureIndexValidateBeforeCall(String indexName, Configur /** * Configure an index - * This operation specifies the pod type and number of replicas for an index. It applies to pod-based indexes only. Serverless indexes scale automatically based on usage. + * This operation configures the pod size and number of replicas for a pod-based index. It is not possible to change the pod type of an index. However, you can create a collection from an index and then [create a new index with a different pod type](http://docs.pinecone.io/guides/indexes/create-an-index#create-an-index-from-a-collection) from the collection. * @param indexName The name of the index to configure. (required) - * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @param configureIndexRequest The desired pod size 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 @@ -186,9 +186,9 @@ public IndexModel configureIndex(String indexName, ConfigureIndexRequest configu /** * Configure an index - * This operation specifies the pod type and number of replicas for an index. It applies to pod-based indexes only. Serverless indexes scale automatically based on usage. + * This operation configures the pod size and number of replicas for a pod-based index. It is not possible to change the pod type of an index. However, you can create a collection from an index and then [create a new index with a different pod type](http://docs.pinecone.io/guides/indexes/create-an-index#create-an-index-from-a-collection) from the collection. * @param indexName The name of the index to configure. (required) - * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @param configureIndexRequest The desired pod size 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 @@ -211,9 +211,9 @@ public ApiResponse configureIndexWithHttpInfo(String indexName, Conf /** * Configure an index (asynchronously) - * This operation specifies the pod type and number of replicas for an index. It applies to pod-based indexes only. Serverless indexes scale automatically based on usage. + * This operation configures the pod size and number of replicas for a pod-based index. It is not possible to change the pod type of an index. However, you can create a collection from an index and then [create a new index with a different pod type](http://docs.pinecone.io/guides/indexes/create-an-index#create-an-index-from-a-collection) from the collection. * @param indexName The name of the index to configure. (required) - * @param configureIndexRequest The desired pod type and replica configuration for the index. (required) + * @param configureIndexRequest The desired pod size 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 diff --git a/src/main/java/org/openapitools/control/client/auth/ApiKeyAuth.java b/src/main/java/org/openapitools/control/client/auth/ApiKeyAuth.java index f20d34fb..6b0a704e 100644 --- a/src/main/java/org/openapitools/control/client/auth/ApiKeyAuth.java +++ b/src/main/java/org/openapitools/control/client/auth/ApiKeyAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/src/main/java/org/openapitools/control/client/auth/HttpBearerAuth.java b/src/main/java/org/openapitools/control/client/auth/HttpBearerAuth.java index c14709a6..b5cdf1a1 100644 --- a/src/main/java/org/openapitools/control/client/auth/HttpBearerAuth.java +++ b/src/main/java/org/openapitools/control/client/auth/HttpBearerAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class HttpBearerAuth implements Authentication { private final String scheme; private String bearerToken; diff --git a/src/main/java/org/openapitools/control/client/model/AbstractOpenApiSchema.java b/src/main/java/org/openapitools/control/client/model/AbstractOpenApiSchema.java index a10e5ae0..56928d9a 100644 --- a/src/main/java/org/openapitools/control/client/model/AbstractOpenApiSchema.java +++ b/src/main/java/org/openapitools/control/client/model/AbstractOpenApiSchema.java @@ -23,7 +23,7 @@ /** * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public abstract class AbstractOpenApiSchema { // store the actual instance of the schema/object diff --git a/src/main/java/org/openapitools/control/client/model/CollectionList.java b/src/main/java/org/openapitools/control/client/model/CollectionList.java index 79cf4c96..f2d253ad 100644 --- a/src/main/java/org/openapitools/control/client/model/CollectionList.java +++ b/src/main/java/org/openapitools/control/client/model/CollectionList.java @@ -52,7 +52,7 @@ /** * The list of collections that exist in the project. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class CollectionList { public static final String SERIALIZED_NAME_COLLECTIONS = "collections"; @SerializedName(SERIALIZED_NAME_COLLECTIONS) diff --git a/src/main/java/org/openapitools/control/client/model/CollectionModel.java b/src/main/java/org/openapitools/control/client/model/CollectionModel.java index 8c48e9ce..728dd8e5 100644 --- a/src/main/java/org/openapitools/control/client/model/CollectionModel.java +++ b/src/main/java/org/openapitools/control/client/model/CollectionModel.java @@ -49,7 +49,7 @@ /** * The CollectionModel describes the configuration and status of a Pinecone collection. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class CollectionModel { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) diff --git a/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequest.java b/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequest.java index 24a20198..756530e7 100644 --- a/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequest.java +++ b/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequest.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Arrays; import org.openapitools.control.client.model.ConfigureIndexRequestSpec; +import org.openapitools.control.client.model.DeletionProtection; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -50,12 +51,16 @@ /** * Configuration used to scale an index. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class ConfigureIndexRequest { public static final String SERIALIZED_NAME_SPEC = "spec"; @SerializedName(SERIALIZED_NAME_SPEC) private ConfigureIndexRequestSpec spec; + public static final String SERIALIZED_NAME_DELETION_PROTECTION = "deletion_protection"; + @SerializedName(SERIALIZED_NAME_DELETION_PROTECTION) + private DeletionProtection deletionProtection = DeletionProtection.DISABLED; + public ConfigureIndexRequest() { } @@ -69,7 +74,7 @@ public ConfigureIndexRequest spec(ConfigureIndexRequestSpec spec) { * Get spec * @return spec **/ - @javax.annotation.Nonnull + @javax.annotation.Nullable public ConfigureIndexRequestSpec getSpec() { return spec; } @@ -79,6 +84,27 @@ public void setSpec(ConfigureIndexRequestSpec spec) { this.spec = spec; } + + public ConfigureIndexRequest deletionProtection(DeletionProtection deletionProtection) { + + this.deletionProtection = deletionProtection; + return this; + } + + /** + * Get deletionProtection + * @return deletionProtection + **/ + @javax.annotation.Nullable + public DeletionProtection getDeletionProtection() { + return deletionProtection; + } + + + public void setDeletionProtection(DeletionProtection deletionProtection) { + this.deletionProtection = deletionProtection; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -134,13 +160,14 @@ public boolean equals(Object o) { return false; } ConfigureIndexRequest configureIndexRequest = (ConfigureIndexRequest) o; - return Objects.equals(this.spec, configureIndexRequest.spec)&& + return Objects.equals(this.spec, configureIndexRequest.spec) && + Objects.equals(this.deletionProtection, configureIndexRequest.deletionProtection)&& Objects.equals(this.additionalProperties, configureIndexRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(spec, additionalProperties); + return Objects.hash(spec, deletionProtection, additionalProperties); } @Override @@ -148,6 +175,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ConfigureIndexRequest {\n"); sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); + sb.append(" deletionProtection: ").append(toIndentedString(deletionProtection)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -172,10 +200,10 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("spec"); + openapiFields.add("deletion_protection"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("spec"); } /** @@ -190,16 +218,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format("The required field(s) %s in ConfigureIndexRequest is not found in the empty JSON string", ConfigureIndexRequest.openapiRequiredFields.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")); + // validate the optional field `spec` + if (jsonObj.get("spec") != null && !jsonObj.get("spec").isJsonNull()) { + ConfigureIndexRequestSpec.validateJsonElement(jsonObj.get("spec")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpec.java b/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpec.java index 32642d6a..19c58340 100644 --- a/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpec.java +++ b/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpec.java @@ -50,7 +50,7 @@ /** * ConfigureIndexRequestSpec */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class ConfigureIndexRequestSpec { public static final String SERIALIZED_NAME_POD = "pod"; @SerializedName(SERIALIZED_NAME_POD) diff --git a/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpecPod.java b/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpecPod.java index 4104ba6b..125b568f 100644 --- a/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpecPod.java +++ b/src/main/java/org/openapitools/control/client/model/ConfigureIndexRequestSpecPod.java @@ -49,7 +49,7 @@ /** * ConfigureIndexRequestSpecPod */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class ConfigureIndexRequestSpecPod { public static final String SERIALIZED_NAME_REPLICAS = "replicas"; @SerializedName(SERIALIZED_NAME_REPLICAS) diff --git a/src/main/java/org/openapitools/control/client/model/CreateCollectionRequest.java b/src/main/java/org/openapitools/control/client/model/CreateCollectionRequest.java index 222d966d..b2f2a57f 100644 --- a/src/main/java/org/openapitools/control/client/model/CreateCollectionRequest.java +++ b/src/main/java/org/openapitools/control/client/model/CreateCollectionRequest.java @@ -49,7 +49,7 @@ /** * The configuration needed to create a Pinecone collection. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class CreateCollectionRequest { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) diff --git a/src/main/java/org/openapitools/control/client/model/CreateIndexRequest.java b/src/main/java/org/openapitools/control/client/model/CreateIndexRequest.java index 5330896b..1c35f841 100644 --- a/src/main/java/org/openapitools/control/client/model/CreateIndexRequest.java +++ b/src/main/java/org/openapitools/control/client/model/CreateIndexRequest.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.control.client.model.DeletionProtection; import org.openapitools.control.client.model.IndexSpec; import com.google.gson.Gson; @@ -50,7 +51,7 @@ /** * The configuration needed to create a Pinecone index. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class CreateIndexRequest { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) @@ -113,6 +114,10 @@ public MetricEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_METRIC) private MetricEnum metric = MetricEnum.COSINE; + public static final String SERIALIZED_NAME_DELETION_PROTECTION = "deletion_protection"; + @SerializedName(SERIALIZED_NAME_DELETION_PROTECTION) + private DeletionProtection deletionProtection = DeletionProtection.DISABLED; + public static final String SERIALIZED_NAME_SPEC = "spec"; @SerializedName(SERIALIZED_NAME_SPEC) private IndexSpec spec; @@ -185,6 +190,27 @@ public void setMetric(MetricEnum metric) { } + public CreateIndexRequest deletionProtection(DeletionProtection deletionProtection) { + + this.deletionProtection = deletionProtection; + return this; + } + + /** + * Get deletionProtection + * @return deletionProtection + **/ + @javax.annotation.Nullable + public DeletionProtection getDeletionProtection() { + return deletionProtection; + } + + + public void setDeletionProtection(DeletionProtection deletionProtection) { + this.deletionProtection = deletionProtection; + } + + public CreateIndexRequest spec(IndexSpec spec) { this.spec = spec; @@ -263,13 +289,14 @@ public boolean equals(Object o) { return Objects.equals(this.name, createIndexRequest.name) && Objects.equals(this.dimension, createIndexRequest.dimension) && Objects.equals(this.metric, createIndexRequest.metric) && + Objects.equals(this.deletionProtection, createIndexRequest.deletionProtection) && Objects.equals(this.spec, createIndexRequest.spec)&& Objects.equals(this.additionalProperties, createIndexRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, dimension, metric, spec, additionalProperties); + return Objects.hash(name, dimension, metric, deletionProtection, spec, additionalProperties); } @Override @@ -279,6 +306,7 @@ public String toString() { 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(" deletionProtection: ").append(toIndentedString(deletionProtection)).append("\n"); sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); @@ -306,6 +334,7 @@ private String toIndentedString(Object o) { openapiFields.add("name"); openapiFields.add("dimension"); openapiFields.add("metric"); + openapiFields.add("deletion_protection"); openapiFields.add("spec"); // a set of required properties/fields (JSON key names) diff --git a/src/main/java/org/openapitools/control/client/model/DeletionProtection.java b/src/main/java/org/openapitools/control/client/model/DeletionProtection.java new file mode 100644 index 00000000..0eaa2c6a --- /dev/null +++ b/src/main/java/org/openapitools/control/client/model/DeletionProtection.java @@ -0,0 +1,72 @@ +/* + * Pinecone Control Plane 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: 2024-07 + * Contact: support@pinecone.io + * + * 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.control.client.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +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; + +/** + * Whether delete protection is enabled/disabled for the resource. + */ +@JsonAdapter(DeletionProtection.Adapter.class) +public enum DeletionProtection { + + DISABLED("disabled"), + + ENABLED("enabled"); + + private String value; + + DeletionProtection(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DeletionProtection fromValue(String value) { + for (DeletionProtection b : DeletionProtection.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 DeletionProtection enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public DeletionProtection read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return DeletionProtection.fromValue(value); + } + } +} + diff --git a/src/main/java/org/openapitools/control/client/model/EmbedRequest.java b/src/main/java/org/openapitools/control/client/model/EmbedRequest.java index c27f5827..8cffa9b9 100644 --- a/src/main/java/org/openapitools/control/client/model/EmbedRequest.java +++ b/src/main/java/org/openapitools/control/client/model/EmbedRequest.java @@ -53,7 +53,7 @@ /** * Generate embeddings for inputs */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class EmbedRequest { public static final String SERIALIZED_NAME_MODEL = "model"; @SerializedName(SERIALIZED_NAME_MODEL) diff --git a/src/main/java/org/openapitools/control/client/model/EmbedRequestInputsInner.java b/src/main/java/org/openapitools/control/client/model/EmbedRequestInputsInner.java index e64bfce0..86033a5b 100644 --- a/src/main/java/org/openapitools/control/client/model/EmbedRequestInputsInner.java +++ b/src/main/java/org/openapitools/control/client/model/EmbedRequestInputsInner.java @@ -49,7 +49,7 @@ /** * EmbedRequestInputsInner */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class EmbedRequestInputsInner { public static final String SERIALIZED_NAME_TEXT = "text"; @SerializedName(SERIALIZED_NAME_TEXT) diff --git a/src/main/java/org/openapitools/control/client/model/EmbedRequestParameters.java b/src/main/java/org/openapitools/control/client/model/EmbedRequestParameters.java index 39bbca85..10469745 100644 --- a/src/main/java/org/openapitools/control/client/model/EmbedRequestParameters.java +++ b/src/main/java/org/openapitools/control/client/model/EmbedRequestParameters.java @@ -49,7 +49,7 @@ /** * Model-specific parameters. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class EmbedRequestParameters { public static final String SERIALIZED_NAME_INPUT_TYPE = "input_type"; @SerializedName(SERIALIZED_NAME_INPUT_TYPE) diff --git a/src/main/java/org/openapitools/control/client/model/Embedding.java b/src/main/java/org/openapitools/control/client/model/Embedding.java index 8bbe3fd1..f8d743ea 100644 --- a/src/main/java/org/openapitools/control/client/model/Embedding.java +++ b/src/main/java/org/openapitools/control/client/model/Embedding.java @@ -52,7 +52,7 @@ /** * Embedding of a single input */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class Embedding { public static final String SERIALIZED_NAME_VALUES = "values"; @SerializedName(SERIALIZED_NAME_VALUES) diff --git a/src/main/java/org/openapitools/control/client/model/EmbeddingsList.java b/src/main/java/org/openapitools/control/client/model/EmbeddingsList.java index 55e57040..9bbdac61 100644 --- a/src/main/java/org/openapitools/control/client/model/EmbeddingsList.java +++ b/src/main/java/org/openapitools/control/client/model/EmbeddingsList.java @@ -53,7 +53,7 @@ /** * Embeddings generated for the input */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class EmbeddingsList { public static final String SERIALIZED_NAME_MODEL = "model"; @SerializedName(SERIALIZED_NAME_MODEL) diff --git a/src/main/java/org/openapitools/control/client/model/EmbeddingsListUsage.java b/src/main/java/org/openapitools/control/client/model/EmbeddingsListUsage.java index fcb76ab1..2c4cbcd0 100644 --- a/src/main/java/org/openapitools/control/client/model/EmbeddingsListUsage.java +++ b/src/main/java/org/openapitools/control/client/model/EmbeddingsListUsage.java @@ -49,7 +49,7 @@ /** * Usage statistics for model inference including any instruction prefixes */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class EmbeddingsListUsage { public static final String SERIALIZED_NAME_TOTAL_TOKENS = "total_tokens"; @SerializedName(SERIALIZED_NAME_TOTAL_TOKENS) diff --git a/src/main/java/org/openapitools/control/client/model/ListIndexes401Response.java b/src/main/java/org/openapitools/control/client/model/ErrorResponse.java similarity index 79% rename from src/main/java/org/openapitools/control/client/model/ListIndexes401Response.java rename to src/main/java/org/openapitools/control/client/model/ErrorResponse.java index ed7b851c..3a59ac92 100644 --- a/src/main/java/org/openapitools/control/client/model/ListIndexes401Response.java +++ b/src/main/java/org/openapitools/control/client/model/ErrorResponse.java @@ -21,7 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.control.client.model.ListIndexes401ResponseError; +import org.openapitools.control.client.model.ErrorResponseError; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -50,20 +50,20 @@ /** * The response shape used for all error responses. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") -public class ListIndexes401Response { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") +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 ListIndexes401ResponseError error; + private ErrorResponseError error; - public ListIndexes401Response() { + public ErrorResponse() { } - public ListIndexes401Response status(Integer status) { + public ErrorResponse status(Integer status) { this.status = status; return this; @@ -84,7 +84,7 @@ public void setStatus(Integer status) { } - public ListIndexes401Response error(ListIndexes401ResponseError error) { + public ErrorResponse error(ErrorResponseError error) { this.error = error; return this; @@ -95,12 +95,12 @@ public ListIndexes401Response error(ListIndexes401ResponseError error) { * @return error **/ @javax.annotation.Nonnull - public ListIndexes401ResponseError getError() { + public ErrorResponseError getError() { return error; } - public void setError(ListIndexes401ResponseError error) { + public void setError(ErrorResponseError error) { this.error = error; } @@ -117,9 +117,9 @@ public void setError(ListIndexes401ResponseError error) { * * @param key name of the property * @param value value of the property - * @return the ListIndexes401Response instance itself + * @return the ErrorResponse instance itself */ - public ListIndexes401Response putAdditionalProperty(String key, Object value) { + public ErrorResponse putAdditionalProperty(String key, Object value) { if (this.additionalProperties == null) { this.additionalProperties = new HashMap(); } @@ -158,10 +158,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ListIndexes401Response listIndexes401Response = (ListIndexes401Response) o; - return Objects.equals(this.status, listIndexes401Response.status) && - Objects.equals(this.error, listIndexes401Response.error)&& - Objects.equals(this.additionalProperties, listIndexes401Response.additionalProperties); + ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.status, errorResponse.status) && + Objects.equals(this.error, errorResponse.error)&& + Objects.equals(this.additionalProperties, errorResponse.additionalProperties); } @Override @@ -172,7 +172,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ListIndexes401Response {\n"); + sb.append("class ErrorResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" error: ").append(toIndentedString(error)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); @@ -211,40 +211,40 @@ private String toIndentedString(Object o) { * 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 ListIndexes401Response + * @throws IOException if the JSON Element is invalid with respect to ErrorResponse */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!ListIndexes401Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in ListIndexes401Response is not found in the empty JSON string", ListIndexes401Response.openapiRequiredFields.toString())); + 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())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ListIndexes401Response.openapiRequiredFields) { + 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` - ListIndexes401ResponseError.validateJsonElement(jsonObj.get("error")); + ErrorResponseError.validateJsonElement(jsonObj.get("error")); } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ListIndexes401Response.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ListIndexes401Response' and its subtypes + 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(ListIndexes401Response.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorResponse.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ListIndexes401Response value) throws IOException { + public void write(JsonWriter out, ErrorResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); obj.remove("additionalProperties"); // serialize additional properties @@ -267,12 +267,12 @@ else if (entry.getValue() instanceof Character) } @Override - public ListIndexes401Response read(JsonReader in) throws IOException { + public ErrorResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); JsonObject jsonObj = jsonElement.getAsJsonObject(); // store additional fields in the deserialized instance - ListIndexes401Response instance = thisAdapter.fromJsonTree(jsonObj); + ErrorResponse instance = thisAdapter.fromJsonTree(jsonObj); for (Map.Entry entry : jsonObj.entrySet()) { if (!openapiFields.contains(entry.getKey())) { if (entry.getValue().isJsonPrimitive()) { // primitive type @@ -299,18 +299,18 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean()) } /** - * Create an instance of ListIndexes401Response given an JSON string + * Create an instance of ErrorResponse given an JSON string * * @param jsonString JSON string - * @return An instance of ListIndexes401Response - * @throws IOException if the JSON string is invalid with respect to ListIndexes401Response + * @return An instance of ErrorResponse + * @throws IOException if the JSON string is invalid with respect to ErrorResponse */ - public static ListIndexes401Response fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ListIndexes401Response.class); + public static ErrorResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponse.class); } /** - * Convert an instance of ListIndexes401Response to an JSON string + * Convert an instance of ErrorResponse to an JSON string * * @return JSON string */ diff --git a/src/main/java/org/openapitools/control/client/model/ListIndexes401ResponseError.java b/src/main/java/org/openapitools/control/client/model/ErrorResponseError.java similarity index 83% rename from src/main/java/org/openapitools/control/client/model/ListIndexes401ResponseError.java rename to src/main/java/org/openapitools/control/client/model/ErrorResponseError.java index 63fadfbf..c6c74ce4 100644 --- a/src/main/java/org/openapitools/control/client/model/ListIndexes401ResponseError.java +++ b/src/main/java/org/openapitools/control/client/model/ErrorResponseError.java @@ -49,8 +49,8 @@ /** * Detailed information about the error that occurred. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") -public class ListIndexes401ResponseError { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") +public class ErrorResponseError { /** * Gets or Sets code */ @@ -90,7 +90,9 @@ public enum CodeEnum { DATA_LOSS("DATA_LOSS"), - FORBIDDEN("FORBIDDEN"); + FORBIDDEN("FORBIDDEN"), + + UNPROCESSABLE_ENTITY("UNPROCESSABLE_ENTITY"); private String value; @@ -142,10 +144,10 @@ public CodeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_DETAILS) private Object details; - public ListIndexes401ResponseError() { + public ErrorResponseError() { } - public ListIndexes401ResponseError code(CodeEnum code) { + public ErrorResponseError code(CodeEnum code) { this.code = code; return this; @@ -166,7 +168,7 @@ public void setCode(CodeEnum code) { } - public ListIndexes401ResponseError message(String message) { + public ErrorResponseError message(String message) { this.message = message; return this; @@ -187,7 +189,7 @@ public void setMessage(String message) { } - public ListIndexes401ResponseError details(Object details) { + public ErrorResponseError details(Object details) { this.details = details; return this; @@ -220,9 +222,9 @@ public void setDetails(Object details) { * * @param key name of the property * @param value value of the property - * @return the ListIndexes401ResponseError instance itself + * @return the ErrorResponseError instance itself */ - public ListIndexes401ResponseError putAdditionalProperty(String key, Object value) { + public ErrorResponseError putAdditionalProperty(String key, Object value) { if (this.additionalProperties == null) { this.additionalProperties = new HashMap(); } @@ -261,11 +263,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ListIndexes401ResponseError listIndexes401ResponseError = (ListIndexes401ResponseError) o; - return Objects.equals(this.code, listIndexes401ResponseError.code) && - Objects.equals(this.message, listIndexes401ResponseError.message) && - Objects.equals(this.details, listIndexes401ResponseError.details)&& - Objects.equals(this.additionalProperties, listIndexes401ResponseError.additionalProperties); + ErrorResponseError errorResponseError = (ErrorResponseError) o; + return Objects.equals(this.code, errorResponseError.code) && + Objects.equals(this.message, errorResponseError.message) && + Objects.equals(this.details, errorResponseError.details)&& + Objects.equals(this.additionalProperties, errorResponseError.additionalProperties); } @Override @@ -276,7 +278,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ListIndexes401ResponseError {\n"); + 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"); @@ -317,17 +319,17 @@ private String toIndentedString(Object o) { * 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 ListIndexes401ResponseError + * @throws IOException if the JSON Element is invalid with respect to ErrorResponseError */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!ListIndexes401ResponseError.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in ListIndexes401ResponseError is not found in the empty JSON string", ListIndexes401ResponseError.openapiRequiredFields.toString())); + 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())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ListIndexes401ResponseError.openapiRequiredFields) { + 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())); } @@ -345,16 +347,16 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ListIndexes401ResponseError.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ListIndexes401ResponseError' and its subtypes + 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(ListIndexes401ResponseError.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorResponseError.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ListIndexes401ResponseError value) throws IOException { + public void write(JsonWriter out, ErrorResponseError value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); obj.remove("additionalProperties"); // serialize additional properties @@ -377,12 +379,12 @@ else if (entry.getValue() instanceof Character) } @Override - public ListIndexes401ResponseError read(JsonReader in) throws IOException { + public ErrorResponseError read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); JsonObject jsonObj = jsonElement.getAsJsonObject(); // store additional fields in the deserialized instance - ListIndexes401ResponseError instance = thisAdapter.fromJsonTree(jsonObj); + ErrorResponseError instance = thisAdapter.fromJsonTree(jsonObj); for (Map.Entry entry : jsonObj.entrySet()) { if (!openapiFields.contains(entry.getKey())) { if (entry.getValue().isJsonPrimitive()) { // primitive type @@ -409,18 +411,18 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean()) } /** - * Create an instance of ListIndexes401ResponseError given an JSON string + * Create an instance of ErrorResponseError given an JSON string * * @param jsonString JSON string - * @return An instance of ListIndexes401ResponseError - * @throws IOException if the JSON string is invalid with respect to ListIndexes401ResponseError + * @return An instance of ErrorResponseError + * @throws IOException if the JSON string is invalid with respect to ErrorResponseError */ - public static ListIndexes401ResponseError fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ListIndexes401ResponseError.class); + public static ErrorResponseError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponseError.class); } /** - * Convert an instance of ListIndexes401ResponseError to an JSON string + * Convert an instance of ErrorResponseError to an JSON string * * @return JSON string */ diff --git a/src/main/java/org/openapitools/control/client/model/IndexList.java b/src/main/java/org/openapitools/control/client/model/IndexList.java index cf8bb44b..e8a8a597 100644 --- a/src/main/java/org/openapitools/control/client/model/IndexList.java +++ b/src/main/java/org/openapitools/control/client/model/IndexList.java @@ -52,7 +52,7 @@ /** * The list of indexes that exist in the project. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class IndexList { public static final String SERIALIZED_NAME_INDEXES = "indexes"; @SerializedName(SERIALIZED_NAME_INDEXES) diff --git a/src/main/java/org/openapitools/control/client/model/IndexModel.java b/src/main/java/org/openapitools/control/client/model/IndexModel.java index 3fce6199..1aa42f04 100644 --- a/src/main/java/org/openapitools/control/client/model/IndexModel.java +++ b/src/main/java/org/openapitools/control/client/model/IndexModel.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.control.client.model.DeletionProtection; import org.openapitools.control.client.model.IndexModelSpec; import org.openapitools.control.client.model.IndexModelStatus; @@ -51,7 +52,7 @@ /** * The IndexModel describes the configuration and status of a Pinecone index. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class IndexModel { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) @@ -118,6 +119,10 @@ public MetricEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_HOST) private String host; + public static final String SERIALIZED_NAME_DELETION_PROTECTION = "deletion_protection"; + @SerializedName(SERIALIZED_NAME_DELETION_PROTECTION) + private DeletionProtection deletionProtection = DeletionProtection.DISABLED; + public static final String SERIALIZED_NAME_SPEC = "spec"; @SerializedName(SERIALIZED_NAME_SPEC) private IndexModelSpec spec; @@ -215,6 +220,27 @@ public void setHost(String host) { } + public IndexModel deletionProtection(DeletionProtection deletionProtection) { + + this.deletionProtection = deletionProtection; + return this; + } + + /** + * Get deletionProtection + * @return deletionProtection + **/ + @javax.annotation.Nullable + public DeletionProtection getDeletionProtection() { + return deletionProtection; + } + + + public void setDeletionProtection(DeletionProtection deletionProtection) { + this.deletionProtection = deletionProtection; + } + + public IndexModel spec(IndexModelSpec spec) { this.spec = spec; @@ -315,6 +341,7 @@ public boolean equals(Object o) { Objects.equals(this.dimension, indexModel.dimension) && Objects.equals(this.metric, indexModel.metric) && Objects.equals(this.host, indexModel.host) && + Objects.equals(this.deletionProtection, indexModel.deletionProtection) && Objects.equals(this.spec, indexModel.spec) && Objects.equals(this.status, indexModel.status)&& Objects.equals(this.additionalProperties, indexModel.additionalProperties); @@ -322,7 +349,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(name, dimension, metric, host, spec, status, additionalProperties); + return Objects.hash(name, dimension, metric, host, deletionProtection, spec, status, additionalProperties); } @Override @@ -333,6 +360,7 @@ public String toString() { 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(" deletionProtection: ").append(toIndentedString(deletionProtection)).append("\n"); sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); @@ -362,6 +390,7 @@ private String toIndentedString(Object o) { openapiFields.add("dimension"); openapiFields.add("metric"); openapiFields.add("host"); + openapiFields.add("deletion_protection"); openapiFields.add("spec"); openapiFields.add("status"); diff --git a/src/main/java/org/openapitools/control/client/model/IndexModelSpec.java b/src/main/java/org/openapitools/control/client/model/IndexModelSpec.java index 7f14cc2a..cf098956 100644 --- a/src/main/java/org/openapitools/control/client/model/IndexModelSpec.java +++ b/src/main/java/org/openapitools/control/client/model/IndexModelSpec.java @@ -51,7 +51,7 @@ /** * IndexModelSpec */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class IndexModelSpec { public static final String SERIALIZED_NAME_POD = "pod"; @SerializedName(SERIALIZED_NAME_POD) diff --git a/src/main/java/org/openapitools/control/client/model/IndexModelStatus.java b/src/main/java/org/openapitools/control/client/model/IndexModelStatus.java index c5345c97..3bcc66d5 100644 --- a/src/main/java/org/openapitools/control/client/model/IndexModelStatus.java +++ b/src/main/java/org/openapitools/control/client/model/IndexModelStatus.java @@ -49,7 +49,7 @@ /** * IndexModelStatus */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class IndexModelStatus { public static final String SERIALIZED_NAME_READY = "ready"; @SerializedName(SERIALIZED_NAME_READY) diff --git a/src/main/java/org/openapitools/control/client/model/IndexSpec.java b/src/main/java/org/openapitools/control/client/model/IndexSpec.java index 00d5380d..5de50f80 100644 --- a/src/main/java/org/openapitools/control/client/model/IndexSpec.java +++ b/src/main/java/org/openapitools/control/client/model/IndexSpec.java @@ -49,9 +49,9 @@ import org.openapitools.control.client.JSON; /** - * The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. + * The spec object defines how the index should be deployed. For serverless indexes, you define only the [cloud and region](http://docs.pinecone.io/guides/indexes/understanding-indexes#cloud-regions) where the index should be hosted. For pod-based indexes, you define the [environment](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-environments) where the index should be hosted, the [pod type and size](http://docs.pinecone.io/guides/indexes/understanding-indexes#pod-types) to use, and other index characteristics. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class IndexSpec { public static final String SERIALIZED_NAME_SERVERLESS = "serverless"; @SerializedName(SERIALIZED_NAME_SERVERLESS) diff --git a/src/main/java/org/openapitools/control/client/model/PodSpec.java b/src/main/java/org/openapitools/control/client/model/PodSpec.java index 5359b6ec..d2cf6d99 100644 --- a/src/main/java/org/openapitools/control/client/model/PodSpec.java +++ b/src/main/java/org/openapitools/control/client/model/PodSpec.java @@ -50,7 +50,7 @@ /** * Configuration needed to deploy a pod-based index. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class PodSpec { public static final String SERIALIZED_NAME_ENVIRONMENT = "environment"; @SerializedName(SERIALIZED_NAME_ENVIRONMENT) @@ -115,7 +115,7 @@ public PodSpec replicas(Integer replicas) { * minimum: 1 * @return replicas **/ - @javax.annotation.Nullable + @javax.annotation.Nonnull public Integer getReplicas() { return replicas; } @@ -137,7 +137,7 @@ public PodSpec shards(Integer shards) { * minimum: 1 * @return shards **/ - @javax.annotation.Nullable + @javax.annotation.Nonnull public Integer getShards() { return shards; } @@ -347,6 +347,8 @@ private String toIndentedString(Object o) { // 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"); } diff --git a/src/main/java/org/openapitools/control/client/model/PodSpecMetadataConfig.java b/src/main/java/org/openapitools/control/client/model/PodSpecMetadataConfig.java index 4434f4f7..560862a1 100644 --- a/src/main/java/org/openapitools/control/client/model/PodSpecMetadataConfig.java +++ b/src/main/java/org/openapitools/control/client/model/PodSpecMetadataConfig.java @@ -51,7 +51,7 @@ /** * 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-based indexes. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class PodSpecMetadataConfig { public static final String SERIALIZED_NAME_INDEXED = "indexed"; @SerializedName(SERIALIZED_NAME_INDEXED) diff --git a/src/main/java/org/openapitools/control/client/model/ServerlessSpec.java b/src/main/java/org/openapitools/control/client/model/ServerlessSpec.java index 85ee3585..60e39ddc 100644 --- a/src/main/java/org/openapitools/control/client/model/ServerlessSpec.java +++ b/src/main/java/org/openapitools/control/client/model/ServerlessSpec.java @@ -49,10 +49,10 @@ /** * Configuration needed to deploy a serverless index. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-08T21:08:32.278360Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-07-16T15:28:37.412995Z[Etc/UTC]") public class ServerlessSpec { /** - * The public cloud where you would like your index hosted. Serverless indexes can be hosted only in AWS at this time. + * The public cloud where you would like your index hosted. */ @JsonAdapter(CloudEnum.Adapter.class) public enum CloudEnum { @@ -118,7 +118,7 @@ public ServerlessSpec cloud(CloudEnum cloud) { } /** - * The public cloud where you would like your index hosted. Serverless indexes can be hosted only in AWS at this time. + * The public cloud where you would like your index hosted. * @return cloud **/ @javax.annotation.Nonnull @@ -139,7 +139,7 @@ public ServerlessSpec region(String region) { } /** - * The region where you would like your index to be created. Serverless indexes can be created only in the us-east-1,us-west-2, and eu-west-1 regions of AWS at this time. + * The region where you would like your index to be created. * @return region **/ @javax.annotation.Nonnull diff --git a/src/test/java/io/pinecone/PineconeIndexOperationsTest.java b/src/test/java/io/pinecone/PineconeIndexOperationsTest.java index 80fb1efe..b1e52ce2 100644 --- a/src/test/java/io/pinecone/PineconeIndexOperationsTest.java +++ b/src/test/java/io/pinecone/PineconeIndexOperationsTest.java @@ -64,55 +64,55 @@ public void testCreateServerlessIndex() throws IOException { Pinecone client = new Pinecone.Builder("testAPiKey").withOkHttpClient(mockClient).build(); - client.createServerlessIndex("testServerlessIndex", "cosine", 3, "aws", "us-west-2"); + client.createServerlessIndex("testServerlessIndex", "cosine", 3, "aws", "us-west-2", DeletionProtection.DISABLED); verify(mockCall, times(1)).execute(); PineconeValidationException thrownEmptyIndexName = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("", "cosine", 3, "aws", "us-west-2")); + () -> client.createServerlessIndex("", "cosine", 3, "aws", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Index name cannot be null or empty", thrownEmptyIndexName.getMessage()); PineconeValidationException thrownNullIndexName = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex(null, "cosine", 3, "aws", "us-west-2")); + () -> client.createServerlessIndex(null, "cosine", 3, "aws", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Index name cannot be null or empty", thrownNullIndexName.getMessage()); PineconeValidationException thrownEmptyMetric = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "", 3, "aws", "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", "", 3, "aws", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Metric cannot be null or empty. Must be one of " + Arrays.toString(IndexModel.MetricEnum.values()), thrownEmptyMetric.getMessage()); PineconeValidationException thrownInvalidMetric = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "blah", 3, "aws", "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", "blah", 3, "aws", "us-west-2", DeletionProtection.DISABLED)); assertEquals(String.format("Metric cannot be null or empty. Must be one of " + Arrays.toString(IndexModel.MetricEnum.values())), thrownInvalidMetric.getMessage()); PineconeValidationException thrownNullMetric = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", null, 3, "aws", "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", null, 3, "aws", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Metric cannot be null or empty. Must be one of " + Arrays.toString(IndexModel.MetricEnum.values()), thrownNullMetric.getMessage()); PineconeValidationException thrownNegativeDimension = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "cosine", -3, "aws", "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", "cosine", -3, "aws", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Dimension must be greater than 0. See limits for more info: https://docs.pinecone.io/reference/limits", thrownNegativeDimension.getMessage()); PineconeValidationException thrownEmptyCloud = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "", "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Cloud cannot be null or empty. Must be one of " + Arrays.toString(ServerlessSpec.CloudEnum.values()), thrownEmptyCloud.getMessage()); PineconeValidationException thrownNullCloud = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, null, "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, null, "us-west-2", DeletionProtection.DISABLED)); assertEquals("Cloud cannot be null or empty. Must be one of " + Arrays.toString(ServerlessSpec.CloudEnum.values()), thrownNullCloud.getMessage()); PineconeValidationException thrownInvalidCloud = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "wooooo", "us-west-2")); + () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "wooooo", "us-west-2", DeletionProtection.DISABLED)); assertEquals("Cloud cannot be null or empty. Must be one of " + Arrays.toString(ServerlessSpec.CloudEnum.values()), thrownInvalidCloud.getMessage()); PineconeValidationException thrownEmptyRegion = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "aws", "")); + () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "aws", "", DeletionProtection.DISABLED)); assertEquals("Region cannot be null or empty", thrownEmptyRegion.getMessage()); PineconeValidationException thrownNullRegion = assertThrows(PineconeValidationException.class, - () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "aws", null)); + () -> client.createServerlessIndex("testServerlessIndex", "cosine", 3, "aws", null, DeletionProtection.DISABLED)); assertEquals("Region cannot be null or empty", thrownNullRegion.getMessage()); } @@ -144,7 +144,8 @@ public void testCreatePodsIndex() throws IOException { 1, 2, new PodSpecMetadataConfig(), - "some-source-collection"); + "some-source-collection", + DeletionProtection.DISABLED); ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(Request.class); @@ -328,25 +329,25 @@ public void testConfigureIndex() throws IOException { OkHttpClient mockClient = mock(OkHttpClient.class); when(mockClient.newCall(any(Request.class))).thenReturn(mockCall); Pinecone client = new Pinecone.Builder("testAPiKey").withOkHttpClient(mockClient).build(); - IndexModel configuredIndex = client.configureIndex("testPodIndex", 3); + IndexModel configuredIndex = client.configurePodsIndex("testPodIndex", 3, DeletionProtection.DISABLED); verify(mockCall, times(1)).execute(); assertEquals(expectedConfiguredIndex, configuredIndex); // Test for empty string for index name PineconeValidationException thrownEmptyIndexName = assertThrows(PineconeValidationException.class, - () -> client.configureIndex("", - 3)); + () -> client.configurePodsIndex("", + 3, DeletionProtection.DISABLED)); assertEquals("indexName cannot be null or empty", thrownEmptyIndexName.getMessage()); // Test for null as index name - PineconeValidationException thrownNullIndexName = assertThrows(PineconeValidationException.class, () -> client.configureIndex(null, - 3)); + PineconeValidationException thrownNullIndexName = assertThrows(PineconeValidationException.class, () -> client.configurePodsIndex(null, + 3, DeletionProtection.DISABLED)); assertEquals("indexName cannot be null or empty", thrownNullIndexName.getMessage()); // Test for invalid number of replicas PineconeValidationException thrownZeroReplicas = assertThrows(PineconeValidationException.class, - () -> client.configureIndex("testPodIndex", 0)); + () -> client.configurePodsIndex("testPodIndex", 0, DeletionProtection.DISABLED)); assertEquals("Number of replicas must be >= 1", thrownZeroReplicas.getMessage()); }