23
23
namespace MongoDB . Driver . Encryption
24
24
{
25
25
/// <summary>
26
- /// //TODO
26
+ /// A builder class for creating Client-Side Field Level Encryption (CSFLE) schemas.
27
27
/// </summary>
28
28
public class CsfleSchemaBuilder
29
29
{
@@ -34,8 +34,9 @@ private CsfleSchemaBuilder()
34
34
}
35
35
36
36
/// <summary>
37
- /// //TODO
37
+ /// Creates a new instance of the <see cref="CsfleSchemaBuilder"/> and configures it using the provided action.
38
38
/// </summary>
39
+ /// <param name="configure">An action to configure the schema builder.</param>
39
40
public static CsfleSchemaBuilder Create ( Action < CsfleSchemaBuilder > configure )
40
41
{
41
42
var builder = new CsfleSchemaBuilder ( ) ;
@@ -44,8 +45,12 @@ public static CsfleSchemaBuilder Create(Action<CsfleSchemaBuilder> configure)
44
45
}
45
46
46
47
/// <summary>
47
- /// //TODO
48
+ /// Adds an encrypted collection schema for a specific collection namespace.
48
49
/// </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>
49
54
public CsfleSchemaBuilder Encrypt < T > ( string collectionNamespace , Action < EncryptedCollectionBuilder < T > > configure )
50
55
{
51
56
var builder = new EncryptedCollectionBuilder < T > ( ) ;
@@ -69,30 +74,31 @@ public IDictionary<string, BsonDocument> Build()
69
74
}
70
75
71
76
/// <summary>
72
- /// //TODO
77
+ /// A builder class for creating encrypted collection schemas.
73
78
/// </summary>
79
+ /// <typeparam name="TDocument">The type of the document in the collection.</typeparam>
74
80
public class EncryptedCollectionBuilder < TDocument >
75
81
{
76
82
private readonly BsonDocument _schema = new ( "bsonType" , "object" ) ;
77
83
private readonly RenderArgs < TDocument > _args = new ( BsonSerializer . LookupSerializer < TDocument > ( ) , BsonSerializer . SerializerRegistry ) ;
78
84
79
- /// <summary>
80
- /// //TODO
81
- /// </summary>
82
85
internal EncryptedCollectionBuilder ( )
83
86
{
84
87
}
85
88
86
89
/// <summary>
87
- /// //TODO
90
+ /// Configures encryption metadata for the collection.
88
91
/// </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>
89
95
public EncryptedCollectionBuilder < TDocument > EncryptMetadata ( Guid ? keyId = null , EncryptionAlgorithm ? algorithm = null )
90
96
{
91
97
if ( keyId is null && algorithm is null )
92
98
{
93
99
throw new ArgumentException ( "At least one of keyId or algorithm must be specified." ) ;
94
100
}
95
-
101
+
96
102
_schema [ "encryptMetadata" ] = new BsonDocument
97
103
{
98
104
{ "keyId" , ( ) => new BsonArray { new BsonBinaryData ( keyId ! . Value , GuidRepresentation . Standard ) } , keyId is not null } ,
@@ -102,8 +108,13 @@ public EncryptedCollectionBuilder<TDocument> EncryptMetadata(Guid? keyId = null,
102
108
}
103
109
104
110
/// <summary>
105
- /// //TODO
111
+ /// Adds a pattern property to the schema with encryption settings.
106
112
/// </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>
107
118
public EncryptedCollectionBuilder < TDocument > PatternProperty (
108
119
string pattern ,
109
120
BsonType bsonType ,
@@ -112,8 +123,13 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty(
112
123
=> PatternProperty ( pattern , [ bsonType ] , algorithm , keyId ) ;
113
124
114
125
/// <summary>
115
- /// //TODO
126
+ /// Adds a pattern property to the schema with encryption settings.
116
127
/// </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>
117
133
public EncryptedCollectionBuilder < TDocument > PatternProperty (
118
134
string pattern ,
119
135
IEnumerable < BsonType > bsonTypes = null ,
@@ -125,16 +141,24 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty(
125
141
}
126
142
127
143
/// <summary>
128
- /// //TODO
144
+ /// Adds a nested pattern property to the schema.
129
145
/// </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>
130
150
public EncryptedCollectionBuilder < TDocument > PatternProperty < TField > (
131
151
Expression < Func < TDocument , TField > > path ,
132
152
Action < EncryptedCollectionBuilder < TField > > configure )
133
153
=> PatternProperty ( new ExpressionFieldDefinition < TDocument , TField > ( path ) , configure ) ;
134
154
135
155
/// <summary>
136
- /// //TODO
156
+ /// Adds a nested pattern property to the schema.
137
157
/// </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>
138
162
public EncryptedCollectionBuilder < TDocument > PatternProperty < TField > (
139
163
FieldDefinition < TDocument > path ,
140
164
Action < EncryptedCollectionBuilder < TField > > configure )
@@ -149,8 +173,14 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty<TField>(
149
173
}
150
174
151
175
/// <summary>
152
- /// //TODO
176
+ /// Adds a property to the schema with encryption settings.
153
177
/// </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>
154
184
public EncryptedCollectionBuilder < TDocument > Property < TField > (
155
185
Expression < Func < TDocument , TField > > path ,
156
186
BsonType bsonType ,
@@ -159,8 +189,14 @@ public EncryptedCollectionBuilder<TDocument> Property<TField>(
159
189
=> Property ( path , [ bsonType ] , algorithm , keyId ) ;
160
190
161
191
/// <summary>
162
- /// //TODO
192
+ /// Adds a property to the schema with encryption settings.
163
193
/// </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>
164
200
public EncryptedCollectionBuilder < TDocument > Property < TField > (
165
201
Expression < Func < TDocument , TField > > path ,
166
202
IEnumerable < BsonType > bsonTypes = null ,
@@ -169,8 +205,13 @@ public EncryptedCollectionBuilder<TDocument> Property<TField>(
169
205
=> Property ( new ExpressionFieldDefinition < TDocument , TField > ( path ) , bsonTypes , algorithm , keyId ) ;
170
206
171
207
/// <summary>
172
- /// //TODO
208
+ /// Adds a property to the schema with encryption settings.
173
209
/// </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>
174
215
public EncryptedCollectionBuilder < TDocument > Property (
175
216
FieldDefinition < TDocument > path ,
176
217
BsonType bsonType ,
@@ -179,8 +220,13 @@ public EncryptedCollectionBuilder<TDocument> Property(
179
220
=> Property ( path , [ bsonType ] , algorithm , keyId ) ;
180
221
181
222
/// <summary>
182
- /// //TODO
223
+ /// Adds a property to the schema with encryption settings.
183
224
/// </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>
184
230
public EncryptedCollectionBuilder < TDocument > Property (
185
231
FieldDefinition < TDocument > path ,
186
232
IEnumerable < BsonType > bsonTypes = null ,
@@ -193,16 +239,25 @@ public EncryptedCollectionBuilder<TDocument> Property(
193
239
}
194
240
195
241
/// <summary>
196
- /// //TODO
242
+ /// Adds a nested property to the schema.
197
243
/// </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>
198
248
public EncryptedCollectionBuilder < TDocument > Property < TField > (
199
249
Expression < Func < TDocument , TField > > path ,
200
250
Action < EncryptedCollectionBuilder < TField > > configure )
201
251
=> Property ( new ExpressionFieldDefinition < TDocument , TField > ( path ) , configure ) ;
202
252
253
+
203
254
/// <summary>
204
- /// //TODO
255
+ /// Adds a nested property to the schema.
205
256
/// </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>
206
261
public EncryptedCollectionBuilder < TDocument > Property < TField > (
207
262
FieldDefinition < TDocument > path ,
208
263
Action < EncryptedCollectionBuilder < TField > > configure )
0 commit comments