/* * 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 { #region Save/serialize /// /// Saves an object to DynamoDB. /// /// Uses DynamoDBContextConfig configured on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to save as. /// Object to save. void Save(T value); /// /// Saves an object to DynamoDB using passed-in configs. /// /// Passed-in config overrides DynamoDBContextConfig on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to save as. /// Object to save. /// Overriding configuration. void Save(T value, DynamoDBOperationConfig operationConfig); #endregion #region Load/deserialize /// /// Loads an object from DynamoDB for the given hash primary key. /// /// Uses DynamoDBContextConfig configured on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to populate. /// Hash key element of the target item. /// /// Object of type T, populated with properties of item loaded from DynamoDB. /// T Load(object hashKey); /// /// Loads an object from DynamoDB for the given hash primary key and using the given config. /// /// Passed-in config overrides DynamoDBContextConfig on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to populate. /// Hash key element of the target item. /// Overriding configuration. /// /// Object of type T, populated with properties of item loaded from DynamoDB. /// T Load(object hashKey, DynamoDBOperationConfig operationConfig); /// /// Loads an object from DynamoDB for the given hash-and-range primary key. /// /// Uses DynamoDBContextConfig configured on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to populate. /// Hash key element of the target item. /// Range key element of the target item. /// /// Object of type T, populated with properties of item loaded from DynamoDB. /// T Load(object hashKey, object rangeKey); /// /// Loads an object from DynamoDB for the given hash-and-range primary key and using the given config. /// /// Passed-in config overrides DynamoDBContextConfig on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to populate. /// Hash key element of the target item. /// Range key element of the target item. /// Overriding configuration. /// /// Object of type T, populated with properties of item loaded from DynamoDB. /// T Load(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig); /// /// Loads an object from DynamoDB for the given key. /// The keyObject is a partially-specified instance, where the /// hash/range properties are equal to the key of the item you /// want to load. /// /// Uses DynamoDBContextConfig configured on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to populate. /// Key object defining the the target item. /// /// Object of type T, populated with properties of item loaded from DynamoDB. /// T Load(T keyObject); /// /// Loads an object from DynamoDB for the given key and using the given config. /// The keyObject is a partially-specified instance, where the /// hash/range properties are equal to the key of the item you /// want to load. /// /// Passed-in config overrides DynamoDBContextConfig on the context. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type to populate. /// Key object defining the the target item. /// Overriding configuration. /// /// Object of type T, populated with properties of item loaded from DynamoDB. /// T Load(T keyObject, DynamoDBOperationConfig operationConfig); #endregion #region Delete /// /// Deletes an item in DynamoDB corresponding to given object. /// /// Uses DynamoDBContextConfig configured on the context. /// If SkipVersionCheck=false, will check version of object before deleting. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type of object. /// Object to delete. void Delete(T value); /// /// Deletes an item in DynamoDB corresponding to given object. /// /// Passed-in config overrides DynamoDBContextConfig on the context. /// If SkipVersionCheck=false, will check version of object before deleting. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type of object. /// Object to delete. /// Overriding configuration. void Delete(T value, DynamoDBOperationConfig operationConfig); /// /// Deletes an item in DynamoDB corresponding to a given hash primary key. /// /// No version check is done prior to delete. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type of object. /// Hash key element of the object to delete. void Delete(object hashKey); /// /// Deletes an item in DynamoDB corresponding to a given hash primary key. /// /// No version check is done prior to delete. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type of object. /// Hash key element of the object to delete. /// Config object which can be used to override that table used. void Delete(object hashKey, DynamoDBOperationConfig operationConfig); /// /// Deletes an item in DynamoDB corresponding to a given hash-and-range primary key. /// /// No version check is done prior to delete. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type of object. /// Hash key element of the object to delete. /// Range key element of the object to delete. void Delete(object hashKey, object rangeKey); /// /// Deletes an item in DynamoDB corresponding to a given hash-and-range primary key. /// /// No version check is done prior to delete. /// Type must be marked up with DynamoDBTableAttribute and at least /// one public field/property with DynamoDBHashKeyAttribute. /// /// Type of object. /// Hash key element of the object to delete. /// Range key element of the object to delete. /// Config object which can be used to override that table used. void Delete(object hashKey, object rangeKey, DynamoDBOperationConfig operationConfig); #endregion #region BatchGet /// /// Issues a batch-get request with multiple batches. /// /// Results are stored in the individual batches. /// /// /// Configured BatchGet objects /// void ExecuteBatchGet(params BatchGet[] batches); #endregion #region Batch Write /// /// Issues a batch-write request with multiple batches. /// /// /// Configured BatchWrite objects /// void ExecuteBatchWrite(params BatchWrite[] batches); #endregion #region Transact Get /// /// Issues a transactional get request with multiple TransactGet objects. /// Results are stored in the individual TransactGet objects. /// /// Configured TransactGet objects. void ExecuteTransactGet(params TransactGet[] transactionParts); #endregion #region Transact Write /// /// Issues a transactional write request with multiple TransactWrite objects. /// /// Configured TransactWrite objects. void ExecuteTransactWrite(params TransactWrite[] transactionParts); #endregion #region Scan /// /// Executes a Scan operation against DynamoDB, finding items /// that match the specified conditions. /// /// Type of object. /// /// Conditions that the results should meet. /// /// Lazy-loaded collection of results. IEnumerable Scan(params ScanCondition[] conditions); /// /// Executes a Scan operation against DynamoDB, finding items /// that match the specified conditions. /// /// Type of object. /// /// Conditions that the results should meet. /// /// Config object which can be used to override that table used. /// Lazy-loaded collection of results. IEnumerable Scan(IEnumerable conditions, DynamoDBOperationConfig operationConfig); /// /// Executes a Scan operation against DynamoDB, finding items /// that match the specified conditions. /// /// Type of object. /// Scan request object. /// Lazy-loaded collection of results. IEnumerable FromScan(ScanOperationConfig scanConfig); /// /// Executes a Scan operation against DynamoDB, finding items /// that match the specified conditions. /// /// Type of object. /// Scan request object. /// Config object which can be used to override the table used. /// Lazy-loaded collection of results. IEnumerable FromScan(ScanOperationConfig scanConfig, DynamoDBOperationConfig operationConfig); #endregion #region Query /// /// Executes a Query operation against DynamoDB, finding items /// that match the specified hash primary key. /// /// Type of object. /// Hash key of the items to query. /// Lazy-loaded collection of results. IEnumerable Query(object hashKeyValue); /// /// Executes a Query operation against DynamoDB, finding items /// that match the specified hash primary key. /// /// Type of object. /// Hash key of the items to query. /// Config object which can be used to override the table used. /// Lazy-loaded collection of results. IEnumerable Query(object hashKeyValue, DynamoDBOperationConfig operationConfig); /// /// Executes a Query operation against DynamoDB, finding items /// that match the specified range element condition for a hash-and-range primary key. /// /// Type of object. /// Hash key of the items to query. /// Operation of the condition. /// /// Value(s) of the condition. /// For all operations except QueryOperator.Between, values should be one value. /// For QueryOperator.Between, values should be two values. /// /// Lazy-loaded collection of results. IEnumerable Query(object hashKeyValue, QueryOperator op, params object[] values); /// /// Executes a Query operation against DynamoDB, finding items /// that match the specified range element condition for a hash-and-range primary key. /// /// Type of object. /// Hash key of the items to query. /// Operation of the condition. /// /// Value(s) of the condition. /// For all operations except QueryOperator.Between, values should be one value. /// For QueryOperator.Between, values should be two values. /// /// Config object which can be used to override the table used. /// Lazy-loaded collection of results. IEnumerable Query(object hashKeyValue, QueryOperator op, IEnumerable values, DynamoDBOperationConfig operationConfig); /// /// Executes a Query operation against DynamoDB, finding items /// that match the specified conditions. /// /// Type of object. /// Query request object. /// Lazy-loaded collection of results. IEnumerable FromQuery(QueryOperationConfig queryConfig); /// /// Executes a Query operation against DynamoDB, finding items /// that match the specified conditions. /// /// Type of object. /// Query request object. /// Config object which can be used to override the table used. /// Lazy-loaded collection of results. IEnumerable FromQuery(QueryOperationConfig queryConfig, DynamoDBOperationConfig operationConfig); #endregion #region Table methods /// /// Retrieves the target table for the specified type /// /// Type to retrieve table for /// Table object Table GetTargetTable(); /// /// Retrieves the target table for the specified type /// /// Type to retrieve table for /// Table object Table GetTargetTable(DynamoDBOperationConfig operationConfig); #endregion } }