Skip to content

Commit 838b4aa

Browse files
committed
make deletion protection an option
1 parent 2fe6a42 commit 838b4aa

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pinecone_sdk/src/pinecone/control.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl PineconeClient {
328328
///
329329
/// ### Arguments
330330
/// * name: &str - The name of the index to be configured.
331-
/// * deletion_protection: DeletionProtection - Deletion protection for the index.
331+
/// * deletion_protection: Option<DeletionProtection> - Deletion protection for the index.
332332
/// * replicas: Option<i32> - The desired number of replicas, lowest value is 0. This parameter should be `None` if the index is serverless.
333333
/// * pod_type: Option<&str> - The new pod_type for the index. This parameter should be `None` if the index is serverless.
334334
///
@@ -346,14 +346,14 @@ impl PineconeClient {
346346
/// let pinecone = PineconeClient::new(None, None, None, None).unwrap();
347347
///
348348
/// // Configure an index in the project.
349-
/// let response = pinecone.configure_index("index-name", DeletionProtection::Enabled, Some(6), Some("s1.x1")).await;
349+
/// let response = pinecone.configure_index("index-name", Some(DeletionProtection::Enabled), Some(6), Some("s1.x1")).await;
350350
/// # Ok(())
351351
/// # }
352352
/// ```
353353
pub async fn configure_index(
354354
&self,
355355
name: &str,
356-
deletion_protection: DeletionProtection,
356+
deletion_protection: Option<DeletionProtection>,
357357
replicas: Option<i32>,
358358
pod_type: Option<&str>,
359359
) -> Result<IndexModel, PineconeError> {
@@ -369,7 +369,7 @@ impl PineconeClient {
369369

370370
let configure_index_request = ConfigureIndexRequest {
371371
spec,
372-
deletion_protection: Some(deletion_protection),
372+
deletion_protection,
373373
};
374374

375375
// make openAPI call
@@ -1605,7 +1605,7 @@ mod tests {
16051605
let configure_index_response = pinecone
16061606
.configure_index(
16071607
"index-name",
1608-
DeletionProtection::Disabled,
1608+
Some(DeletionProtection::Disabled),
16091609
Some(6),
16101610
Some("p1.x1"),
16111611
)
@@ -1671,7 +1671,7 @@ mod tests {
16711671
.expect("Failed to create Pinecone instance");
16721672

16731673
let configure_index_response = pinecone
1674-
.configure_index("index-name", DeletionProtection::Disabled, None, None)
1674+
.configure_index("index-name", Some(DeletionProtection::Disabled), None, None)
16751675
.await
16761676
.expect("Failed to configure index");
16771677

@@ -1717,7 +1717,7 @@ mod tests {
17171717
let configure_index_response = pinecone
17181718
.configure_index(
17191719
"index-name",
1720-
DeletionProtection::Enabled,
1720+
Some(DeletionProtection::Enabled),
17211721
Some(6),
17221722
Some("p1.x1"),
17231723
)
@@ -1764,7 +1764,7 @@ mod tests {
17641764
let configure_index_response = pinecone
17651765
.configure_index(
17661766
"index-name",
1767-
DeletionProtection::Disabled,
1767+
Some(DeletionProtection::Disabled),
17681768
Some(6),
17691769
Some("p1.x1"),
17701770
)
@@ -1811,7 +1811,7 @@ mod tests {
18111811
let configure_index_response = pinecone
18121812
.configure_index(
18131813
"index-name",
1814-
DeletionProtection::Enabled,
1814+
Some(DeletionProtection::Enabled),
18151815
Some(6),
18161816
Some("p1.x1"),
18171817
)
@@ -1848,7 +1848,7 @@ mod tests {
18481848
let configure_index_response = pinecone
18491849
.configure_index(
18501850
"index-name",
1851-
DeletionProtection::Enabled,
1851+
Some(DeletionProtection::Enabled),
18521852
Some(6),
18531853
Some("p1.x1"),
18541854
)

pinecone_sdk/tests/integration_test_control.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ async fn test_configure_index() -> Result<(), PineconeError> {
262262
let _ = pinecone
263263
.configure_index(
264264
&get_pod_index(),
265-
DeletionProtection::Enabled,
265+
Some(DeletionProtection::Enabled),
266266
Some(1),
267267
Some("s1.x1"),
268268
)
@@ -297,7 +297,7 @@ async fn test_configure_deletion_protection() -> Result<(), PineconeError> {
297297
.expect_err("Expected to fail to delete index");
298298

299299
let _ = pinecone
300-
.configure_index(index_name, DeletionProtection::Disabled, None, None)
300+
.configure_index(index_name, Some(DeletionProtection::Disabled), None, None)
301301
.await
302302
.expect("Failed to configure index");
303303

@@ -317,7 +317,7 @@ async fn test_configure_serverless_index_err() -> Result<(), PineconeError> {
317317
let _ = pinecone
318318
.configure_index(
319319
&get_serverless_index(),
320-
DeletionProtection::Enabled,
320+
Some(DeletionProtection::Enabled),
321321
Some(1),
322322
Some("p1.x1"),
323323
)
@@ -335,7 +335,7 @@ async fn test_configure_invalid_index_err() -> Result<(), PineconeError> {
335335
let _ = pinecone
336336
.configure_index(
337337
"invalid-index",
338-
DeletionProtection::Enabled,
338+
Some(DeletionProtection::Enabled),
339339
Some(2),
340340
Some("p1.x1"),
341341
)

0 commit comments

Comments
 (0)