15 #include <string_view>
38 using type = domain::operation_type;
40 using args = domain::operation_args<t>;
41 template <type t,
typename f>
42 using vec_args = domain::operation_args<t, f>;
66 template <net::threading_mode Mode>
81 auto api_metadata = client->request(
83 if (api_metadata.is_failed()) {
85 err <<
"Failed to construct Pinecone client due to API metadata retrieval failure: "
93 return {
"Failed to construct HTTP client; CURL seems to be somehow misconfigured"};
96 [[nodiscard]]
auto get_api_metdata() const noexcept -> util::result<types::api_metadata>
98 util::logger()->info(
"Retrieving API metadata");
102 [[nodiscard]]
auto create_index(types::new_index index)
const noexcept
103 -> util::result<types::accepted>
105 util::logger()->info(
"Creating index");
106 return _http_client->request(args<type::index_create>{_url_builder,
std::move(index)});
109 [[nodiscard]]
auto list_indexes() const noexcept -> util::result<
std::vector<
std::
string>>
111 util::logger()->info(
"Listing indices");
112 return _http_client->request(args<type::index_list>{_url_builder});
115 [[nodiscard]]
auto describe_index(std::string_view name)
const noexcept
116 -> util::result<types::database>
118 util::logger()->info(
"Describing index");
119 return _http_client->request(args<type::index_describe>{_url_builder, name});
122 [[nodiscard]]
auto configure_index(std::string_view name,
123 types::index_configuration config)
const noexcept
124 -> util::result<types::accepted>
126 util::logger()->info(
"Configuring index");
127 return _http_client->request(args<type::index_configure>(_url_builder, name, config));
130 [[nodiscard]]
auto delete_index(std::string_view name)
const noexcept
131 -> util::result<types::accepted>
133 util::logger()->info(
"Deleting index");
134 return _http_client->request(args<type::index_delete>{_url_builder, name});
137 [[nodiscard]]
auto list_collections() const noexcept -> util::result<
std::vector<
std::
string>>
139 util::logger()->info(
"Listing collections");
140 return _http_client->request(args<type::collection_list>{_url_builder});
143 [[nodiscard]]
auto describe_collection(std::string_view name)
const noexcept
144 -> util::result<types::collection>
146 util::logger()->info(
"Describing collection");
147 return _http_client->request(args<type::collection_describe>{_url_builder, name});
150 [[nodiscard]]
auto delete_collection(std::string_view name)
const noexcept
151 -> util::result<types::accepted>
153 util::logger()->info(
"Deleting collection");
154 return _http_client->request(args<type::collection_delete>{_url_builder, name});
157 [[nodiscard]]
auto create_collection(types::new_collection collection)
const noexcept
158 -> util::result<types::accepted>
160 util::logger()->info(
"Creating collection");
161 return _http_client->request(
162 args<type::collection_create>(_url_builder,
std::move(collection)));
165 [[nodiscard]]
auto describe_index_stats(std::string_view name)
const noexcept
166 -> util::result<types::index_stats>
168 util::logger()->info(
"Descriving index stats");
169 return _http_client->request(vec_args<type::vector_describe_index_stats, types::no_filter>{
170 _url_builder, name, types::filters::none()});
173 template <
typename filter>
174 [[nodiscard]]
auto query(std::string_view name, types::query<filter> query)
const noexcept
175 -> util::result<types::query_result>
177 util::logger()->info(
"Querying index");
178 return _http_client->request(
179 vec_args<type::vector_query, filter>{_url_builder, name,
std::move(query)});
182 template <
typename filter>
183 [[nodiscard]]
auto delete_vectors(std::string_view name,
184 types::delete_request<filter> req)
const noexcept
185 -> util::result<types::accepted>
187 util::logger()->info(
"Deleting vectors");
188 return _http_client->request(
189 vec_args<type::vector_delete, filter>{_url_builder, name,
std::move(req)});
192 [[nodiscard]]
auto upsert_vectors(std::string_view name, types::upsert_request req)
const noexcept
193 -> util::result<types::accepted>
195 util::logger()->info(
"Upserting vectors");
196 return _http_client->request(args<type::vector_upsert>{_url_builder, name,
std::move(req)});
199 [[nodiscard]]
auto update_vector(std::string_view name, types::update_request req)
const noexcept
200 -> util::result<types::accepted>
202 util::logger()->info(
"Updating vectors");
203 return _http_client->request(args<type::vector_update>{_url_builder, name,
std::move(req)});
207 net::url_builder _url_builder;
210 pinecone_client(net::url_builder url_builder,
214 util::logger()->info(
"Client construction completed successfully");
217 template <
typename filter>
218 [[nodiscard]]
auto describe_index_stats(std::string_view name, filter f)
const noexcept
219 -> util::result<types::index_stats>
221 return _http_client->request(
222 vec_args<type::vector_describe_index_stats, filter>{_url_builder, name,
std::move(f)});
226 using synchronous_client = pinecone_client<net::threading_mode::sync>;
A monostate sentinel type for operations that have no associated response.
User-facing arguments for networking operations.
Filters supported by complex vector API operations.
A bare-bones HTTP client implementation.
API operations providing functionality for Pinecone indices.
Native C++ type modeling the results of index operations.
Provides logging capability.
Metaprogamming infrastructure for generation of per-operation code.
Operations made available by the Pinecone API.
Models the possibility of failure for Pinecone operations.
Operation-specific arguments.
Arguments required to connect to a Pinecone server.
An HTTP client responsible for making requests to a Pinecone instance.
Constructs Pinecone API URLs.
auto set_metadata(types::api_metadata metadata) noexcept
Set the API metadata.
The Pinecone REST API client.
static auto build(net::connection_args args) -> std::variant< pinecone_client< Mode >, std::string >
Attempts to initialize a new Pinecone API client.
Constructs Pinecone API URLs.
API operations providing functionality for Pinecone vectors.
Native C++ types modeling the results of vector operations.