Loading...
Searching...
No Matches
encrypt.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/encrypt-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/types/value.hpp>
#include <mongocxx/v1/encrypt_options.hpp> // IWYU pragma: export
#include <cstdint>
#include <string>
#include <utility>
#include <mongocxx/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/types.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/types/bson_value/view.hpp>
#include <bsoncxx/types/bson_value/view_or_value.hpp>
#include <mongocxx/options/range.hpp>
#include <mongocxx/options/text.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class encrypt {
public:
encrypt() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() encrypt(v1::encrypt_options opts);
explicit operator v1::encrypt_options() const {
using bsoncxx::v_noabi::to_v1;
using mongocxx::v_noabi::to_v1;
v1::encrypt_options ret;
if (_key_id) {
ret.key_id(bsoncxx::v1::types::value{to_v1(*_key_id)});
}
if (_key_alt_name) {
ret.key_alt_name(*_key_alt_name);
}
if (_algorithm) {
ret.algorithm(*_algorithm);
}
if (_contention_factor) {
ret.contention_factor(*_contention_factor);
}
if (_query_type) {
ret.query_type(*_query_type);
}
if (_range_opts) {
ret.range_opts(to_v1(*_range_opts));
}
if (_text_opts) {
ret.text_opts(*_text_opts);
}
return ret;
}
encrypt& key_id(bsoncxx::v_noabi::types::bson_value::view_or_value key_id) {
_key_id = std::move(key_id);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const& key_id() const {
return _key_id;
}
encrypt& key_alt_name(std::string name) {
_key_alt_name = std::move(name);
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::string> const& key_alt_name() const {
return _key_alt_name;
}
using encryption_algorithm = v1::encrypt_options::encryption_algorithm;
using encryption_query_type = v1::encrypt_options::encryption_query_type;
encrypt& algorithm(encryption_algorithm algorithm) {
_algorithm = algorithm;
return *this;
}
bsoncxx::v_noabi::stdx::optional<encryption_algorithm> const& algorithm() const {
return _algorithm;
}
encrypt& contention_factor(std::int64_t contention_factor) {
_contention_factor = contention_factor;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::int64_t> const& contention_factor() const {
return _contention_factor;
}
encrypt& query_type(encryption_query_type query_type) {
_query_type = query_type;
return *this;
}
bsoncxx::v_noabi::stdx::optional<encryption_query_type> const& query_type() const {
return _query_type;
}
encrypt& range_opts(options::range opts) {
_range_opts = std::move(opts);
return *this;
}
bsoncxx::v_noabi::stdx::optional<options::range> const& range_opts() const {
return _range_opts;
}
encrypt& text_opts(v1::text_options opts) {
_text_opts = std::move(opts);
return *this;
}
bsoncxx::v_noabi::stdx::optional<v1::text_options> const& text_opts() const {
return _text_opts;
}
class internal;
private:
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> _key_id;
bsoncxx::v_noabi::stdx::optional<std::string> _key_alt_name;
bsoncxx::v_noabi::stdx::optional<encryption_algorithm> _algorithm;
bsoncxx::v_noabi::stdx::optional<std::int64_t> _contention_factor;
bsoncxx::v_noabi::stdx::optional<encryption_query_type> _query_type;
bsoncxx::v_noabi::stdx::optional<options::range> _range_opts;
bsoncxx::v_noabi::stdx::optional<v1::text_options> _text_opts;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::encrypt from_v1(v1::encrypt_options v) {
return {std::move(v)};
}
inline v1::encrypt_options to_v1(v_noabi::options::encrypt const& v) {
return v1::encrypt_options{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v1::types::value
A union of BSON type values.
Definition value.hpp:52
mongocxx::options::encrypt::encrypt
encrypt()=default
Default initialization.
mongocxx::v1::encrypt_options
Options related to explicit encryption for In-Use Encryption.
Definition encrypt_options.hpp:57
mongocxx::v1::encrypt_options::algorithm
encrypt_options & algorithm(encryption_algorithm v)
Set the "algorithm" field.
mongocxx::v1::encrypt_options::query_type
encrypt_options & query_type(encryption_query_type v)
Set the "queryType" field.
mongocxx::v1::encrypt_options::key_alt_name
encrypt_options & key_alt_name(std::string v)
Set the "keyAltName" field.
mongocxx::v1::encrypt_options::text_opts
encrypt_options & text_opts(v1::text_options v)
Set the "textOpts" field.
mongocxx::v1::encrypt_options::key_id
encrypt_options & key_id(bsoncxx::v1::types::value v)
Set the "keyId" field.
mongocxx::v1::encrypt_options::contention_factor
encrypt_options & contention_factor(std::int64_t v)
Set the "contentionFactor" field.
mongocxx::v1::encrypt_options::range_opts
encrypt_options & range_opts(v1::range_options v)
Set the "rangeOpts" field.
mongocxx::v1::encrypt_options::encryption_algorithm
encryption_algorithm
An encryption algorithm.
Definition encrypt_options.hpp:72
mongocxx::v1::encrypt_options::encryption_query_type
encryption_query_type
A query type.
Definition encrypt_options.hpp:93
mongocxx::v1::text_options
Options related to text queries for Queryable Encryption.
Definition text_options.hpp:48
mongocxx::v_noabi::options::encrypt
Used by mongocxx::v_noabi::client_encryption.
Definition encrypt.hpp:48
mongocxx::v_noabi::options::encrypt::key_alt_name
bsoncxx::v_noabi::stdx::optional< std::string > const & key_alt_name() const
Gets the current key alt name.
Definition encrypt.hpp:156
mongocxx::v_noabi::options::encrypt::encrypt_options
operator v1::encrypt_options() const
Convert to the mongocxx::v1 equivalent.
Definition encrypt.hpp:63
mongocxx::v_noabi::options::encrypt::key_id
encrypt & key_id(bsoncxx::v_noabi::types::bson_value::view_or_value key_id)
Sets the key to use for this encryption operation. A key id can be used instead of a key alt name.
Definition encrypt.hpp:117
mongocxx::v_noabi::options::encrypt::text_opts
bsoncxx::v_noabi::stdx::optional< v1::text_options > const & text_opts() const
Gets the current text options.
Definition encrypt.hpp:280
mongocxx::v_noabi::options::encrypt::algorithm
encrypt & algorithm(encryption_algorithm algorithm)
Sets the algorithm to use for encryption.
Definition encrypt.hpp:188
mongocxx::v_noabi::options::encrypt::key_alt_name
encrypt & key_alt_name(std::string name)
Sets a name by which to lookup a key from the key vault collection to use for this encryption operati...
Definition encrypt.hpp:145
mongocxx::v_noabi::options::encrypt::encryption_query_type
v1::encrypt_options::encryption_query_type encryption_query_type
queryType only applies when algorithm is "indexed" or "range". It is an error to set queryType when a...
Definition encrypt.hpp:170
mongocxx::v_noabi::options::encrypt::query_type
encrypt & query_type(encryption_query_type query_type)
Sets the query type to use for encryption.
Definition encrypt.hpp:236
mongocxx::v_noabi::options::encrypt::encryption_algorithm
v1::encrypt_options::encryption_algorithm encryption_algorithm
Determines which AEAD_AES_256_CBC algorithm to use with HMAC_SHA_512 when encrypting data.
Definition encrypt.hpp:164
mongocxx::v_noabi::options::encrypt::range_opts
bsoncxx::v_noabi::stdx::optional< options::range > const & range_opts() const
Gets the current range options.
Definition encrypt.hpp:265
mongocxx::v_noabi::options::encrypt::query_type
bsoncxx::v_noabi::stdx::optional< encryption_query_type > const & query_type() const
Gets the current query type.
Definition encrypt.hpp:247
mongocxx::v_noabi::options::encrypt::contention_factor
bsoncxx::v_noabi::stdx::optional< std::int64_t > const & contention_factor() const
Gets the current contention factor.
Definition encrypt.hpp:224
mongocxx::v_noabi::options::encrypt::contention_factor
encrypt & contention_factor(std::int64_t contention_factor)
Sets the contention factor to use for encryption. contentionFactor only applies when algorithm is "In...
Definition encrypt.hpp:213
mongocxx::v_noabi::options::encrypt::range_opts
encrypt & range_opts(options::range opts)
Sets the range options to use for encryption.
Definition encrypt.hpp:254
mongocxx::v_noabi::options::encrypt::text_opts
encrypt & text_opts(v1::text_options opts)
Sets the text options to use for encryption.
Definition encrypt.hpp:272
mongocxx::v_noabi::options::encrypt::encrypt
encrypt()=default
Default initialization.
mongocxx::v_noabi::options::encrypt::algorithm
bsoncxx::v_noabi::stdx::optional< encryption_algorithm > const & algorithm() const
Gets the current algorithm.
Definition encrypt.hpp:201
mongocxx::v_noabi::options::encrypt::key_id
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & key_id() const
Gets the key_id.
Definition encrypt.hpp:128
mongocxx::v_noabi::options::range
Used by mongocxx::v_noabi::options::encrypt::range_opts.
Definition range.hpp:51
encrypt-fwd.hpp
Declares mongocxx::v_noabi::options::encrypt.
encrypt_options.hpp
Provides mongocxx::v1::encrypt_options.
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx::v_noabi::types::bson_value::view_or_value
v_noabi::view_or_value< view, value > view_or_value
Equivalent to v_noabi::view_or_value<view, value>.
Definition view_or_value.hpp:31
bsoncxx::v_noabi::to_v1
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
range.hpp
Provides mongocxx::v_noabi::options::range.
text.hpp
Provides mongocxx::text_options.
view_or_value.hpp
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
types.hpp
Provides entities used to represent BSON types.
value.hpp
Provides bsoncxx::v1::types::value.
optional.hpp
Provides std::optional-related polyfills for library API usage.
view.hpp
Provides bsoncxx::v_noabi::types::bson_value::view.
client_encryption-fwd.hpp
Declares mongocxx::v_noabi::client_encryption.