MongoDB C++ Driver  mongocxx-3.6.0
auto_encryption.hpp
1 // Copyright 2020 MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <bsoncxx/document/view_or_value.hpp>
18 #include <bsoncxx/stdx/optional.hpp>
19 #include <mongocxx/stdx.hpp>
20 
21 #include <mongocxx/config/prelude.hpp>
22 
23 namespace mongocxx {
24 MONGOCXX_INLINE_NAMESPACE_BEGIN
25 
26 class client;
27 class pool;
28 
29 namespace options {
30 
34 class MONGOCXX_API auto_encryption {
35  public:
39  auto_encryption() noexcept;
40 
57  auto_encryption& key_vault_client(client* client);
58 
65  const stdx::optional<client*>& key_vault_client() const;
66 
87  auto_encryption& key_vault_pool(pool* pool);
88 
95  const stdx::optional<pool*>& key_vault_pool() const;
96 
113  using ns_pair = std::pair<std::string, std::string>;
114  auto_encryption& key_vault_namespace(ns_pair ns);
115 
123  const stdx::optional<ns_pair>& key_vault_namespace() const;
124 
149  auto_encryption& kms_providers(bsoncxx::document::view_or_value kms_providers);
150 
157  const stdx::optional<bsoncxx::document::view_or_value>& kms_providers() const;
158 
181  auto_encryption& schema_map(bsoncxx::document::view_or_value schema_map);
182 
189  const stdx::optional<bsoncxx::document::view_or_value>& schema_map() const;
190 
203  auto_encryption& bypass_auto_encryption(bool should_bypass);
204 
211  bool bypass_auto_encryption() const;
212 
236 
243  const stdx::optional<bsoncxx::document::view_or_value>& extra_options() const;
244 
245  private:
246  friend class mongocxx::client;
247  friend class mongocxx::pool;
248 
249  MONGOCXX_PRIVATE void* convert() const;
250 
251  bool _bypass;
252  stdx::optional<mongocxx::client*> _key_vault_client;
253  stdx::optional<mongocxx::pool*> _key_vault_pool;
254  stdx::optional<ns_pair> _key_vault_namespace;
255  stdx::optional<bsoncxx::document::view_or_value> _kms_providers;
256  stdx::optional<bsoncxx::document::view_or_value> _schema_map;
257  stdx::optional<bsoncxx::document::view_or_value> _extra_options;
258 };
259 
260 } // namespace options
261 MONGOCXX_INLINE_NAMESPACE_END
262 } // namespace mongocxx
mongocxx::options::client
Class representing the optional arguments to a MongoDB driver client object.
Definition: client.hpp:35
mongocxx::pool
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:47
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::options::pool
Class representing the optional arguments to a MongoDB driver pool object.
Definition: pool.hpp:29
bsoncxx::view_or_value
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:30
mongocxx::client
Class representing a client connection to MongoDB.
Definition: client.hpp:58
mongocxx::options::auto_encryption
Class representing options for automatic client-side encryption.
Definition: auto_encryption.hpp:34
mongocxx::options::auto_encryption::ns_pair
std::pair< std::string, std::string > ns_pair
Sets the namespace to use to access the key vault collection, which contains all data keys used for e...
Definition: auto_encryption.hpp:113