Skip to content

Commit b791291

Browse files
Implement deletion protection (#40)
## Problem Deletion protection was not implemented. ## Solution We updated the OpenAPI code to include deletion protection. This changed the parameters for several structs and functions, so all this code was updated to reflect the changes. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Test cases should still pass. --------- Co-authored-by: Emily Yu <emily.y@pinecone.io>
1 parent c0c109f commit b791291

16 files changed

+575
-122
lines changed

src/openapi/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,20 @@ Class | Method | HTTP request | Description
4848
- [ConfigureIndexRequestSpecPod](docs/ConfigureIndexRequestSpecPod.md)
4949
- [CreateCollectionRequest](docs/CreateCollectionRequest.md)
5050
- [CreateIndexRequest](docs/CreateIndexRequest.md)
51+
- [DeletionProtection](docs/DeletionProtection.md)
5152
- [EmbedRequest](docs/EmbedRequest.md)
5253
- [EmbedRequestInputsInner](docs/EmbedRequestInputsInner.md)
5354
- [EmbedRequestParameters](docs/EmbedRequestParameters.md)
5455
- [Embedding](docs/Embedding.md)
5556
- [EmbeddingsList](docs/EmbeddingsList.md)
5657
- [EmbeddingsListUsage](docs/EmbeddingsListUsage.md)
58+
- [ErrorResponse](docs/ErrorResponse.md)
59+
- [ErrorResponseError](docs/ErrorResponseError.md)
5760
- [IndexList](docs/IndexList.md)
5861
- [IndexModel](docs/IndexModel.md)
5962
- [IndexModelSpec](docs/IndexModelSpec.md)
6063
- [IndexModelStatus](docs/IndexModelStatus.md)
6164
- [IndexSpec](docs/IndexSpec.md)
62-
- [ListIndexes401Response](docs/ListIndexes401Response.md)
63-
- [ListIndexes401ResponseError](docs/ListIndexes401ResponseError.md)
6465
- [PodSpec](docs/PodSpec.md)
6566
- [PodSpecMetadataConfig](docs/PodSpecMetadataConfig.md)
6667
- [ServerlessSpec](docs/ServerlessSpec.md)

src/openapi/apis/inference_api.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use super::{Error, configuration};
1919
#[derive(Debug, Clone, Serialize, Deserialize)]
2020
#[serde(untagged)]
2121
pub enum EmbedError {
22-
Status400(models::ListIndexes401Response),
23-
Status401(models::ListIndexes401Response),
24-
Status500(models::ListIndexes401Response),
22+
Status400(models::ErrorResponse),
23+
Status401(models::ErrorResponse),
24+
Status500(models::ErrorResponse),
2525
UnknownValue(serde_json::Value),
2626
}
2727

src/openapi/apis/manage_indexes_api.rs

+37-37
Original file line numberDiff line numberDiff line change
@@ -19,103 +19,103 @@ use super::{Error, configuration};
1919
#[derive(Debug, Clone, Serialize, Deserialize)]
2020
#[serde(untagged)]
2121
pub enum ConfigureIndexError {
22-
Status400(models::ListIndexes401Response),
23-
Status401(models::ListIndexes401Response),
24-
Status403(models::ListIndexes401Response),
25-
Status404(models::ListIndexes401Response),
26-
Status422(models::ListIndexes401Response),
27-
Status500(models::ListIndexes401Response),
22+
Status400(models::ErrorResponse),
23+
Status401(models::ErrorResponse),
24+
Status403(models::ErrorResponse),
25+
Status404(models::ErrorResponse),
26+
Status422(models::ErrorResponse),
27+
Status500(models::ErrorResponse),
2828
UnknownValue(serde_json::Value),
2929
}
3030

3131
/// struct for typed errors of method [`create_collection`]
3232
#[derive(Debug, Clone, Serialize, Deserialize)]
3333
#[serde(untagged)]
3434
pub enum CreateCollectionError {
35-
Status400(models::ListIndexes401Response),
36-
Status401(models::ListIndexes401Response),
37-
Status403(models::ListIndexes401Response),
38-
Status409(models::ListIndexes401Response),
39-
Status422(models::ListIndexes401Response),
40-
Status500(models::ListIndexes401Response),
35+
Status400(models::ErrorResponse),
36+
Status401(models::ErrorResponse),
37+
Status403(models::ErrorResponse),
38+
Status409(models::ErrorResponse),
39+
Status422(models::ErrorResponse),
40+
Status500(models::ErrorResponse),
4141
UnknownValue(serde_json::Value),
4242
}
4343

4444
/// struct for typed errors of method [`create_index`]
4545
#[derive(Debug, Clone, Serialize, Deserialize)]
4646
#[serde(untagged)]
4747
pub enum CreateIndexError {
48-
Status400(models::ListIndexes401Response),
49-
Status401(models::ListIndexes401Response),
50-
Status403(models::ListIndexes401Response),
51-
Status404(models::ListIndexes401Response),
52-
Status422(models::ListIndexes401Response),
53-
Status409(models::ListIndexes401Response),
54-
Status500(models::ListIndexes401Response),
48+
Status400(models::ErrorResponse),
49+
Status401(models::ErrorResponse),
50+
Status403(models::ErrorResponse),
51+
Status404(models::ErrorResponse),
52+
Status422(models::ErrorResponse),
53+
Status409(models::ErrorResponse),
54+
Status500(models::ErrorResponse),
5555
UnknownValue(serde_json::Value),
5656
}
5757

5858
/// struct for typed errors of method [`delete_collection`]
5959
#[derive(Debug, Clone, Serialize, Deserialize)]
6060
#[serde(untagged)]
6161
pub enum DeleteCollectionError {
62-
Status401(models::ListIndexes401Response),
63-
Status404(models::ListIndexes401Response),
64-
Status500(models::ListIndexes401Response),
62+
Status401(models::ErrorResponse),
63+
Status404(models::ErrorResponse),
64+
Status500(models::ErrorResponse),
6565
UnknownValue(serde_json::Value),
6666
}
6767

6868
/// struct for typed errors of method [`delete_index`]
6969
#[derive(Debug, Clone, Serialize, Deserialize)]
7070
#[serde(untagged)]
7171
pub enum DeleteIndexError {
72-
Status401(models::ListIndexes401Response),
73-
Status404(models::ListIndexes401Response),
74-
Status412(models::ListIndexes401Response),
75-
Status500(models::ListIndexes401Response),
72+
Status401(models::ErrorResponse),
73+
Status404(models::ErrorResponse),
74+
Status412(models::ErrorResponse),
75+
Status500(models::ErrorResponse),
7676
UnknownValue(serde_json::Value),
7777
}
7878

7979
/// struct for typed errors of method [`describe_collection`]
8080
#[derive(Debug, Clone, Serialize, Deserialize)]
8181
#[serde(untagged)]
8282
pub enum DescribeCollectionError {
83-
Status401(models::ListIndexes401Response),
84-
Status404(models::ListIndexes401Response),
85-
Status500(models::ListIndexes401Response),
83+
Status401(models::ErrorResponse),
84+
Status404(models::ErrorResponse),
85+
Status500(models::ErrorResponse),
8686
UnknownValue(serde_json::Value),
8787
}
8888

8989
/// struct for typed errors of method [`describe_index`]
9090
#[derive(Debug, Clone, Serialize, Deserialize)]
9191
#[serde(untagged)]
9292
pub enum DescribeIndexError {
93-
Status401(models::ListIndexes401Response),
94-
Status404(models::ListIndexes401Response),
95-
Status500(models::ListIndexes401Response),
93+
Status401(models::ErrorResponse),
94+
Status404(models::ErrorResponse),
95+
Status500(models::ErrorResponse),
9696
UnknownValue(serde_json::Value),
9797
}
9898

9999
/// struct for typed errors of method [`list_collections`]
100100
#[derive(Debug, Clone, Serialize, Deserialize)]
101101
#[serde(untagged)]
102102
pub enum ListCollectionsError {
103-
Status401(models::ListIndexes401Response),
104-
Status500(models::ListIndexes401Response),
103+
Status401(models::ErrorResponse),
104+
Status500(models::ErrorResponse),
105105
UnknownValue(serde_json::Value),
106106
}
107107

108108
/// struct for typed errors of method [`list_indexes`]
109109
#[derive(Debug, Clone, Serialize, Deserialize)]
110110
#[serde(untagged)]
111111
pub enum ListIndexesError {
112-
Status401(models::ListIndexes401Response),
113-
Status500(models::ListIndexes401Response),
112+
Status401(models::ErrorResponse),
113+
Status500(models::ErrorResponse),
114114
UnknownValue(serde_json::Value),
115115
}
116116

117117

118-
/// 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.
118+
/// This operation configures an existing index. For serverless indexes, you can configure only index deletion protection. For pod-based indexes, you can configure the pod size, number of replicas, and index deletion protection. It is not possible to change the pod type of a pod-based index. However, you can create a collection from a pod-based index and then [create a new pod-based index with a different pod type](http://docs.pinecone.io/guides/indexes/create-an-index#create-an-index-from-a-collection) from the collection. For guidance and examples, see [Configure an index](http://docs.pinecone.io/guides/indexes/configure-an-index).
119119
pub async fn configure_index(configuration: &configuration::Configuration, index_name: &str, configure_index_request: models::ConfigureIndexRequest) -> Result<models::IndexModel, Error<ConfigureIndexError>> {
120120
let local_var_configuration = configuration;
121121

src/openapi/models/configure_index_request.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ use serde::{Deserialize, Serialize};
1414
/// ConfigureIndexRequest : Configuration used to scale an index.
1515
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
1616
pub struct ConfigureIndexRequest {
17-
#[serde(rename = "spec")]
18-
pub spec: Box<models::ConfigureIndexRequestSpec>,
17+
#[serde(rename = "spec", skip_serializing_if = "Option::is_none")]
18+
pub spec: Option<Box<models::ConfigureIndexRequestSpec>>,
19+
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
20+
pub deletion_protection: Option<models::DeletionProtection>,
1921
}
2022

2123
impl ConfigureIndexRequest {
2224
/// Configuration used to scale an index.
23-
pub fn new(spec: models::ConfigureIndexRequestSpec) -> ConfigureIndexRequest {
25+
pub fn new() -> ConfigureIndexRequest {
2426
ConfigureIndexRequest {
25-
spec: Box::new(spec),
27+
spec: None,
28+
deletion_protection: None,
2629
}
2730
}
2831
}

src/openapi/models/create_index_request.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub struct CreateIndexRequest {
2323
/// The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
2424
#[serde(rename = "metric", skip_serializing_if = "Option::is_none")]
2525
pub metric: Option<Metric>,
26+
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
27+
pub deletion_protection: Option<models::DeletionProtection>,
2628
#[serde(rename = "spec", deserialize_with = "Option::deserialize")]
2729
pub spec: Option<Box<models::IndexSpec>>,
2830
}
@@ -34,6 +36,7 @@ impl CreateIndexRequest {
3436
name,
3537
dimension,
3638
metric: None,
39+
deletion_protection: None,
3740
spec: if let Some(x) = spec {Some(Box::new(x))} else {None},
3841
}
3942
}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Pinecone Control Plane API
3+
*
4+
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
5+
*
6+
* The version of the OpenAPI document: 2024-07
7+
* Contact: support@pinecone.io
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::openapi::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
/// DeletionProtection : Whether [deletion protection](http://docs.pinecone.io/guides/indexes/prevent-index-deletion) is enabled/disabled for the index.
15+
/// Whether [deletion protection](http://docs.pinecone.io/guides/indexes/prevent-index-deletion) is enabled/disabled for the index.
16+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
17+
pub enum DeletionProtection {
18+
#[serde(rename = "disabled")]
19+
Disabled,
20+
#[serde(rename = "enabled")]
21+
Enabled,
22+
23+
}
24+
25+
impl std::fmt::Display for DeletionProtection {
26+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
27+
match self {
28+
Self::Disabled => write!(f, "disabled"),
29+
Self::Enabled => write!(f, "enabled"),
30+
}
31+
}
32+
}
33+
34+
impl Default for DeletionProtection {
35+
fn default() -> DeletionProtection {
36+
Self::Disabled
37+
}
38+
}
39+

src/openapi/models/error_response.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Pinecone Control Plane API
3+
*
4+
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
5+
*
6+
* The version of the OpenAPI document: 2024-07
7+
* Contact: support@pinecone.io
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::openapi::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
/// ErrorResponse : The response shape used for all error responses.
15+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16+
pub struct ErrorResponse {
17+
/// The HTTP status code of the error.
18+
#[serde(rename = "status")]
19+
pub status: i32,
20+
#[serde(rename = "error")]
21+
pub error: Box<models::ErrorResponseError>,
22+
}
23+
24+
impl ErrorResponse {
25+
/// The response shape used for all error responses.
26+
pub fn new(status: i32, error: models::ErrorResponseError) -> ErrorResponse {
27+
ErrorResponse {
28+
status,
29+
error: Box::new(error),
30+
}
31+
}
32+
}
33+
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Pinecone Control Plane API
3+
*
4+
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
5+
*
6+
* The version of the OpenAPI document: 2024-07
7+
* Contact: support@pinecone.io
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::openapi::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
/// ErrorResponseError : Detailed information about the error that occurred.
15+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16+
pub struct ErrorResponseError {
17+
#[serde(rename = "code")]
18+
pub code: Code,
19+
#[serde(rename = "message")]
20+
pub message: String,
21+
/// Additional information about the error. This field is not guaranteed to be present.
22+
#[serde(rename = "details", skip_serializing_if = "Option::is_none")]
23+
pub details: Option<serde_json::Value>,
24+
}
25+
26+
impl ErrorResponseError {
27+
/// Detailed information about the error that occurred.
28+
pub fn new(code: Code, message: String) -> ErrorResponseError {
29+
ErrorResponseError {
30+
code,
31+
message,
32+
details: None,
33+
}
34+
}
35+
}
36+
///
37+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
38+
pub enum Code {
39+
#[serde(rename = "OK")]
40+
Ok,
41+
#[serde(rename = "UNKNOWN")]
42+
Unknown,
43+
#[serde(rename = "INVALID_ARGUMENT")]
44+
InvalidArgument,
45+
#[serde(rename = "DEADLINE_EXCEEDED")]
46+
DeadlineExceeded,
47+
#[serde(rename = "QUOTA_EXCEEDED")]
48+
QuotaExceeded,
49+
#[serde(rename = "NOT_FOUND")]
50+
NotFound,
51+
#[serde(rename = "ALREADY_EXISTS")]
52+
AlreadyExists,
53+
#[serde(rename = "PERMISSION_DENIED")]
54+
PermissionDenied,
55+
#[serde(rename = "UNAUTHENTICATED")]
56+
Unauthenticated,
57+
#[serde(rename = "RESOURCE_EXHAUSTED")]
58+
ResourceExhausted,
59+
#[serde(rename = "FAILED_PRECONDITION")]
60+
FailedPrecondition,
61+
#[serde(rename = "ABORTED")]
62+
Aborted,
63+
#[serde(rename = "OUT_OF_RANGE")]
64+
OutOfRange,
65+
#[serde(rename = "UNIMPLEMENTED")]
66+
Unimplemented,
67+
#[serde(rename = "INTERNAL")]
68+
Internal,
69+
#[serde(rename = "UNAVAILABLE")]
70+
Unavailable,
71+
#[serde(rename = "DATA_LOSS")]
72+
DataLoss,
73+
#[serde(rename = "FORBIDDEN")]
74+
Forbidden,
75+
#[serde(rename = "UNPROCESSABLE_ENTITY")]
76+
UnprocessableEntity,
77+
}
78+
79+
impl Default for Code {
80+
fn default() -> Code {
81+
Self::Ok
82+
}
83+
}
84+

src/openapi/models/index_model.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub struct IndexModel {
2626
/// The URL address where the index is hosted.
2727
#[serde(rename = "host")]
2828
pub host: String,
29+
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
30+
pub deletion_protection: Option<models::DeletionProtection>,
2931
#[serde(rename = "spec")]
3032
pub spec: Box<models::IndexModelSpec>,
3133
#[serde(rename = "status")]
@@ -40,6 +42,7 @@ impl IndexModel {
4042
dimension,
4143
metric,
4244
host,
45+
deletion_protection: None,
4346
spec: Box::new(spec),
4447
status: Box::new(status),
4548
}

0 commit comments

Comments
 (0)