/* * 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.DocumentModel; using Amazon.DynamoDBv2.Model; namespace Amazon.DynamoDBv2.DataModel { /// /// Context interface for using the DataModel mode of DynamoDB. /// Used to interact with the service, save/load objects, etc. /// public partial interface IDynamoDBContext : IDisposable { #region Save/serialize /// /// Serializes an object to a Document. /// /// Type to serialize as. /// Object to serialize. /// Document with attributes populated from object. Document ToDocument(T value); /// /// Serializes an object to a Document. /// /// Type to serialize as. /// Object to serialize. /// Config object which can be used to override the table used. /// Document with attributes populated from object. Document ToDocument(T value, DynamoDBOperationConfig operationConfig); #endregion #region Load/deserialize /// /// Deserializes a document to an instance of type T. /// /// Type to populate. /// Document with properties to use. /// /// Object of type T, populated with properties from the document. /// T FromDocument(Document document); /// /// Deserializes a document to an instance of type T. /// /// Type to populate. /// Document with properties to use. /// Config object which can be used to override the table used. /// /// Object of type T, populated with properties from the document. /// T FromDocument(Document document, DynamoDBOperationConfig operationConfig); /// /// Deserializes a collections of documents to a collection of instances of type T. /// /// Type to populate. /// Documents to deserialize. /// /// Collection of items of type T, each populated with properties from a corresponding document. /// IEnumerable FromDocuments(IEnumerable documents); /// /// Deserializes a collections of documents to a collection of instances of type T. /// /// Type to populate. /// Documents to deserialize. /// Config object which can be used to override the table used. /// /// Collection of items of type T, each populated with properties from a corresponding document. /// IEnumerable FromDocuments(IEnumerable documents, DynamoDBOperationConfig operationConfig); #endregion #region BatchGet #if BCL35 /// /// Creates a strongly-typed BatchGet object, allowing /// a batch-get operation against DynamoDB. /// /// Type of objects to get /// Empty strongly-typed BatchGet object BatchGet CreateBatchGet(); /// /// Creates a strongly-typed BatchGet object, allowing /// a batch-get operation against DynamoDB. /// /// Type of objects to get /// Config object which can be used to override that table used. /// Empty strongly-typed BatchGet object BatchGet CreateBatchGet(DynamoDBOperationConfig operationConfig); #else /// /// Creates a strongly-typed BatchGet object, allowing /// a batch-get operation against DynamoDB. /// /// Type of objects to get /// Config object which can be used to override that table used. /// Empty strongly-typed BatchGet object BatchGet CreateBatchGet(DynamoDBOperationConfig operationConfig = null); #endif /// /// Creates a MultiTableBatchGet object, composed of multiple /// individual BatchGet objects. /// /// Individual BatchGet objects /// Composite MultiTableBatchGet object MultiTableBatchGet CreateMultiTableBatchGet(params BatchGet[] batches); #endregion #region Batch Write #if BCL35 /// /// Creates a strongly-typed BatchWrite object, allowing /// a batch-write operation against DynamoDB. /// /// Type of objects to write /// Empty strongly-typed BatchWrite object BatchWrite CreateBatchWrite(); /// /// Creates a strongly-typed BatchWrite object, allowing /// a batch-write operation against DynamoDB. /// /// Type of objects to write /// Config object which can be used to override that table used. /// Empty strongly-typed BatchWrite object BatchWrite CreateBatchWrite(DynamoDBOperationConfig operationConfig); /// /// Creates a strongly-typed BatchWrite object, allowing /// a batch-write operation against DynamoDB. /// /// This is intended for use only when the valuesType is not known at compile-time, for example, /// when hooking into EF's ChangeTracker to record audit logs from EF into DynamoDB. /// /// In scenarios when the valuesType is known at compile-time, the /// `BatchWrite CreateBatchWrite()` method is generally preferred. /// /// The type of data which will be persisted in this batch. /// Empty strongly-typed BatchWrite object BatchWrite CreateBatchWrite(Type valuesType); /// /// Creates a strongly-typed BatchWrite object, allowing /// a batch-write operation against DynamoDB. /// /// This is intended for use only when the valuesType is not known at compile-time, for example, /// when hooking into EF's ChangeTracker to record audit logs from EF into DynamoDB. /// /// In scenarios when the valuesType is known at compile-time, the /// `BatchWrite CreateBatchWrite(DynamoDBOperationConfig operationConfig)` method is generally preferred. /// /// The type of data which will be persisted in this batch. /// Config object which can be used to override that table used. /// Empty strongly-typed BatchWrite object BatchWrite CreateBatchWrite(Type valuesType, DynamoDBOperationConfig operationConfig); #else /// /// Creates a strongly-typed BatchWrite object, allowing /// a batch-write operation against DynamoDB. /// /// Type of objects to write /// Config object which can be used to override that table used. /// Empty strongly-typed BatchWrite object BatchWrite CreateBatchWrite(DynamoDBOperationConfig operationConfig = null); /// /// Creates a strongly-typed BatchWrite object, allowing /// a batch-write operation against DynamoDB. /// /// This is intended for use only when the valuesType is not known at compile-time, for example, /// when hooking into EF's ChangeTracker to record audit logs from EF into DynamoDB. /// /// In scenarios when the valuesType is known at compile-time, the /// `BatchWrite CreateBatchWrite(DynamoDBOperationConfig operationConfig)` method is generally preferred. /// /// The type of data which will be persisted in this batch. /// Config object which can be used to override that table used. /// Empty strongly-typed BatchWrite object BatchWrite CreateBatchWrite(Type valuesType, DynamoDBOperationConfig operationConfig = null); #endif /// /// Creates a MultiTableBatchWrite object, composed of multiple /// individual BatchWrite objects. /// /// Individual BatchWrite objects /// Composite MultiTableBatchWrite object MultiTableBatchWrite CreateMultiTableBatchWrite(params BatchWrite[] batches); #endregion #region Transact Get #if BCL35 /// /// Creates a strongly-typed TransactGet object, allowing /// a transactional get operation against DynamoDB. /// /// Type of objects to get. /// Empty strongly-typed TransactGet object. TransactGet CreateTransactGet(); /// /// Creates a strongly-typed TransactGet object, allowing /// a transactional get operation against DynamoDB. /// /// Type of objects to get. /// Config object which can be used to override that table used. /// Empty strongly-typed TransactGet object. TransactGet CreateTransactGet(DynamoDBOperationConfig operationConfig); #else /// /// Creates a strongly-typed TransactGet object, allowing /// a transactional get operation against DynamoDB. /// /// Type of objects to get. /// Config object which can be used to override that table used. /// Empty strongly-typed TransactGet object. TransactGet CreateTransactGet(DynamoDBOperationConfig operationConfig = null); #endif /// /// Creates a MultiTableTransactGet object, composed of multiple /// individual TransactGet objects. /// /// Individual TransactGet objects. /// Composite MultiTableTransactGet object. MultiTableTransactGet CreateMultiTableTransactGet(params TransactGet[] transactionParts); #endregion #region Transact Write #if BCL35 /// /// Creates a strongly-typed TransactWrite object, allowing /// a transactional write operation against DynamoDB. /// /// Type of objects to write. /// Empty strongly-typed TransactWrite object. TransactWrite CreateTransactWrite(); /// /// Creates a strongly-typed TransactWrite object, allowing /// a transactional write operation against DynamoDB. /// /// Type of objects to write. /// Config object which can be used to override that table used. /// Empty strongly-typed TransactWrite object. TransactWrite CreateTransactWrite(DynamoDBOperationConfig operationConfig); #else /// /// Creates a strongly-typed TransactWrite object, allowing /// a transactional write operation against DynamoDB. /// /// Type of objects to write. /// Config object which can be used to override that table used. /// Empty strongly-typed TransactWrite object. TransactWrite CreateTransactWrite(DynamoDBOperationConfig operationConfig = null); #endif /// /// Creates a MultiTableTransactWrite object, composed of multiple /// individual TransactWrite objects. /// /// Individual TransactWrite objects. /// Composite MultiTableTransactWrite object. MultiTableTransactWrite CreateMultiTableTransactWrite(params TransactWrite[] transactionParts); #endregion } }