using Amazon.DynamoDBv2.DocumentModel; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Amazon.DynamoDb.Wrapper.Interfaces { /// /// Interface to provide DynamoDB Operations. This uses object persistence model that enables you to map your client-side classes to Amazon DynamoDB tables /// public interface IDynamoDBGenericRepository where TEntity : class { /// /// Retrieves an item from a table. It uses the primary key made up of Partition key ///The method requires only the primary key of the item you want to retrieve. /// /// partitionKey of the item to be retrieved /// A cancellation token that can be used by other objects or threads to receive /// notice of cancellation. /// Returns the entity retrieved from Amazon DynamoDB Task GetByPrimaryKeyAsync(object partitionKey); /// /// Retrieves an item from a table. It uses the primary key made up of Partition key and sort key ///The method requires only the primary key of the item you want to retrieve. /// /// partitionKey of the item to be retrieved /// sortKey of the item to be retrieved /// Returns the entity retrieved from Amazon DynamoDB Task GetByPrimaryKeyAsync(object partitionKey, object sortKey); /// /// Saves the specified object in the table /// If the primary key specified in the input object doesn't exist in the table, the method adds a new item to the table. /// /// entity to be created/updated in the table Task SaveAsync(TEntity entity); /// /// Deletes an item from the table /// The method requires the primary key of the item in the entity object you want to delete. /// /// entity to be created/updated in the table Task DeleteAsync(TEntity entity); /// /// Deletes an item from the table /// /// partition key of the item to be deleted Task DeleteAsync(object partitionKey); /// /// Deletes an item from the table /// /// partitionKey of the item to be deleted /// sortKey of the item to be deleted Task DeleteAsync(object partitionKey, object sortKey); /// /// Saves the specified object to the Amazon DynamoDB table /// Queries a table based on query parameters you provide. /// You can query a table only if it has a composite primary key (partition key and sort key). /// When querying, you must specify a partition key and a condition that applies to the sort key. /// /// queryOperationConfig object containing QueryFilter and/or Expression to be used for querying the table /// Returns the IEnumerable containing one or more entities retrieved from DynamoDB Task> QueryAsync(QueryOperationConfig queryOperationConfig); /// /// Saves the specified object to the Amazon DynamoDB table /// Queries a table based on query parameters you provide. /// You can query a table only if it has a composite primary key (partition key and sort key). /// When querying, you must specify a partition key and a condition that applies to the sort key. /// /// QueryFilter object containing QueryFilter to be used for querying the table /// Flag to signal if the search needs to traverse backwards /// Optional index name if search needs to be against the index /// Optional list of attributesToGet /// Returns the IEnumerable containing one or more entities retrieved from DynamoDB Task> QueryAsync(QueryFilter filter, bool backwardSearch = false, string indexName = "", List? attributesToGet = null); /// /// Performs an entire table scan. // You can filter scan results by specifying a scan condition. //The condition can be evaluated on any attributes in the table. /// /// filter to be used for scan /// Optional list of attributesToGet /// Returns the IEnumerable containing one or more entities retrieved from DynamoDB Task> ScanAsync(ScanFilter filter, List? attributesToGet = null); /// /// Gets the items from the table in a batch. /// A batch get operation can not return more than 100 items in a request, otherwise DynamoDB will reject entire batch operation. /// /// List of partitionKeys of the items to be retrieved /// Returns the IEnumerable containing one or more entities retrieved from DynamoDB Task> BatchGetAsync(List partitionKeys); /// /// Gets the items from the table in a batch. /// A batch get operation can not return more than 100 items in a request, otherwise DynamoDB will reject entire batch operation. /// /// List of tuple containing partition and sort keys of the items to be retrieved /// Returns the IEnumerable containing one or more entities retrieved from DynamoDB Task> BatchGetAsync(List> partitionAndSortKeys); /// /// This method puts or deletes multiple items in DynamoDB table in a batch. /// A batch can not write more than 25 items in a request, otherwise DynamoDB will reject entire batch write operation. /// /// Entities to put /// Entities to delete Task BatchWriteAsync(List entitiesToSave, List entitiesToDelete); /// /// Saves the specified object based on conditionExpression to the table /// /// entity to be created/updated in the table /// conditionExpression to specify that the item can be replaced only if the existing item has the ISBN attribute with a specific value Task SaveAsync(TEntity entity, string conditionExpression); } }