MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
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 <string>
18 
19 #include <bsoncxx/document/view_or_value.hpp>
20 #include <bsoncxx/stdx/optional.hpp>
21 #include <mongocxx/stdx.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 
25 namespace mongocxx {
26 inline namespace v_noabi {
27 class client;
28 class pool;
29 
30 namespace options {
31 
35 class MONGOCXX_API auto_encryption {
36  public:
40  auto_encryption() noexcept;
41 
58  auto_encryption& key_vault_client(client* client);
59 
66  const stdx::optional<client*>& key_vault_client() const;
67 
88  auto_encryption& key_vault_pool(pool* pool);
89 
96  const stdx::optional<pool*>& key_vault_pool() const;
97 
114  using ns_pair = std::pair<std::string, std::string>;
115  auto_encryption& key_vault_namespace(ns_pair ns);
116 
124  const stdx::optional<ns_pair>& key_vault_namespace() const;
125 
169  auto_encryption& kms_providers(bsoncxx::document::view_or_value kms_providers);
170 
177  const stdx::optional<bsoncxx::document::view_or_value>& kms_providers() const;
178 
201  auto_encryption& tls_opts(bsoncxx::document::view_or_value tls_opts);
202 
209  const stdx::optional<bsoncxx::document::view_or_value>& tls_opts() const;
210 
233  auto_encryption& schema_map(bsoncxx::document::view_or_value schema_map);
234 
241  const stdx::optional<bsoncxx::document::view_or_value>& schema_map() const;
242 
260  auto_encryption& encrypted_fields_map(bsoncxx::document::view_or_value encrypted_fields_map);
261 
268  const stdx::optional<bsoncxx::document::view_or_value>& encrypted_fields_map() const;
269 
282  auto_encryption& bypass_auto_encryption(bool should_bypass);
283 
290  bool bypass_auto_encryption() const;
291 
304  auto_encryption& bypass_query_analysis(bool should_bypass);
305 
312  bool bypass_query_analysis() const;
313 
363  auto_encryption& extra_options(bsoncxx::document::view_or_value extra);
364 
371  const stdx::optional<bsoncxx::document::view_or_value>& extra_options() const;
372 
373  private:
374  friend class mongocxx::client;
375  friend class mongocxx::pool;
376 
377  MONGOCXX_PRIVATE void* convert() const;
378 
379  bool _bypass;
380  bool _bypass_query_analysis;
381  stdx::optional<mongocxx::client*> _key_vault_client;
382  stdx::optional<mongocxx::pool*> _key_vault_pool;
383  stdx::optional<ns_pair> _key_vault_namespace;
384  stdx::optional<bsoncxx::document::view_or_value> _kms_providers;
385  stdx::optional<bsoncxx::document::view_or_value> _tls_opts;
386  stdx::optional<bsoncxx::document::view_or_value> _schema_map;
387  stdx::optional<bsoncxx::document::view_or_value> _encrypted_fields_map;
388  stdx::optional<bsoncxx::document::view_or_value> _extra_options;
389 };
390 
391 } // namespace options
392 } // namespace v_noabi
393 } // namespace mongocxx
394 
395 // CXX-2770: missing include of postlude header.
396 #if defined(MONGOCXX_TEST_MACRO_GUARDS_FIX_MISSING_POSTLUDE)
397 #include <mongocxx/config/postlude.hpp>
398 #endif
Class representing options for automatic client-side encryption.
Definition: auto_encryption.hpp:35
auto_encryption() noexcept
Default constructs a new auto_encryption object.
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:114
Class representing the optional arguments to a MongoDB driver client object.
Definition: client.hpp:36
Class representing the optional arguments to a MongoDB driver pool object.
Definition: pool.hpp:29
The top-level namespace for bsoncxx library entities.
Definition: element.hpp:24
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24