/*
* 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