-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
3411d21
commit 2ce9ac5
Showing
42 changed files
with
539 additions
and
192 deletions.
There are no files selected for viewing
Submodule apis
updated
from fbd9d8 to 3e5739
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/integration/java/io/pinecone/integration/controlPlane/pod/DeletionProtectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...egration/java/io/pinecone/integration/controlPlane/serverless/DeletionProtectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.