Skip to content

Commit 2a01164

Browse files
committed
wip request objects
1 parent 623dc26 commit 2a01164

File tree

2 files changed

+214
-0
lines changed

2 files changed

+214
-0
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
using System.Collections.Generic;
2+
using Amazon.DynamoDBv2.DocumentModel;
3+
4+
namespace Amazon.DynamoDBv2.DataModel
5+
{
6+
/// <summary>
7+
/// Base class for requests that perform operations on a document in DynamoDB.
8+
/// </summary>
9+
public abstract class DocumentOperationRequest
10+
{
11+
//"ReturnConsumedCapacity"
12+
}
13+
14+
/// <summary>
15+
/// Represents a request to update an item in a DynamoDB table using the Document Model.
16+
/// </summary>
17+
public class UpdateItemDocumentOperationRequest : DocumentOperationRequest
18+
{
19+
/// <summary>
20+
/// Gets or sets the key identifying the item in the table.
21+
/// </summary>
22+
public IDictionary<string, DynamoDBEntry> Key { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the attributes to be updated in the item.
26+
/// </summary>
27+
public Document Document { get; set; }
28+
29+
/// <summary>
30+
/// Gets or sets the update expression specifying how attributes should be updated.
31+
/// </summary>
32+
public Expression UpdateExpression { get; set; }
33+
34+
/// <summary>
35+
/// The expression that is evaluated before the update is performed. If the expression evaluates to false the update
36+
/// will fail and a ConditionalCheckFailedException exception will be thrown.
37+
/// </summary>
38+
public Expression ConditionalExpression { get; set; }
39+
40+
/// <summary>
41+
/// Flag specifying what values should be returned.
42+
/// </summary>
43+
public ReturnValues ReturnValues { get; set; }
44+
}
45+
46+
/// <summary>
47+
/// Represents a request to get an item from a DynamoDB table using the Document Model.
48+
/// </summary>
49+
public class GetItemDocumentOperationRequest : DocumentOperationRequest
50+
{
51+
/// <summary>
52+
/// Gets or sets the key identifying the item in the table.
53+
/// </summary>
54+
public IDictionary<string, DynamoDBEntry> Key { get; set; }
55+
56+
/// <summary>
57+
/// Gets or sets the projection expression specifying which attributes should be retrieved.
58+
/// </summary>
59+
public Expression ProjectionExpression { get; set; }
60+
61+
/// <summary>
62+
/// Gets or sets the consistent read flag.
63+
/// </summary>
64+
public bool ConsistentRead { get; set; }
65+
}
66+
67+
/// <summary>
68+
/// Represents a request to delete an item from a DynamoDB table using the Document Model.
69+
/// </summary>
70+
public class DeleteItemDocumentOperationRequest : DocumentOperationRequest
71+
{
72+
/// <summary>
73+
/// Gets or sets the key identifying the item in the table.
74+
/// </summary>
75+
public IDictionary<string, DynamoDBEntry> Key { get; set; }
76+
77+
/// <summary>
78+
/// Gets or sets the conditional expression specifying when the item should be deleted.
79+
/// </summary>
80+
public Expression ConditionalExpression { get; set; }
81+
82+
/// <summary>
83+
/// Flag specifying what values should be returned.
84+
/// </summary>
85+
public ReturnValues ReturnValues { get; set; }
86+
}
87+
88+
/// <summary>
89+
/// Represents a request to put (create or replace) an item in a DynamoDB table using the Document Model.
90+
/// </summary>
91+
public class PutItemDocumentOperationRequest : DocumentOperationRequest
92+
{
93+
/// <summary>
94+
/// Gets or sets the document to be put in the table.
95+
/// </summary>
96+
public Document Document { get; set; }
97+
98+
/// <summary>
99+
/// Gets or sets the conditional expression specifying when the item should be put.
100+
/// </summary>
101+
public Expression ConditionalExpression { get; set; }
102+
103+
/// <summary>
104+
/// Flag specifying what values should be returned.
105+
/// </summary>
106+
public ReturnValues ReturnValues { get; set; }
107+
}
108+
109+
/// <summary>
110+
/// Represents a request to scan items in a DynamoDB table using the Document Model.
111+
/// </summary>
112+
public class ScanDocumentOperationRequest : DocumentOperationRequest
113+
{
114+
/// <summary>
115+
/// Gets or sets the filter expression specifying which items should be returned.
116+
/// </summary>
117+
public Expression FilterExpression { get; set; }
118+
119+
/// <summary>
120+
/// Gets or sets the projection expression specifying which attributes should be retrieved.
121+
/// </summary>
122+
public Expression ProjectionExpression { get; set; }
123+
124+
/// <summary>
125+
/// Gets or sets the maximum number of items to return.
126+
/// </summary>
127+
public int? Limit { get; set; }
128+
129+
/// <summary>
130+
/// Gets or sets the exclusive start key for paginated scans.
131+
/// </summary>
132+
public IDictionary<string, DynamoDBEntry> ExclusiveStartKey { get; set; }
133+
134+
/// <summary>
135+
/// Gets or sets the consistent read flag.
136+
/// </summary>
137+
public bool ConsistentRead { get; set; }
138+
139+
/// <summary>
140+
/// Gets or sets the segment number for parallel scans.
141+
/// </summary>
142+
public int? Segment { get; set; }
143+
144+
/// <summary>
145+
/// Gets or sets the total number of segments for parallel scans.
146+
/// </summary>
147+
public int? TotalSegments { get; set; }
148+
}
149+
150+
/// <summary>
151+
/// Represents a request to query items in a DynamoDB table using the Document Model.
152+
/// </summary>
153+
public class QueryDocumentOperationRequest : DocumentOperationRequest
154+
{
155+
/// <summary>
156+
/// Gets or sets the key condition expression specifying which items should be returned.
157+
/// </summary>
158+
public Expression KeyConditionExpression { get; set; }
159+
160+
/// <summary>
161+
/// Gets or sets the filter expression specifying which items should be returned.
162+
/// </summary>
163+
public Expression FilterExpression { get; set; }
164+
165+
/// <summary>
166+
/// Gets or sets the projection expression specifying which attributes should be retrieved.
167+
/// </summary>
168+
public Expression ProjectionExpression { get; set; }
169+
170+
/// <summary>
171+
/// Gets or sets the exclusive start key for paginated queries.
172+
/// </summary>
173+
public IDictionary<string, DynamoDBEntry> ExclusiveStartKey { get; set; }
174+
175+
/// <summary>
176+
/// Gets or sets the maximum number of items to return.
177+
/// </summary>
178+
public int? Limit { get; set; }
179+
180+
/// <summary>
181+
/// Gets or sets the consistent read flag.
182+
/// </summary>
183+
public bool ConsistentRead { get; set; }
184+
185+
/// <summary>
186+
/// Gets or sets the index name to query against.
187+
/// </summary>
188+
public string IndexName { get; set; }
189+
190+
/// <summary>
191+
/// Gets or sets the scan direction. If true, the scan is performed in descending order.
192+
/// </summary>
193+
public bool ScanIndexForward { get; set; }
194+
}
195+
}

sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_async/Table.Async.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Collections.Generic;
2525
using System.Collections.ObjectModel;
2626
using System.Threading.Tasks;
27+
using Amazon.DynamoDBv2.DataModel;
2728
using Amazon.Runtime.Internal;
2829
using Amazon.Runtime.Telemetry.Tracing;
2930

@@ -189,6 +190,15 @@ public partial interface ITable
189190
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
190191
Task<Document> UpdateItemAsync(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config, CancellationToken cancellationToken = default(CancellationToken));
191192

193+
/// <summary>
194+
/// Initiates the asynchronous execution of the UpdateItem operation using a DocumentUpdateRequest object.
195+
/// </summary>
196+
/// <param name="request">The UpdateItemDocumentOperationRequest object containing all parameters for the update.</param>
197+
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
198+
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
199+
Task<Document> UpdateItemAsync(UpdateItemDocumentOperationRequest request, CancellationToken cancellationToken = default(CancellationToken));
200+
201+
192202

193203
#endregion
194204

@@ -441,6 +451,15 @@ public partial class Table : ITable
441451
}
442452
}
443453

454+
/// <inheritdoc/>
455+
public async Task<Document> UpdateItemAsync(UpdateItemDocumentOperationRequest request, CancellationToken cancellationToken = default(CancellationToken))
456+
{
457+
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(UpdateItemAsync));
458+
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
459+
{
460+
throw new NotImplementedException();
461+
}
462+
}
444463

445464
#endregion
446465

0 commit comments

Comments
 (0)