12 #include <nlohmann/json.hpp>
16 using json = nlohmann::json;
18 namespace pinecone::types
33 NLOHMANN_JSON_SERIALIZE_ENUM(database_state, {{database_state::unknown,
nullptr},
34 {database_state::initializing,
"initializing"},
35 {database_state::scaling_up,
"scaling_up"},
36 {database_state::scaling_down,
"scaling_down"},
37 {database_state::terminating,
"terminating"},
38 {database_state::ready,
"ready"}});
51 NLOHMANN_JSON_SERIALIZE_ENUM(pod_type, {{pod_type::unknown,
nullptr},
54 {pod_type::p2,
"p2"}});
68 NLOHMANN_JSON_SERIALIZE_ENUM(pod_size, {{pod_size::unknown,
nullptr},
72 {pod_size::x8,
"x8"}});
85 NLOHMANN_JSON_SERIALIZE_ENUM(metric_type, {{metric_type::unknown,
nullptr},
86 {metric_type::euclidean,
"euclidean"},
87 {metric_type::cosine,
"cosine"},
88 {metric_type::dotproduct,
"dotproduct"}});
97 [[nodiscard]]
auto type()
const noexcept ->
pod_type {
return _type; }
98 [[nodiscard]]
auto size()
const noexcept ->
pod_size {
return _size; }
100 friend void to_json(nlohmann ::json& nlohmann_json_j,
const pod_configuration& nlohmann_json_t)
102 json typestr = nlohmann_json_t._type;
103 json sizestr = nlohmann_json_t._size;
107 friend void from_json(
const nlohmann ::json& nlohmann_json_j,
pod_configuration& nlohmann_json_t)
112 type_str.get_to(nlohmann_json_t._type);
113 size_str.get_to(nlohmann_json_t._size);
127 [[nodiscard]]
auto db_ready()
const noexcept ->
bool {
return ready; }
128 [[nodiscard]]
auto db_state()
const noexcept ->
database_state {
return state; }
139 [[nodiscard]] constexpr
auto db_name()
const noexcept ->
std::string const& {
return name; }
140 [[nodiscard]] constexpr
auto db_dimension()
const noexcept -> uint32_t {
return dimension; }
141 [[nodiscard]] constexpr
auto db_metric()
const noexcept ->
metric_type {
return metric; }
142 [[nodiscard]] constexpr
auto db_pod_type()
const noexcept ->
pod_configuration const&
146 [[nodiscard]] constexpr
auto db_pods()
const noexcept -> uint16_t {
return pods; }
147 [[nodiscard]] constexpr
auto db_replicas()
const noexcept -> uint16_t {
return replicas; }
148 [[nodiscard]] constexpr
auto db_shards()
const noexcept -> uint16_t {
return shards; }
167 [[nodiscard]]
auto db_status()
const noexcept ->
database_status {
return status; }
181 [[nodiscard]]
auto col_name()
const noexcept ->
std::string {
return name; }
182 [[nodiscard]]
auto col_size()
const noexcept -> uint64_t {
return size; }
183 [[nodiscard]]
auto col_status()
const noexcept ->
std::string {
return status; }
185 NLOHMANN_DEFINE_TYPE_INTRUSIVE(
collection, name, status, size);
203 [[nodiscard]]
auto index_replicas()
const noexcept -> uint16_t {
return replicas; }
223 [[nodiscard]]
auto col_name()
const noexcept ->
std::string const& {
return name; }
224 [[nodiscard]]
auto col_source()
const noexcept ->
std::string const& {
return source; }
239 : _name(
std::move(name)), _dimension(dimension)
249 auto with_pods(uint16_t pods) noexcept ->
builder&
257 _pod_config = pod_config;
261 auto with_shards(uint16_t shards) noexcept ->
builder&
267 auto with_replicas(uint16_t replicas) noexcept ->
builder&
269 _replicas = replicas;
281 _source_collection =
std::move(source_collection);
285 [[nodiscard]]
auto build() noexcept ->
new_index
301 std::optional<metric_type> _metric;
302 std::optional<uint16_t> _pods;
303 std::optional<pod_configuration> _pod_config;
304 std::optional<uint16_t> _shards;
305 std::optional<uint16_t> _replicas;
306 std::optional<std::vector<std::string>> _metadata_config;
307 std::optional<std::string> _source_collection;
310 friend void to_json(nlohmann ::json& nlohmann_json_j,
const new_index& nlohmann_json_t)
312 nlohmann_json_j[
"name"] = nlohmann_json_t.name;
313 nlohmann_json_j[
"dimension"] = nlohmann_json_t.dimension;
314 if (nlohmann_json_t.metric) {
315 nlohmann_json_j[
"metric"] = *nlohmann_json_t.metric;
317 if (nlohmann_json_t.pods) {
318 nlohmann_json_j[
"pods"] = *nlohmann_json_t.pods;
320 if (nlohmann_json_t.pod_type) {
321 nlohmann_json_j[
"pod_type"] = *nlohmann_json_t.pod_type;
323 if (nlohmann_json_t.shards) {
324 nlohmann_json_j[
"shards"] = *nlohmann_json_t.shards;
326 if (nlohmann_json_t.replicas) {
327 nlohmann_json_j[
"replicas"] = *nlohmann_json_t.replicas;
329 if (nlohmann_json_t.metadata_config) {
330 nlohmann_json_j[
"metadata_config"] = *nlohmann_json_t.metadata_config;
332 if (nlohmann_json_t.source_collection) {
333 nlohmann_json_j[
"source_collection"] = *nlohmann_json_t.source_collection;
337 [[nodiscard]]
auto index_name() const noexcept ->
std::
string {
return name; }
338 [[nodiscard]]
auto index_dimension() const noexcept -> uint16_t {
return dimension; }
339 [[nodiscard]]
auto index_metric() const noexcept ->
std::optional<metric_type> {
return metric; }
340 [[nodiscard]]
auto index_pods() const noexcept ->
std::optional<uint16_t> {
return pods; }
341 [[nodiscard]]
auto index_pod_config() const noexcept ->
std::optional<pod_configuration>
345 [[nodiscard]]
auto index_shards() const noexcept ->
std::optional<uint16_t> {
return shards; }
346 [[nodiscard]]
auto index_replicas() const noexcept ->
std::optional<uint16_t> {
return replicas; }
347 [[nodiscard]]
auto index_metadata_config() const noexcept
348 ->
std::optional<
std::vector<
std::
string>>
350 return metadata_config;
352 [[nodiscard]]
auto index_source_collection() const noexcept ->
std::optional<
std::
string>
354 return source_collection;
359 uint16_t dimension{};
360 std::optional<metric_type> metric;
361 std::optional<uint16_t> pods;
362 std::optional<pod_configuration> pod_type;
363 std::optional<uint16_t> shards;
364 std::optional<uint16_t> replicas;
365 std::optional<std::vector<std::string>> metadata_config;
366 std::optional<std::string> source_collection;
368 new_index() =
default;
369 new_index(
std::string name, uint32_t dimension, std::optional<metric_type> metric,
370 std::optional<uint16_t> pods, std::optional<pod_configuration> pod_config,
371 std::optional<uint16_t> shards, std::optional<uint16_t> replicas,
373 std::optional<std::string> source_collection) noexcept
375 dimension(dimension),
381 metadata_config(
std::move(metadata_config)),
382 source_collection(
std::move(source_collection))
pod_size
Pod sizes for individual databases.
pod_type
Pod types for individual databases.
metric_type
Metric types for individual databases.
database_state
Pod states for individual databases.
operation_type
All operation types exposed by the Pinecone REST API.
Models the possibility of failure for Pinecone operations.
A snapshot of index contents.
The details of an individual database.
The status of an individual database.
The complete description of a Pinecone vector index.
The technical configuration of a single Pinecone index.
Arguments required to create a new collection.
Arguments required to create a new index.
Pod configuration for an individual index.