Exemplo n.º 1
0
 /// <summary>
 /// Attribute accessor, allows getting or setting of an individual attribute.
 /// </summary>
 /// <param name="key">Name of the attribute.</param>
 /// <returns>Current value of the attribute.</returns>
 public DynamoDBEntry this[string key]
 {
     get
     {
         return currentValues[key];
     }
     set
     {
         if (value == null)
         {
             currentValues[key] = new Primitive();
         }
         else
         {
             currentValues[key] = value;
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initiates the asynchronous execution of the UpdateItem operation.
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.UpdateItem"/>
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateItem
 ///         operation.</returns>
 public IAsyncResult BeginUpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => UpdateHelper(doc, MakeKey(hashKey, rangeKey), config, true), callback, state);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, rangeKey), config, true), callback, state);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.GetItem"/>
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(Primitive hashKey, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, null), null, true), callback, state);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add a single item to get, identified by its hash-and-range primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the item to get.</param>
 /// <param name="rangeKey">Range key element of the item to get.</param>
 public void AddKey(Primitive hashKey, Primitive rangeKey)
 {
     Keys.Add(TargetTable.MakeKey(hashKey, rangeKey));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Update a document in DynamoDB, with a hash-and-range primary key to identify
 /// the document, and using the specified config.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or updated attributes, depending on config.</returns>
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.UpdateItemOperationConfig"/>
 public Document UpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config)
 {
     return UpdateHelper(doc, MakeKey(hashKey, rangeKey), config, false);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initiates a Search object to Query a DynamoDB table, with the
 /// specified hash primary key and filter.
 /// 
 /// No calls are made until the Search object is used.
 /// </summary>
 /// <param name="hashKey">Hash key element parameter of the query.</param>
 /// <param name="filter">Filter to use.</param>
 /// <returns>Resultant Search container.</returns>
 public Search Query(Primitive hashKey, RangeFilter filter)
 {
     return Query(new QueryOperationConfig { HashKey = hashKey, Filter = filter });
 }
Exemplo n.º 8
0
 /// <summary>
 /// Gets a document from DynamoDB by hash-and-range primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, Primitive rangeKey)
 {
     return GetItemHelper(MakeKey(hashKey, rangeKey), null, false);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Update a document in DynamoDB, with a hash primary key to identify the
 /// document, and using the specified config.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or updated attributes, depending on config.</returns>
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.UpdateItemOperationConfig"/>
 public Document UpdateItem(Document doc, Primitive hashKey, UpdateItemOperationConfig config)
 {
     return UpdateHelper(doc, MakeKey(hashKey, null), config);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Update a document in DynamoDB, with hash primary key to identify the document.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 public void UpdateItem(Document doc, Primitive hashKey)
 {
     UpdateHelper(doc, MakeKey(hashKey,null), null);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gets a document from DynamoDB by hash primary key, using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, GetItemOperationConfig config)
 {
     return GetHelper(MakeKey(hashKey, null), config);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Gets a document from DynamoDB by hash primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <returns>Document from DynamoDB</returns>
 public Document GetItem(Primitive hashKey)
 {
     return GetHelper(MakeKey(hashKey, null), null);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Delete a document in DynamoDB, identified by a hash primary key,
 /// using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or old attributes, depending on config.</returns>
 public Document DeleteItem(Primitive hashKey, DeleteItemOperationConfig config)
 {
     return DeleteHelper(MakeKey(hashKey, null), config);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Delete a document in DynamoDB, identified by a hash primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 public void DeleteItem(Primitive hashKey)
 {
     DeleteHelper(MakeKey(hashKey, null), null);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Add a single item to get, identified by its hash primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the item to get.</param>
 public void AddKey(Primitive hashKey)
 {
     AddKey(hashKey, null);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Delete a document in DynamoDB, identified by a hash-and-range primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 public void DeleteItem(Primitive hashKey, Primitive rangeKey)
 {
     DeleteHelper(MakeKey(hashKey, rangeKey), null, false);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Delete a document in DynamoDB, identified by hash-and-range primary key,
 /// using the specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or old attributes, depending on config.</returns>
 public Document DeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config)
 {
     return DeleteHelper(MakeKey(hashKey, rangeKey), config, false);
 }
Exemplo n.º 18
0
        internal static DynamoDBEntry AttributeValueToDynamoDBEntry(AttributeValue attributeValue)
        {
            Primitive primitive = null;
            if (attributeValue.S != null)
            {
                primitive = new Primitive(attributeValue.S);
            }
            else if (attributeValue.N != null)
            {
                primitive = new Primitive(attributeValue.N, true);
            }
            else if (attributeValue.B != null)
            {
                primitive = new Primitive(attributeValue.B);
            }
            if (primitive != null)
                return primitive;

            PrimitiveList primitiveList = null;
            if (attributeValue.SS != null && attributeValue.SS.Count != 0)
            {
                primitiveList = new PrimitiveList(DynamoDBEntryType.String);
                foreach (string item in attributeValue.SS)
                {
                    primitive = new Primitive(item);
                    primitiveList.Add(primitive);
                }
            }
            else if (attributeValue.NS != null && attributeValue.NS.Count != 0)
            {
                primitiveList = new PrimitiveList(DynamoDBEntryType.Numeric);
                foreach (string item in attributeValue.NS)
                {
                    primitive = new Primitive(item, true);
                    primitiveList.Add(primitive);
                }
            }
            else if (attributeValue.BS != null && attributeValue.BS.Count != 0)
            {
                primitiveList = new PrimitiveList(DynamoDBEntryType.Binary);
                foreach (MemoryStream item in attributeValue.BS)
                {
                    primitive = new Primitive(item);
                    primitiveList.Add(primitive);
                }
            }

            if (primitiveList != null)
                return primitiveList;

            return null;
        }
Exemplo n.º 19
0
 /// <summary>
 /// Gets a document from DynamoDB by hash-and-range primary key,
 /// using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config)
 {
     return GetItemHelper(MakeKey(hashKey, rangeKey), config, false);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.DeleteItem"/>
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
 ///         operation.</returns>
 public IAsyncResult BeginDeleteItem(Primitive hashKey, Primitive rangeKey, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => { DeleteHelper(MakeKey(hashKey, rangeKey), null, true); return null; }, callback, state);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Update a document in DynamoDB, with a hash-and-range primary key
 /// to identify the document.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 public void UpdateItem(Document doc, Primitive hashKey, Primitive rangeKey)
 {
     UpdateHelper(doc, MakeKey(hashKey, rangeKey), null, false);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteItem operation.
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.DeleteItem"/>
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteItem
 ///         operation.</returns>
 public IAsyncResult BeginDeleteItem(Primitive hashKey, DeleteItemOperationConfig config, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => DeleteHelper(MakeKey(hashKey, null), config, true), callback, state);
 }
Exemplo n.º 23
0
        internal Key MakeKey(Primitive hashKey, Primitive rangeKey)
        {
            Key newKey = new Key();

            newKey.HashKeyElement = hashKey.ConvertToAttributeValue();
            if (HashKeyType != hashKey.Type)
                throw new InvalidOperationException("Table schema hash key inconsistent with specified hash key value");

            if ((rangeKey == null) == RangeKeyIsDefined)
            {
                throw new ArgumentException("Range Key does not match schema");
            }
            else
            {
                if (RangeKeyIsDefined)
                {
                    newKey.RangeKeyElement = rangeKey.ConvertToAttributeValue();
                    if (RangeKeyType != rangeKey.Type)
                        throw new InvalidOperationException("Table schema range key inconsistent with specified range key value");
                }
            }

            return newKey;
        }
Exemplo n.º 24
0
 /// <summary>
 /// Adds a Primitive to the end of the list.
 /// </summary>
 /// <param name="value">Primitive to add.</param>
 public void Add(Primitive value)
 {
     this.Entries.Add(value);
 }