Cppinecone
A C++ client for the Pinecone vector database
operation_type.hpp
Go to the documentation of this file.
1 #pragma once
8 
9 namespace pinecone::domain
10 {
21 enum class operation_type {
22  actions_whoami,
23 
24  index_create,
25  index_configure,
26  index_list,
27  index_describe,
28  index_delete,
29 
30  collection_create,
31  collection_list,
32  collection_describe,
33  collection_delete,
34 
35  vector_upsert,
36  vector_update,
37  vector_query,
38  vector_fetch,
39  vector_describe_index_stats,
40  vector_delete
41 };
42 
54 enum class api_type {
55  controller,
56  service
57 };
58 
65 constexpr auto op_api_type(operation_type op) -> api_type
66 {
67  switch (op) {
68  case operation_type::actions_whoami:
69  case operation_type::index_create:
70  case operation_type::index_list:
71  case operation_type::index_configure:
72  case operation_type::index_describe:
73  case operation_type::index_delete:
74  case operation_type::collection_create:
75  case operation_type::collection_list:
76  case operation_type::collection_describe:
77  case operation_type::collection_delete:
78  return api_type::controller;
79  case operation_type::vector_upsert:
80  case operation_type::vector_update:
81  case operation_type::vector_query:
82  case operation_type::vector_fetch:
83  case operation_type::vector_describe_index_stats:
84  case operation_type::vector_delete:
85  return api_type::service;
86  }
87 }
88 
95 constexpr auto op_url_fragment(operation_type op) -> char const*
96 {
97  switch (op) {
98  case operation_type::actions_whoami:
99  return "/actions/whoami";
100  case operation_type::index_create:
101  case operation_type::index_list:
102  return "/databases";
103  case operation_type::index_configure:
104  case operation_type::index_describe:
105  case operation_type::index_delete:
106  return "/databases/";
107  case operation_type::collection_create:
108  case operation_type::collection_list:
109  return "/collections";
110  case operation_type::collection_describe:
111  case operation_type::collection_delete:
112  return "/collections/";
113  case operation_type::vector_upsert:
114  return "/vectors/upsert";
115  case operation_type::vector_update:
116  return "/vectors/update";
117  case operation_type::vector_query:
118  return "/query";
119  case operation_type::vector_fetch:
120  return "/vectors/fetch";
121  case operation_type::vector_describe_index_stats:
122  return "/describe_index_stats";
123  case operation_type::vector_delete:
124  return "/vectors/delete";
125  }
126 }
127 
134 constexpr auto op_method(operation_type op) -> method
135 {
136  switch (op) {
137  case operation_type::index_create:
138  case operation_type::collection_create:
139  case operation_type::vector_upsert:
140  case operation_type::vector_update:
141  case operation_type::vector_query:
142  case operation_type::vector_describe_index_stats:
143  case operation_type::vector_delete:
144  return method::post;
145  case operation_type::actions_whoami:
146  case operation_type::index_list:
147  case operation_type::index_describe:
148  case operation_type::collection_list:
149  case operation_type::collection_describe:
150  case operation_type::vector_fetch:
151  return method::get;
152  case operation_type::index_configure:
153  return method::patch;
154  case operation_type::index_delete:
155  case operation_type::collection_delete:
156  return method::del;
157  }
158 }
159 } // namespace pinecone::domain
HTTP method definitions.
method
The API methods supported by the Pinecone API.
Definition: method.hpp:16
constexpr auto op_url_fragment(operation_type op) -> char const *
Returns the URL specialization for an operation.
constexpr auto op_api_type(operation_type op) -> api_type
Returns the API type of an operation.
operation_type
All operation types exposed by the Pinecone REST API.
constexpr auto op_method(operation_type op) -> method
Returns the HTTP method for an operation.
api_type
The API types supported by the Pinecone REST API.