1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* 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
* Generated by: https://openapi-generator.tech
*/
use crate::openapi::models;
use serde::{Deserialize, Serialize};
/// CreateIndexRequest : The configuration needed to create a Pinecone index.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateIndexRequest {
/// The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
#[serde(rename = "name")]
pub name: String,
/// The dimensions of the vectors to be inserted in the index.
#[serde(rename = "dimension")]
pub dimension: i32,
/// The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
#[serde(rename = "metric", skip_serializing_if = "Option::is_none")]
pub metric: Option<Metric>,
#[serde(rename = "deletion_protection", skip_serializing_if = "Option::is_none")]
pub deletion_protection: Option<models::DeletionProtection>,
#[serde(rename = "spec", deserialize_with = "Option::deserialize")]
pub spec: Option<Box<models::IndexSpec>>,
}
impl CreateIndexRequest {
/// The configuration needed to create a Pinecone index.
pub fn new(name: String, dimension: i32, spec: Option<models::IndexSpec>) -> CreateIndexRequest {
CreateIndexRequest {
name,
dimension,
metric: None,
deletion_protection: None,
spec: if let Some(x) = spec {Some(Box::new(x))} else {None},
}
}
}
/// The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Metric {
#[serde(rename = "cosine")]
Cosine,
#[serde(rename = "euclidean")]
Euclidean,
#[serde(rename = "dotproduct")]
Dotproduct,
}
impl Default for Metric {
fn default() -> Metric {
Self::Cosine
}
}