pinecone-sdk 0.1.2

Pinecone Rust SDK
Documentation
/*
 * 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
    }
}