Skip to content

Commit 68da7e2

Browse files
committed
Added docs
1 parent 30c0877 commit 68da7e2

File tree

1 file changed

+74
-19
lines changed

1 file changed

+74
-19
lines changed

src/MongoDB.Driver.Encryption/CsfleSchemaBuilder.cs

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace MongoDB.Driver.Encryption
2424
{
2525
/// <summary>
26-
/// //TODO
26+
/// A builder class for creating Client-Side Field Level Encryption (CSFLE) schemas.
2727
/// </summary>
2828
public class CsfleSchemaBuilder
2929
{
@@ -34,8 +34,9 @@ private CsfleSchemaBuilder()
3434
}
3535

3636
/// <summary>
37-
/// //TODO
37+
/// Creates a new instance of the <see cref="CsfleSchemaBuilder"/> and configures it using the provided action.
3838
/// </summary>
39+
/// <param name="configure">An action to configure the schema builder.</param>
3940
public static CsfleSchemaBuilder Create(Action<CsfleSchemaBuilder> configure)
4041
{
4142
var builder = new CsfleSchemaBuilder();
@@ -44,8 +45,12 @@ public static CsfleSchemaBuilder Create(Action<CsfleSchemaBuilder> configure)
4445
}
4546

4647
/// <summary>
47-
/// //TODO
48+
/// Adds an encrypted collection schema for a specific collection namespace.
4849
/// </summary>
50+
/// <typeparam name="T">The type of the document in the collection.</typeparam>
51+
/// <param name="collectionNamespace">The namespace of the collection.</param>
52+
/// <param name="configure">An action to configure the encrypted collection builder.</param>
53+
/// <returns>The current <see cref="CsfleSchemaBuilder"/> instance.</returns>
4954
public CsfleSchemaBuilder Encrypt<T>(string collectionNamespace, Action<EncryptedCollectionBuilder<T>> configure)
5055
{
5156
var builder = new EncryptedCollectionBuilder<T>();
@@ -69,30 +74,31 @@ public IDictionary<string, BsonDocument> Build()
6974
}
7075

7176
/// <summary>
72-
/// //TODO
77+
/// A builder class for creating encrypted collection schemas.
7378
/// </summary>
79+
/// <typeparam name="TDocument">The type of the document in the collection.</typeparam>
7480
public class EncryptedCollectionBuilder<TDocument>
7581
{
7682
private readonly BsonDocument _schema = new("bsonType", "object");
7783
private readonly RenderArgs<TDocument> _args = new(BsonSerializer.LookupSerializer<TDocument>(), BsonSerializer.SerializerRegistry);
7884

79-
/// <summary>
80-
/// //TODO
81-
/// </summary>
8285
internal EncryptedCollectionBuilder()
8386
{
8487
}
8588

8689
/// <summary>
87-
/// //TODO
90+
/// Configures encryption metadata for the collection.
8891
/// </summary>
92+
/// <param name="keyId">The key ID to use for encryption.</param>
93+
/// <param name="algorithm">The encryption algorithm to use.</param>
94+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
8995
public EncryptedCollectionBuilder<TDocument> EncryptMetadata(Guid? keyId = null, EncryptionAlgorithm? algorithm = null)
9096
{
9197
if (keyId is null && algorithm is null)
9298
{
9399
throw new ArgumentException("At least one of keyId or algorithm must be specified.");
94100
}
95-
101+
96102
_schema["encryptMetadata"] = new BsonDocument
97103
{
98104
{ "keyId", () => new BsonArray { new BsonBinaryData(keyId!.Value, GuidRepresentation.Standard) }, keyId is not null },
@@ -102,8 +108,13 @@ public EncryptedCollectionBuilder<TDocument> EncryptMetadata(Guid? keyId = null,
102108
}
103109

104110
/// <summary>
105-
/// //TODO
111+
/// Adds a pattern property to the schema with encryption settings.
106112
/// </summary>
113+
/// <param name="pattern">The regex pattern for the property.</param>
114+
/// <param name="bsonType">The BSON type of the property.</param>
115+
/// <param name="algorithm">The encryption algorithm to use.</param>
116+
/// <param name="keyId">The key ID to use for encryption.</param>
117+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
107118
public EncryptedCollectionBuilder<TDocument> PatternProperty(
108119
string pattern,
109120
BsonType bsonType,
@@ -112,8 +123,13 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty(
112123
=> PatternProperty(pattern, [bsonType], algorithm, keyId);
113124

114125
/// <summary>
115-
/// //TODO
126+
/// Adds a pattern property to the schema with encryption settings.
116127
/// </summary>
128+
/// <param name="pattern">The regex pattern for the property.</param>
129+
/// <param name="bsonTypes">The BSON types of the property.</param>
130+
/// <param name="algorithm">The encryption algorithm to use.</param>
131+
/// <param name="keyId">The key ID to use for encryption.</param>
132+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
117133
public EncryptedCollectionBuilder<TDocument> PatternProperty(
118134
string pattern,
119135
IEnumerable<BsonType> bsonTypes = null,
@@ -125,16 +141,24 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty(
125141
}
126142

127143
/// <summary>
128-
/// //TODO
144+
/// Adds a nested pattern property to the schema.
129145
/// </summary>
146+
/// <typeparam name="TField">The type of the nested field.</typeparam>
147+
/// <param name="path">The field.</param>
148+
/// <param name="configure">An action to configure the nested builder.</param>
149+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
130150
public EncryptedCollectionBuilder<TDocument> PatternProperty<TField>(
131151
Expression<Func<TDocument, TField>> path,
132152
Action<EncryptedCollectionBuilder<TField>> configure)
133153
=> PatternProperty(new ExpressionFieldDefinition<TDocument, TField>(path), configure);
134154

135155
/// <summary>
136-
/// //TODO
156+
/// Adds a nested pattern property to the schema.
137157
/// </summary>
158+
/// <typeparam name="TField">The type of the nested field.</typeparam>
159+
/// <param name="path">The field.</param>
160+
/// <param name="configure">An action to configure the nested builder.</param>
161+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
138162
public EncryptedCollectionBuilder<TDocument> PatternProperty<TField>(
139163
FieldDefinition<TDocument> path,
140164
Action<EncryptedCollectionBuilder<TField>> configure)
@@ -149,8 +173,14 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty<TField>(
149173
}
150174

151175
/// <summary>
152-
/// //TODO
176+
/// Adds a property to the schema with encryption settings.
153177
/// </summary>
178+
/// <typeparam name="TField">The type of the field.</typeparam>
179+
/// <param name="path">The field.</param>
180+
/// <param name="bsonType">The BSON type of the property.</param>
181+
/// <param name="algorithm">The encryption algorithm to use.</param>
182+
/// <param name="keyId">The key ID to use for encryption.</param>
183+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
154184
public EncryptedCollectionBuilder<TDocument> Property<TField>(
155185
Expression<Func<TDocument, TField>> path,
156186
BsonType bsonType,
@@ -159,8 +189,14 @@ public EncryptedCollectionBuilder<TDocument> Property<TField>(
159189
=> Property(path, [bsonType], algorithm, keyId);
160190

161191
/// <summary>
162-
/// //TODO
192+
/// Adds a property to the schema with encryption settings.
163193
/// </summary>
194+
/// <typeparam name="TField">The type of the field.</typeparam>
195+
/// <param name="path">The field.</param>
196+
/// <param name="bsonTypes">The BSON types of the property.</param>
197+
/// <param name="algorithm">The encryption algorithm to use.</param>
198+
/// <param name="keyId">The key ID to use for encryption.</param>
199+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
164200
public EncryptedCollectionBuilder<TDocument> Property<TField>(
165201
Expression<Func<TDocument, TField>> path,
166202
IEnumerable<BsonType> bsonTypes = null,
@@ -169,8 +205,13 @@ public EncryptedCollectionBuilder<TDocument> Property<TField>(
169205
=> Property(new ExpressionFieldDefinition<TDocument, TField>(path), bsonTypes, algorithm, keyId);
170206

171207
/// <summary>
172-
/// //TODO
208+
/// Adds a property to the schema with encryption settings.
173209
/// </summary>
210+
/// <param name="path">The field.</param>
211+
/// <param name="bsonType">The BSON type of the property.</param>
212+
/// <param name="algorithm">The encryption algorithm to use.</param>
213+
/// <param name="keyId">The key ID to use for encryption.</param>
214+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
174215
public EncryptedCollectionBuilder<TDocument> Property(
175216
FieldDefinition<TDocument> path,
176217
BsonType bsonType,
@@ -179,8 +220,13 @@ public EncryptedCollectionBuilder<TDocument> Property(
179220
=> Property(path, [bsonType], algorithm, keyId);
180221

181222
/// <summary>
182-
/// //TODO
223+
/// Adds a property to the schema with encryption settings.
183224
/// </summary>
225+
/// <param name="path">The field.</param>
226+
/// <param name="bsonTypes">The BSON types of the property.</param>
227+
/// <param name="algorithm">The encryption algorithm to use.</param>
228+
/// <param name="keyId">The key ID to use for encryption.</param>
229+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
184230
public EncryptedCollectionBuilder<TDocument> Property(
185231
FieldDefinition<TDocument> path,
186232
IEnumerable<BsonType> bsonTypes = null,
@@ -193,16 +239,25 @@ public EncryptedCollectionBuilder<TDocument> Property(
193239
}
194240

195241
/// <summary>
196-
/// //TODO
242+
/// Adds a nested property to the schema.
197243
/// </summary>
244+
/// <typeparam name="TField">The type of the nested field.</typeparam>
245+
/// <param name="path">The field.</param>
246+
/// <param name="configure">An action to configure the nested builder.</param>
247+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
198248
public EncryptedCollectionBuilder<TDocument> Property<TField>(
199249
Expression<Func<TDocument, TField>> path,
200250
Action<EncryptedCollectionBuilder<TField>> configure)
201251
=> Property(new ExpressionFieldDefinition<TDocument, TField>(path), configure);
202252

253+
203254
/// <summary>
204-
/// //TODO
255+
/// Adds a nested property to the schema.
205256
/// </summary>
257+
/// <typeparam name="TField">The type of the nested field.</typeparam>
258+
/// <param name="path">The field.</param>
259+
/// <param name="configure">An action to configure the nested builder.</param>
260+
/// <returns>The current <see cref="EncryptedCollectionBuilder{TDocument}"/> instance.</returns>
206261
public EncryptedCollectionBuilder<TDocument> Property<TField>(
207262
FieldDefinition<TDocument> path,
208263
Action<EncryptedCollectionBuilder<TField>> configure)

0 commit comments

Comments
 (0)