/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ using System; using System.Collections.Generic; using Amazon.DynamoDBv2.Model; namespace Amazon.DynamoDBv2.DocumentModel { /// /// Configuration for the Table.PutItem operation /// public class PutItemOperationConfig : IConditionalOperationConfig { /// /// The expression that is evaluated before the put is performed. If the expression evaluates to false the put /// will fail and a ConditionalCheckFailedException exception will be thrown. /// public Expression ConditionalExpression { get; set; } /// /// The expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must match the conditions /// specified in the ExpectedState. /// public ExpectedState ExpectedState { get; set; } /// /// Document representing the expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must be equal /// to the attributes in Expected. If an attribute in Expected /// is set to null, that attribute must not be preset on the item in DynamoDB. /// public Document Expected { get; set; } /// /// Flag specifying what values should be returned. /// /// PutItem only supports ReturnValues.AllOldAttributes and ReturnValues.None /// public ReturnValues ReturnValues { get; set; } } /// /// Configuration for the Table.GetItem operation /// public class GetItemOperationConfig { /// /// List of attributes to retrieve /// public List AttributesToGet { get; set; } /// /// If set to true, this flag ensures that the most recently written data is /// returned. /// public bool ConsistentRead { get; set; } } /// /// Configuration for the Table.UpdateItem operation /// public class UpdateItemOperationConfig : IConditionalOperationConfig { /// /// The expression that is evaluated before the update is performed. If the expression evaluates to false the update /// will fail and a ConditionalCheckFailedException exception will be thrown. /// public Expression ConditionalExpression { get; set; } /// /// The expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must match the conditions /// specified in the ExpectedState. /// public ExpectedState ExpectedState { get; set; } /// /// Document representing the expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must be equal /// to the attributes in Expected. If an attribute in Expected /// is set to null, that attribute must not be preset on the item in DynamoDB. /// public Document Expected { get; set; } /// /// Flag specifying what values should be returned. /// public ReturnValues ReturnValues { get; set; } } /// /// Configuration for the Table.DeleteItem operation /// public class DeleteItemOperationConfig : IConditionalOperationConfig { /// /// The expression that is evaluated before the delete is performed. If the expression evaluates to false the delete /// will fail and a ConditionalCheckFailedException exception will be thrown. /// public Expression ConditionalExpression { get; set; } /// /// The expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must match the conditions /// specified in the ExpectedState. /// public ExpectedState ExpectedState { get; set; } /// /// Document representing the expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must be equal /// to the attributes in Expected. If an attribute in Expected /// is set to null, that attribute must not be preset on the item in DynamoDB. /// public Document Expected { get; set; } /// /// Flag specifying what values should be returned. /// /// DeleteItem only supports ReturnValues.AllOldAttributes and ReturnValues.None /// public ReturnValues ReturnValues { get; set; } } /// /// Configuration for the Table.Scan operation /// public class ScanOperationConfig { /// /// Initializes a default Table.Scan config object /// Filter is empty, Limit is Int32.MaxValue /// public ScanOperationConfig() { Filter = new ScanFilter(); Limit = Int32.MaxValue; Select = SelectValues.AllAttributes; ConditionalOperator = ConditionalOperatorValues.And; ConsistentRead = false; } /// /// List of attributes to retrieve as part of the search /// public List AttributesToGet { get; set; } /// /// If set to true, this flag ensures that the most recently written data is /// returned. /// public bool ConsistentRead { get; set; } /// /// Upper limit on the number of items scanned per request /// for matching conditions. /// public int Limit { get; set; } /// /// The expression that is evaluated for each item. Only items that pass the expression are returned. /// public Expression FilterExpression { get; set; } /// /// Filter for the search operation /// public ScanFilter Filter { get; set; } /// /// Name of the index to scan against. /// public string IndexName { get; set; } /// /// Enum specifying what data to return from query. /// public SelectValues Select { get; set; } /// /// For parallel Scan requests, TotalSegmentsrepresents the total number of segments for a table that is being scanned. Segments /// are a way to logically divide a table into equally sized portions, for the duration of the Scan request. The value of /// TotalSegments corresponds to the number of application "workers" (such as threads or processes) that will perform the parallel /// Scan. For example, if you want to scan a table using four application threads, you would specify a TotalSegments value of 4. /// The value for TotalSegments must be greater than or equal to 1, and less than or equal to 4096. If you specify a TotalSegments /// value of 1, the Scan will be sequential rather than parallel. If you specify TotalSegments, you must also specify /// Segment. /// /// /// Constraints: /// /// /// Range /// 1 - 4096 /// /// /// /// public int TotalSegments { get; set; } /// /// For parallel Scan requests, Segment identifies an individual segment to be scanned by an application "worker" (such as a /// thread or a process). Each worker issues a Scan request with a distinct value for the segment it will scan. Segment IDs are /// zero-based, so the first segment is always 0. For example, if you want to scan a table using four application threads, the first thread /// would specify a Segment value of 0, the second thread would specify 1, and so on. LastEvaluatedKey returned from a parallel scan /// request must be used with same Segment id in a subsequent operation. The value for Segment must be less than or equal to 0, and less /// than the value provided for TotalSegments. If you specify Segment, you must also specify TotalSegments. /// /// /// Constraints: /// /// /// Range /// 0 - 4095 /// /// /// /// public int Segment { get; set; } /// /// Whether to collect GetNextSet and GetRemaining results in Matches property. /// Default is true. If set to false, Matches will always be empty. /// public bool CollectResults { get; set; } /// /// A logical operator to apply to the conditions in the Filter property: /// AND - If all of the conditions evaluate to true, then the entire filter evaluates to true. /// OR - If at least one of the conditions evaluate to true, then the entire filter evaluates to true. /// /// Default value is AND. /// public ConditionalOperatorValues ConditionalOperator { get; set; } /// /// Pagination token corresponding to the item where the last Scan operation /// stopped, inclusive of the previous result set. Set this value to resume /// Scan operation from the next item. /// This token should be retrieved from a Search object. /// public string PaginationToken { get; set; } } /// /// Configuration for the Table.Query operation /// public class QueryOperationConfig { /// /// Initializes a default Table.Query config object /// Filter is empty, Limit is Int32.MaxValue /// public QueryOperationConfig() { Filter = new QueryFilter(); Limit = Int32.MaxValue; Select = SelectValues.AllAttributes; } /// /// The key expression that is evaluated for each item. Only items that pass the expression are returned. /// /// Both KeyExpression and FilterExpression contain ExpressionAttributeNames and ExpressionAttributeValues. /// Attribute names or values can be added to either expression and can be referenced in either expression /// statement. Conflicting attribute names or values will lead to an exception being thrown. /// /// public Expression KeyExpression { get; set; } /// /// The expression that is evaluated for each item. Only items that pass the expression are returned. /// /// Both KeyExpression and FilterExpression contain ExpressionAttributeNames and ExpressionAttributeValues. /// Attribute names or values can be added to either expression and can be referenced in either expression /// statement. Conflicting attribute names or values will lead to an exception being thrown. /// /// public Expression FilterExpression { get; set; } /// /// Filter for the search operation /// public QueryFilter Filter { get; set; } /// /// If set to true, this flag ensures that the most recently written data is /// returned. /// public bool ConsistentRead { get; set; } /// /// List of attributes to retrieve as part of the search /// public List AttributesToGet { get; set; } /// /// Upper limit on the number of items to return per request /// public int Limit { get; set; } /// /// Flag that signals if the search is traversing backwards /// public bool BackwardSearch { get; set; } /// /// Name of the index to query against. /// public string IndexName { get; set; } /// /// Enum specifying what data to return from query. /// public SelectValues Select { get; set; } /// /// Whether to collect GetNextSet and GetRemaining results in Matches property. /// Default is true. If set to false, Matches will always be empty. /// public bool CollectResults { get; set; } /// /// A logical operator to apply to the conditions in the Filter property: /// AND - If all of the conditions evaluate to true, then the entire filter evaluates to true. /// OR - If at least one of the conditions evaluate to true, then the entire filter evaluates to true. /// /// Default value is AND. /// public ConditionalOperatorValues ConditionalOperator { get; set; } /// /// Pagination token corresponding to the item where the last Query operation /// stopped, inclusive of the previous result set. Set this value to resume /// Query operation from the next item. /// This token should be retrieved from a Search object. /// public string PaginationToken { get; set; } } /// /// Interface for operations that support conditional behavior. /// interface IConditionalOperationConfig { /// /// An expression that is evaluated before the operation. If the expression evaluates to false then the operation /// will fail with a ConditionalCheckFailedException exception. /// Expression ConditionalExpression { get; set; } /// /// The expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must match the conditions /// specified in the ExpectedState. /// ExpectedState ExpectedState { get; set; } /// /// Document representing the expected state of data in DynamoDB. /// /// For the operation to succeed, the data in DynamoDB must be equal /// to the attributes in Expected. If an attribute in Expected /// is set to null, that attribute must not be preset on the item in DynamoDB. /// Document Expected { get; set; } } /// /// Configuration for a request item of the Table.DocumentTransactGet operation. /// public class TransactGetItemOperationConfig { /// /// An expression that identifies one or more attributes of an item to retrieve from the table. /// The attributes in the expression must be separated by commas. /// If no attribute names are specified, then all attributes of the item are returned. /// If any of the requested attributes are not found, they do not appear in the result. /// public Expression ProjectionExpression { get; set; } } /// /// Configuration for a request item of the Table.DocumentTransactWrite operation. /// public class TransactWriteItemOperationConfig { /// /// An expression that is evaluated before the operation. If the expression evaluates to false then the operation /// will fail with a ConditionalCheckFailedException exception. /// public Expression ConditionalExpression { get; set; } /// /// Flag specifying what values should be returned if the ConditionalExpression evaluates to false. /// public ReturnValuesOnConditionCheckFailure ReturnValuesOnConditionCheckFailure { get; set; } } }