Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::KeyValueSecret Class Reference

The KeyValueSecret is a class that implements a Secret as a set of key -> values. This class can be used for most use-cases of secrets as secrets generally tend to fit in a key value map. More...

#include <duckdb.hpp>

Inheritance diagram for duckdb::KeyValueSecret:
Collaboration diagram for duckdb::KeyValueSecret:

Public Member Functions

 KeyValueSecret (const vector< string > &prefix_paths, const string &type, const string &provider, const string &name)
 KeyValueSecret (const BaseSecret &secret)
 KeyValueSecret (const KeyValueSecret &secret)
 KeyValueSecret (KeyValueSecret &&secret) noexcept
string ToString (SecretDisplayType mode=SecretDisplayType::REDACTED) const override
 Print the secret as a key value map in the format 'key1=value;key2=value2'.
void Serialize (Serializer &serializer) const override
 Serialize this secret.
Value TryGetValue (const string &key, bool error_on_missing=false) const
 Tries to get the value at key <key>, depending on error_on_missing will throw or return Value().
unique_ptr< const BaseSecret > Clone () const override
bool TryGetValue (const string &key, Value &result) const
bool TrySetValue (const string &key, const CreateSecretInput &input)
Public Member Functions inherited from duckdb::BaseSecret
 BaseSecret (vector< string > prefix_paths_p, string type_p, string provider_p, string name_p)
 BaseSecret (const BaseSecret &other)
virtual int64_t MatchScore (const string &path) const
 The score of how well this secret's scope matches the path (by default: the length of the longest matching prefix).
const vector< string > & GetScope () const
 Getters.
const string & GetType () const
const string & GetProvider () const
const string & GetName () const
bool IsSerializable () const

Static Public Member Functions

template<class TYPE>
static unique_ptr< BaseSecret > Deserialize (Deserializer &deserializer, BaseSecret base_secret)

Public Attributes

case_insensitive_tree_t< Value > secret_map
 the map of key -> values that make up the secret
case_insensitive_set_t redact_keys
 keys that are sensitive and should be redacted

Additional Inherited Members

Protected Member Functions inherited from duckdb::BaseSecret
virtual void SerializeBaseSecret (Serializer &serializer) const final
 Helper function to serialize the base BaseSecret class variables.
Protected Attributes inherited from duckdb::BaseSecret
vector< string > prefix_paths
 prefixes to which the secret applies
string type
 Type of secret.
string provider
 Provider of the secret.
string name
 Name of the secret.
bool serializable
 Whether the secret can be serialized/deserialized.

Detailed Description

The KeyValueSecret is a class that implements a Secret as a set of key -> values. This class can be used for most use-cases of secrets as secrets generally tend to fit in a key value map.

Constructor & Destructor Documentation

◆ KeyValueSecret() [1/4]

duckdb::KeyValueSecret::KeyValueSecret ( const vector< string > & prefix_paths,
const string & type,
const string & provider,
const string & name )
inline
53277 : BaseSecret(prefix_paths, type, provider, name) {
53278 D_ASSERT(!type.empty());
53279 serializable = true;
53280 }
string type
Type of secret.
Definition duckdb.hpp:53263
string provider
Provider of the secret.
Definition duckdb.hpp:53265
vector< string > prefix_paths
prefixes to which the secret applies
Definition duckdb.hpp:53260
string name
Name of the secret.
Definition duckdb.hpp:53267
bool serializable
Whether the secret can be serialized/deserialized.
Definition duckdb.hpp:53269

◆ KeyValueSecret() [2/4]

duckdb::KeyValueSecret::KeyValueSecret ( const BaseSecret & secret)
inlineexplicit
53282 : BaseSecret(secret.GetScope(), secret.GetType(), secret.GetProvider(), secret.GetName()) {
53283 serializable = true;
53284 };

◆ KeyValueSecret() [3/4]

duckdb::KeyValueSecret::KeyValueSecret ( const KeyValueSecret & secret)
inline
53286 : BaseSecret(secret.GetScope(), secret.GetType(), secret.GetProvider(), secret.GetName()) {
53287 secret_map = secret.secret_map;
53288 redact_keys = secret.redact_keys;
53289 serializable = true;
53290 };
case_insensitive_tree_t< Value > secret_map
the map of key -> values that make up the secret
Definition duckdb.hpp:53351
case_insensitive_set_t redact_keys
keys that are sensitive and should be redacted
Definition duckdb.hpp:53353

◆ KeyValueSecret() [4/4]

duckdb::KeyValueSecret::KeyValueSecret ( KeyValueSecret && secret)
inlinenoexcept
53292 : BaseSecret(std::move(secret.prefix_paths), std::move(secret.type), std::move(secret.provider),
53293 std::move(secret.name)) {
53294 secret_map = std::move(secret.secret_map);
53295 redact_keys = std::move(secret.redact_keys);
53296 serializable = true;
53297 };

Member Function Documentation

◆ ToString()

string duckdb::KeyValueSecret::ToString ( SecretDisplayType mode = SecretDisplayType::REDACTED) const
overridevirtual

Print the secret as a key value map in the format 'key1=value;key2=value2'.

Reimplemented from duckdb::BaseSecret.

