Loading...
Searching...
No Matches
data_key.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/data_key-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/document/value.hpp>
#include <mongocxx/v1/data_key_options.hpp> // IWYU pragma: export
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
#include <mongocxx/client_encryption-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class data_key {
public:
data_key() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() data_key(v1::data_key_options key);
explicit operator v1::data_key_options() const {
v1::data_key_options ret;
if (_master_key) {
ret.master_key(bsoncxx::v1::document::value{bsoncxx::v_noabi::to_v1(_master_key->view())});
}
ret.key_alt_names(_key_alt_names);
if (_key_material) {
ret.key_material(*_key_material);
}
return ret;
}
data_key& master_key(bsoncxx::v_noabi::document::view_or_value master_key) {
_master_key = std::move(master_key);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const& master_key() const {
return _master_key;
}
data_key& key_alt_names(std::vector<std::string> key_alt_names) {
_key_alt_names = std::move(key_alt_names);
return *this;
}
std::vector<std::string> const& key_alt_names() const {
return _key_alt_names;
}
using key_material_type = std::vector<std::uint8_t>;
data_key& key_material(key_material_type key_material) {
_key_material = std::move(key_material);
return *this;
}
bsoncxx::v_noabi::stdx::optional<key_material_type> const& key_material() {
return _key_material;
}
class internal;
private:
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _master_key;
std::vector<std::string> _key_alt_names;
bsoncxx::v_noabi::stdx::optional<key_material_type> _key_material;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::data_key from_v1(v1::data_key_options v) {
return {std::move(v)};
}
inline v1::data_key_options to_v1(v_noabi::options::data_key const& v) {
return v1::data_key_options{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::document::value
A BSON document.
Definition value.hpp:44
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
mongocxx::options::data_key::data_key
data_key()=default
Default initialization.
mongocxx::v1::data_key_options
A Data Encryption Key (DEK) for In-Use Encryption.
Definition data_key_options.hpp:48
mongocxx::v1::data_key_options::key_alt_names
data_key_options & key_alt_names(std::vector< std::string > v)
Set the "keyAltNames" field.
mongocxx::v1::data_key_options::key_material
data_key_options & key_material(key_material_type v)
Set the "keyMaterial" field.
mongocxx::v1::data_key_options::master_key
data_key_options & master_key(bsoncxx::v1::document::value v)
Set the "masterKey" field.
mongocxx::v_noabi::options::data_key
Used by mongocxx::v_noabi::client_encryption::create_data_key.
Definition data_key.hpp:45
mongocxx::v_noabi::options::data_key::data_key_options
operator v1::data_key_options() const
Convert to the mongocxx::v1 equivalent.
Definition data_key.hpp:60
mongocxx::v_noabi::options::data_key::master_key
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & master_key() const
Gets the master key.
Definition data_key.hpp:152
mongocxx::v_noabi::options::data_key::key_alt_names
std::vector< std::string > const & key_alt_names() const
Gets the alternate names for the data key.
Definition data_key.hpp:181
mongocxx::v_noabi::options::data_key::data_key
data_key()=default
Default initialization.
mongocxx::v_noabi::options::data_key::key_material
bsoncxx::v_noabi::stdx::optional< key_material_type > const & key_material()
Gets the keyMaterial as binary data.
Definition data_key.hpp:223
mongocxx::v_noabi::options::data_key::key_alt_names
data_key & key_alt_names(std::vector< std::string > key_alt_names)
Sets an optional list of string alternate names used to reference the key. If a key is created with a...
Definition data_key.hpp:170
mongocxx::v_noabi::options::data_key::key_material_type
std::vector< std::uint8_t > key_material_type
Represents binary data used to represent key material.
Definition data_key.hpp:188
mongocxx::v_noabi::options::data_key::master_key
data_key & master_key(bsoncxx::v_noabi::document::view_or_value master_key)
Sets a KMS-specific key used to encrypt the new data key.
Definition data_key.hpp:141
mongocxx::v_noabi::options::data_key::key_material
data_key & key_material(key_material_type key_material)
Sets the binary data for the key material.
Definition data_key.hpp:209
data_key-fwd.hpp
Declares mongocxx::v_noabi::options::data_key.
data_key_options.hpp
Provides mongocxx::v1::data_key_options.
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
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::document::view_or_value
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
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.
value.hpp
Provides bsoncxx::v1::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.
client_encryption-fwd.hpp
Declares mongocxx::v_noabi::client_encryption.