299903 {
299904 string result;
299905
299906 result += "name=" + name + ";";
299907 result += "type=" + type + ";";
299908 result += "provider=" + provider + ";";
299909 result += string("serializable=") + (serializable ? "true" : "false") + ";";
299910 result += "scope=";
299911 for (const auto &scope_it : prefix_paths) {
299912 result += scope_it + ",";
299913 }
299914 result = result.substr(0, result.size() - 1);
299915 result += ";";
299916 for (auto it = secret_map.begin(); it != secret_map.end(); it++) {
299917 result.append(it->first);
299918 result.append("=");
299919 if (mode == SecretDisplayType::REDACTED && redact_keys.find(it->first) != redact_keys.end()) {
299920 result.append("redacted");
299921 } else {
299922 result.append(it->second.ToString());
299923 }
299924 if (it != --secret_map.end()) {
299925 result.append(";");
299926 }
299927 }
299928
299929 return result;
299930}

◆ Serialize()

void duckdb::KeyValueSecret::Serialize ( Serializer & serializer) const
overridevirtual

Serialize this secret.

Reimplemented from duckdb::BaseSecret.

299933 {
299935
299936 vector<Value> map_values;
299937 for (auto it = secret_map.begin(); it != secret_map.end(); it++) {
299938 child_list_t<Value> map_struct;
299939 map_struct.push_back(make_pair("key", Value(it->first)));
299940 map_struct.push_back(make_pair("value", Value(it->second)));
299941 map_values.push_back(Value::STRUCT(map_struct));
299942 }
299943
299944 // Warning: the secret map is serialized into a single MAP value with type ANY
299945 auto map_type = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::ANY);
299946 auto map = Value::MAP(ListType::GetChildType(map_type), map_values);
299947 serializer.WriteProperty(201, "secret_map", map);
299948
299949 vector<Value> redact_key_values;
299950 for (auto it = redact_keys.begin(); it != redact_keys.end(); it++) {
299951 redact_key_values.push_back(*it);
299952 }
299953 auto list = Value::LIST(LogicalType::VARCHAR, redact_key_values);
299954 serializer.WriteProperty(202, "redact_keys", list);
299955}
virtual void SerializeBaseSecret(Serializer &serializer) const final
Helper function to serialize the base BaseSecret class variables.
Definition duckdb.cpp:299887
static DUCKDB_API Value MAP(const LogicalType &child_type, vector< Value > values)
Create a map value with the given entries.
Definition duckdb.cpp:132466
static DUCKDB_API Value LIST(const LogicalType &child_type, vector< Value > values)
Create a list value with the given entries.
Definition duckdb.cpp:132555
static DUCKDB_API Value STRUCT(child_list_t< Value > values)
Create a struct value with given list of entries.
Definition duckdb.cpp:132434
Here is the call graph for this function:

◆ TryGetValue() [1/2]

Value duckdb::KeyValueSecret::TryGetValue ( const string & key,
bool error_on_missing = false ) const

Tries to get the value at key <key>, depending on error_on_missing will throw or return Value().

299957 {
299958 auto lookup = secret_map.find(key);
299959 if (lookup == secret_map.end()) {
299960 if (error_on_missing) {
299961 throw InternalException("Failed to fetch key '%s' from secret '%s' of type '%s'", key, name, type);
299962 }
299963 return Value();
299964 }
299965
299966 return lookup->second;
299967}

◆ Deserialize()

template<class TYPE>
unique_ptr< BaseSecret > duckdb::KeyValueSecret::Deserialize ( Deserializer & deserializer,
BaseSecret base_secret )
inlinestatic
53308 {
53309 auto result = make_uniq<TYPE>(base_secret);
53310 Value secret_map_value;
53311 deserializer.ReadProperty(201, "secret_map", secret_map_value);
53312
53313 for (const auto &entry : ListValue::GetChildren(secret_map_value)) {
53314 auto kv_struct = StructValue::GetChildren(entry);
53315 result->secret_map[kv_struct[0].ToString()] = kv_struct[1];
53316 }
53317
53318 Value redact_set_value;
53319 deserializer.ReadProperty(202, "redact_keys", redact_set_value);
53320 for (const auto &entry : ListValue::GetChildren(redact_set_value)) {
53321 result->redact_keys.insert(entry.ToString());
53322 }
53323
53324 return duckdb::unique_ptr_cast<TYPE, BaseSecret>(std::move(result));
53325 }

◆ Clone()

unique_ptr< const BaseSecret > duckdb::KeyValueSecret::Clone ( ) const
inlineoverridevirtual

Reimplemented from duckdb::BaseSecret.

53327 {
53328 return make_uniq<KeyValueSecret>(*this);
53329 }

◆ TryGetValue() [2/2]

bool duckdb::KeyValueSecret::TryGetValue ( const string & key,
Value & result ) const
inline
53332 {
53333 auto lookup = secret_map.find(key);
53334 if (lookup == secret_map.end()) {
53335 return false;
53336 }
53337 result = lookup->second;
53338 return true;
53339 }

◆ TrySetValue()

bool duckdb::KeyValueSecret::TrySetValue ( const string & key,
const CreateSecretInput & input )
inline
53341 {
53342 auto lookup = input.options.find(key);
53343 if (lookup != input.options.end()) {
53344 secret_map[key] = lookup->second;
53345 return true;
53346 }
53347 return false;
53348 }

The documentation for this class was generated from the following files: