protected override void ProcessRecord() { AmazonSimpleDB client = base.GetClient(); Amazon.SimpleDB.Model.BatchPutAttributesRequest request = new Amazon.SimpleDB.Model.BatchPutAttributesRequest(); request.DomainName = this._DomainName; Amazon.SimpleDB.Model.BatchPutAttributesResponse response = client.BatchPutAttributes(request); }
private int maxItemsPerRequest = 25; // simpledb has max 25 items per batch put request #endregion Fields #region Methods protected override void SendBuffer(log4net.Core.LoggingEvent[] events) { var client = new AmazonSimpleDBClient(); // access and secret keys in web.config for (var i = 0; i < (events.Count() / maxItemsPerRequest) + 1; i++) { try { var request = new BatchPutAttributesRequest(); foreach (var e in events.Skip(i * maxItemsPerRequest).Take(maxItemsPerRequest)) { var batchItem = new ReplaceableItem() { ItemName = Guid.NewGuid().ToString() }; batchItem.Attribute.Add(GetAttribute("Thread", e.ThreadName)); batchItem.Attribute.Add(GetAttribute("Level", e.Level.Name)); batchItem.Attribute.Add(GetAttribute("CustomLevel", GetCustomProperty(e, "CustomLevel"))); batchItem.Attribute.Add(GetAttribute("Url", GetCustomProperty(e, "Url"))); batchItem.Attribute.Add(GetAttribute("Machine", GetCustomProperty(e, "Machine"))); batchItem.Attribute.Add(GetAttribute("Product", GetCustomProperty(e, "Product"))); batchItem.Attribute.Add(GetAttribute("UserId", GetCustomProperty(e, "UserId"))); batchItem.Attribute.Add(GetAttribute("UserName", GetCustomProperty(e, "UserName"))); batchItem.Attribute.Add(GetAttribute("TimeStamp", e.TimeStamp.ToUniversalTime().ToString("o"))); batchItem.Attribute.Add(GetAttribute("Message", e.RenderedMessage)); batchItem.Attribute.Add(GetAttribute("FormattedMessage", GetCustomProperty(e, "FormattedMessage"))); batchItem.Attribute.Add(GetAttribute("StackTrace", e.GetExceptionString())); request.Item.Add(batchItem); } // Assumes Domain has already been created if(!string.IsNullOrEmpty(ConfigurationManager.AppSettings["SimpleDBLogName"])) request.DomainName = ConfigurationManager.AppSettings["SimpleDBLogName"]; else request.DomainName = "Log"; client.BatchPutAttributes(request); } finally { } } }
public void AttributeTestA_BatchPutAttribute() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { //Unhook from event. _client.OnSimpleDBResponse -= handler; BatchPutAttributesResponse response = args.Response as BatchPutAttributesResponse; if (null != response) { actualValue = true; } hasCallbackArrived = true; }; //Hook to event _client.OnSimpleDBResponse += handler; BatchPutAttributesRequest request = new BatchPutAttributesRequest() { DomainName = _domainName_UnitTesting }; //List<ReplaceableAttribute> itemA = new List<ReplaceableAttribute>(); ReplaceableItem itemA = new ReplaceableItem { ItemName = "ItemA" }; itemA.Attribute.Add(new ReplaceableAttribute().WithName("Category").WithValue("Company")); itemA.Attribute.Add(new ReplaceableAttribute().WithName("Subcategory").WithValue("Private Limited")); itemA.Attribute.Add(new ReplaceableAttribute().WithName("Name").WithValue("Neudesic Technologies")); //List<ReplaceableAttribute> itemB = new List<ReplaceableAttribute>(); ReplaceableItem itemB = new ReplaceableItem { ItemName = "ItemB" }; itemB.Attribute.Add(new ReplaceableAttribute().WithName("Sector").WithValue("IT")); itemB.Attribute.Add(new ReplaceableAttribute().WithName("Location").WithValue("Hydrabad")); itemB.Attribute.Add(new ReplaceableAttribute().WithName("Location").WithValue("Bangalore")); itemB.Attribute.Add(new ReplaceableAttribute().WithName("Size").WithValue("Large")); List<ReplaceableItem> replacableItem = request.Items; replacableItem.Add(itemA); replacableItem.Add(itemB); _client.BatchPutAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
/// <summary> /// Initiates the asynchronous execution of the BatchPutAttributes operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the BatchPutAttributes operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new BatchPutAttributesRequestMarshaller(); var unmarshaller = BatchPutAttributesResponseUnmarshaller.Instance; return InvokeAsync<BatchPutAttributesRequest,BatchPutAttributesResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// The <code>BatchPutAttributes</code> operation creates or replaces attributes within /// one or more items. By using this operation, the client can perform multiple <a>PutAttribute</a> /// operation with a single call. This helps yield savings in round trips and latencies, /// enabling Amazon SimpleDB to optimize requests and generally produce better throughput. /// /// /// /// <para> /// The client may specify the item name with the <code>Item.X.ItemName</code> parameter. /// The client may specify new attributes using a combination of the <code>Item.X.Attribute.Y.Name</code> /// and <code>Item.X.Attribute.Y.Value</code> parameters. The client may specify the first /// attribute for the first item using the parameters <code>Item.0.Attribute.0.Name</code> /// and <code>Item.0.Attribute.0.Value</code>, and for the second attribute for the first /// item by the parameters <code>Item.0.Attribute.1.Name</code> and <code>Item.0.Attribute.1.Value</code>, /// and so on. /// </para> /// /// <para> /// Attributes are uniquely identified within an item by their name/value combination. /// For example, a single item can have the attributes <code>{ "first_name", "first_value" /// }</code> and <code>{ "first_name", "second_value" }</code>. However, it cannot have /// two attribute instances where both the <code>Item.X.Attribute.Y.Name</code> and <code>Item.X.Attribute.Y.Value</code> /// are the same. /// </para> /// /// <para> /// Optionally, the requester can supply the <code>Replace</code> parameter for each /// individual value. Setting this value to <code>true</code> will cause the new attribute /// values to replace the existing attribute values. For example, if an item <code>I</code> /// has the attributes <code>{ 'a', '1' }, { 'b', '2'}</code> and <code>{ 'b', '3' }</code> /// and the requester does a BatchPutAttributes of <code>{'I', 'b', '4' }</code> with /// the Replace parameter set to true, the final attributes of the item will be <code>{ /// 'a', '1' }</code> and <code>{ 'b', '4' }</code>, replacing the previous values of /// the 'b' attribute with the new value. /// </para> /// <important> This operation is vulnerable to exceeding the maximum URL size when making /// a REST request using the HTTP GET method. This operation does not support conditions /// using <code>Expected.X.Name</code>, <code>Expected.X.Value</code>, or <code>Expected.X.Exists</code>. /// </important> /// <para> /// You can execute multiple <code>BatchPutAttributes</code> operations and other operations /// in parallel. However, large numbers of concurrent <code>BatchPutAttributes</code> /// calls can result in Service Unavailable (503) responses. /// </para> /// /// <para> /// The following limitations are enforced for this operation: <ul> <li>256 attribute /// name-value pairs per item</li> <li>1 MB request size</li> <li>1 billion attributes /// per domain</li> <li>10 GB of total user data storage per domain</li> <li>25 item limit /// per <code>BatchPutAttributes</code> operation</li> </ul> /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the BatchPutAttributes service method.</param> /// /// <returns>The response from the BatchPutAttributes service method, as returned by SimpleDB.</returns> /// <exception cref="DuplicateItemNameException"> /// The item name was specified more than once. /// </exception> /// <exception cref="InvalidParameterValueException"> /// The value for a parameter is invalid. /// </exception> /// <exception cref="MissingParameterException"> /// The request must contain the specified missing parameter. /// </exception> /// <exception cref="NoSuchDomainException"> /// The specified domain does not exist. /// </exception> /// <exception cref="NumberDomainAttributesExceededException"> /// Too many attributes in this domain. /// </exception> /// <exception cref="NumberDomainBytesExceededException"> /// Too many bytes in this domain. /// </exception> /// <exception cref="NumberItemAttributesExceededException"> /// Too many attributes in this item. /// </exception> /// <exception cref="NumberSubmittedAttributesExceededException"> /// Too many attributes exist in a single call. /// </exception> /// <exception cref="NumberSubmittedItemsExceededException"> /// Too many items exist in a single call. /// </exception> public BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { var marshaller = new BatchPutAttributesRequestMarshaller(); var unmarshaller = BatchPutAttributesResponseUnmarshaller.Instance; return Invoke<BatchPutAttributesRequest,BatchPutAttributesResponse>(request, marshaller, unmarshaller); }
public void AttributeTestA_BatchPutAttribute_ForException_WithoutItem() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "No items specified"; SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { //Unhook from event. _client.OnSimpleDBResponse -= handler; AmazonSimpleDBException response = args.Response as AmazonSimpleDBException; if (null != response) { actualValue = response.Message.Trim(); } hasCallbackArrived = true; }; //Hook to event _client.OnSimpleDBResponse += handler; BatchPutAttributesRequest request = new BatchPutAttributesRequest() { DomainName = _domainName_UnitTesting }; _client.BatchPutAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
IAsyncResult invokeBatchPutAttributes(BatchPutAttributesRequest batchPutAttributesRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new BatchPutAttributesRequestMarshaller().Marshall(batchPutAttributesRequest); var unmarshaller = BatchPutAttributesResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
internal BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { var task = BatchPutAttributesAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
public static void SaveNewsStory(string domainName, string bucketName, List<NewsComponents> newsItems, AmazonSimpleDBClient sdbClient, AmazonS3Client s3Client) { //BucketHelper.CheckForBucket(itemName, s3Client); //foreach (var stream in newsItems.Images) //{ // PutObjectRequest putObjectRequest = new PutObjectRequest(); // putObjectRequest.WithBucketName(bucketName); // putObjectRequest.CannedACL = S3CannedACL.PublicRead; // putObjectRequest.Key = stream.fileName; // putObjectRequest.InputStream = stream.photostreams; // S3Response response = s3Client.PutObject(putObjectRequest); // response.Dispose(); //} DomainHelper.CheckForDomain(domainName, sdbClient); BatchPutAttributesRequest batchPutAttributesRequest = new BatchPutAttributesRequest(); batchPutAttributesRequest.WithDomainName(domainName); ReplaceableItem replaceableItem; foreach (var list in newsItems) { replaceableItem = new ReplaceableItem(); replaceableItem.WithItemName(Convert.ToString(list.NewsID)); var list1 = new List<ReplaceableAttribute>{ new ReplaceableAttribute { Name = "NewsID", Value = Convert.ToString(list.NewsID), Replace = false }, new ReplaceableAttribute { Name = "Source", Value = list.Source, Replace = false }, new ReplaceableAttribute { Name = "Section", Value = list.Section, Replace = false }, new ReplaceableAttribute { Name = "NewsItem", Value = list.NewsItem, Replace = false }, new ReplaceableAttribute { Name = "NewsHeadline", Value = list.NewsHeadline, Replace = true }, new ReplaceableAttribute { Name = "NewsAdded", Value = Convert.ToString(list.NewsAdded), Replace = true }, new ReplaceableAttribute { Name = "Photos", Value = list.NewsPhotoUrl, Replace = true } , new ReplaceableAttribute { Name = "Summary", Value = list.Summary, Replace = true }, new ReplaceableAttribute { Name = "Category", Value = list.Category, Replace = true } , new ReplaceableAttribute { Name = "TimeStamp", Value = Convert.ToString(list.TimeStamp), Replace = true } }; replaceableItem.WithAttribute(list1.ToArray()); batchPutAttributesRequest.Item.Add(replaceableItem); } //PutAttributesRequest putAttrRequest = new PutAttributesRequest() // .WithDomainName(domainName) // .WithItemName(Convert.ToString(newsItems.NewsID)); // sdbClient.PutAttributes(putAttrRequest); sdbClient.BatchPutAttributes(batchPutAttributesRequest); }
/// <summary> /// Initiates the asynchronous execution of the BatchPutAttributes operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB.BatchPutAttributes"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the BatchPutAttributes operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new BatchPutAttributesRequestMarshaller(); var unmarshaller = BatchPutAttributesResponseUnmarshaller.GetInstance(); return Invoke<IRequest, BatchPutAttributesRequest, BatchPutAttributesResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// <para> The <c>BatchPutAttributes</c> operation creates or replaces attributes within one or more items. By using this operation, the client /// can perform multiple PutAttribute operation with a single call. This helps yield savings in round trips and latencies, enabling Amazon /// SimpleDB to optimize requests and generally produce better throughput. </para> <para> The client may specify the item name with the /// <c>Item.X.ItemName</c> parameter. The client may specify new attributes using a combination of the <c>Item.X.Attribute.Y.Name</c> and /// <c>Item.X.Attribute.Y.Value</c> parameters. The client may specify the first attribute for the first item using the parameters /// <c>Item.0.Attribute.0.Name</c> and <c>Item.0.Attribute.0.Value</c> , /// and for the second attribute for the first item by the parameters <c>Item.0.Attribute.1.Name</c> and <c>Item.0.Attribute.1.Value</c> , /// and so on. </para> <para> Attributes are uniquely identified within an item by their name/value combination. For example, a single item /// can have the attributes <c>{ "first_name", "first_value" }</c> and <c>{ "first_name", "second_value" }</c> . /// However, it cannot have two attribute instances where both the <c>Item.X.Attribute.Y.Name</c> and <c>Item.X.Attribute.Y.Value</c> are the /// same. </para> <para> Optionally, the requester can supply the <c>Replace</c> parameter for each individual value. Setting this value to /// <c>true</c> will cause the new attribute values to replace the existing attribute values. For example, if an item <c>I</c> has the /// attributes <c>{ 'a', '1' }, { 'b', '2'}</c> and <c>{ 'b', '3' }</c> and the requester does a BatchPutAttributes of <c>{'I', 'b', '4' }</c> /// with the Replace parameter set to true, the final attributes of the item will be <c>{ 'a', '1' }</c> and <c>{ 'b', '4' }</c> , /// replacing the previous values of the 'b' attribute with the new value. </para> <para><b>NOTE:</b> You cannot specify an empty string as an /// item or as an attribute name. The BatchPutAttributes operation succeeds or fails in its entirety. There are no partial puts. </para> /// <para><b>IMPORTANT:</b> This operation is vulnerable to exceeding the maximum URL size when making a REST request using the HTTP GET method. /// This operation does not support conditions using Expected.X.Name, Expected.X.Value, or Expected.X.Exists. </para> <para> You can execute /// multiple <c>BatchPutAttributes</c> operations and other operations in parallel. However, large numbers of concurrent /// <c>BatchPutAttributes</c> calls can result in Service Unavailable (503) responses. </para> <para> The following limitations are enforced for /// this operation: /// <ul> /// <li>256 attribute name-value pairs per item</li> /// <li>1 MB request size</li> /// <li>1 billion attributes per domain</li> /// <li>10 GB of total user data storage per domain</li> /// <li>25 item limit per <c>BatchPutAttributes</c> operation</li> /// /// </ul> /// </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the BatchPutAttributes service method on /// AmazonSimpleDB.</param> /// /// <exception cref="T:Amazon.SimpleDB.Model.DuplicateItemNameException" /> /// <exception cref="T:Amazon.SimpleDB.Model.InvalidParameterValueException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberDomainBytesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberSubmittedItemsExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberSubmittedAttributesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberDomainAttributesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NoSuchDomainException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberItemAttributesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.MissingParameterException" /> public BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { var task = BatchPutAttributesAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
private void btnBatchPutAttributes_Click(object sender, RoutedEventArgs e) { SimpleDB.Client.OnSimpleDBResponse += BatchPutAttributeWebResponse; BatchPutAttributesRequest request = new BatchPutAttributesRequest() { DomainName = this.DomainName }; this.BatchPutMessage = "Please wait..."; List<ReplaceableAttribute> attributesOne = new List<ReplaceableAttribute>(); List<ReplaceableAttribute> attributesTwo = new List<ReplaceableAttribute>(); List<AttributeAndValue> aAndV = GetListAttributeAndValueFromString(this.AttributesAndValuesToPut); int index = 0; foreach (var item in aAndV) { if (index <= aAndV.Count / 2) attributesOne.Add(new ReplaceableAttribute().WithName(item.Attribute).WithValue(item.Value)); else attributesTwo.Add(new ReplaceableAttribute().WithName(item.Attribute).WithValue(item.Value)); index++; } //attributesOne.Add(new ReplaceableAttribute().WithName("Category").WithValue("Clothes")); //attributesOne.Add(new ReplaceableAttribute().WithName("Subcategory").WithValue("Sweater")); //attributesOne.Add(new ReplaceableAttribute().WithName("Name").WithValue("Cathair Sweater")); //attributesTwo.Add(new ReplaceableAttribute().WithName("Color").WithValue("Siamese")); //attributesTwo.Add(new ReplaceableAttribute().WithName("Size").WithValue("Small")); //attributesTwo.Add(new ReplaceableAttribute().WithName("Size").WithValue("Medium")); //attributesTwo.Add(new ReplaceableAttribute().WithName("Size").WithValue("Large")); List<ReplaceableItem> replacableItem = request.Items; //Get the item-names. foreach (var item in GetItemNames(this.ItemName)) { ReplaceableItem repItem = new ReplaceableItem() { ItemName = item }; attributesOne.ForEach(a => repItem.Attribute.Add(a)); replacableItem.Add(repItem); } //replacableItem.Add(new ReplaceableItem() { Attribute = attributesOne, ItemName = "OneAttribute" }); //replacableItem.Add(new ReplaceableItem() { Attribute = attributesTwo, ItemName = "TwoAttribute" }); SimpleDB.Client.BatchPutAttributes(request); }
/// <summary> /// Initiates the asynchronous execution of the BatchPutAttributes operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the BatchPutAttributes operation on AmazonSimpleDBClient.</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 EndBatchPutAttributes /// operation.</returns> public IAsyncResult BeginBatchPutAttributes(BatchPutAttributesRequest request, AsyncCallback callback, object state) { var marshaller = new BatchPutAttributesRequestMarshaller(); var unmarshaller = BatchPutAttributesResponseUnmarshaller.Instance; return BeginInvoke<BatchPutAttributesRequest>(request, marshaller, unmarshaller, callback, state); }
BatchPutAttributesResponse AmazonSimpleDB.BatchPutAttributes(BatchPutAttributesRequest request) { throw new NotImplementedException(); }
/// <summary> /// <para> The <c>BatchPutAttributes</c> operation creates or replaces attributes within one or more items. By using this operation, the client /// can perform multiple PutAttribute operation with a single call. This helps yield savings in round trips and latencies, enabling Amazon /// SimpleDB to optimize requests and generally produce better throughput. </para> <para> The client may specify the item name with the /// <c>Item.X.ItemName</c> parameter. The client may specify new attributes using a combination of the <c>Item.X.Attribute.Y.Name</c> and /// <c>Item.X.Attribute.Y.Value</c> parameters. The client may specify the first attribute for the first item using the parameters /// <c>Item.0.Attribute.0.Name</c> and <c>Item.0.Attribute.0.Value</c> , /// and for the second attribute for the first item by the parameters <c>Item.0.Attribute.1.Name</c> and <c>Item.0.Attribute.1.Value</c> , /// and so on. </para> <para> Attributes are uniquely identified within an item by their name/value combination. For example, a single item /// can have the attributes <c>{ "first_name", "first_value" }</c> and <c>{ "first_name", "second_value" }</c> . /// However, it cannot have two attribute instances where both the <c>Item.X.Attribute.Y.Name</c> and <c>Item.X.Attribute.Y.Value</c> are the /// same. </para> <para> Optionally, the requester can supply the <c>Replace</c> parameter for each individual value. Setting this value to /// <c>true</c> will cause the new attribute values to replace the existing attribute values. For example, if an item <c>I</c> has the /// attributes <c>{ 'a', '1' }, { 'b', '2'}</c> and <c>{ 'b', '3' }</c> and the requester does a BatchPutAttributes of <c>{'I', 'b', '4' }</c> /// with the Replace parameter set to true, the final attributes of the item will be <c>{ 'a', '1' }</c> and <c>{ 'b', '4' }</c> , /// replacing the previous values of the 'b' attribute with the new value. </para> <para><b>NOTE:</b> You cannot specify an empty string as an /// item or as an attribute name. The BatchPutAttributes operation succeeds or fails in its entirety. There are no partial puts. </para> /// <para><b>IMPORTANT:</b> This operation is vulnerable to exceeding the maximum URL size when making a REST request using the HTTP GET method. /// This operation does not support conditions using Expected.X.Name, Expected.X.Value, or Expected.X.Exists. </para> <para> You can execute /// multiple <c>BatchPutAttributes</c> operations and other operations in parallel. However, large numbers of concurrent /// <c>BatchPutAttributes</c> calls can result in Service Unavailable (503) responses. </para> <para> The following limitations are enforced for /// this operation: /// <ul> /// <li>256 attribute name-value pairs per item</li> /// <li>1 MB request size</li> /// <li>1 billion attributes per domain</li> /// <li>10 GB of total user data storage per domain</li> /// <li>25 item limit per <c>BatchPutAttributes</c> operation</li> /// /// </ul> /// </para> /// </summary> /// /// <param name="batchPutAttributesRequest">Container for the necessary parameters to execute the BatchPutAttributes service method on /// AmazonSimpleDB.</param> /// /// <exception cref="DuplicateItemNameException"/> /// <exception cref="InvalidParameterValueException"/> /// <exception cref="NumberDomainBytesExceededException"/> /// <exception cref="NumberSubmittedItemsExceededException"/> /// <exception cref="NumberSubmittedAttributesExceededException"/> /// <exception cref="NumberDomainAttributesExceededException"/> /// <exception cref="NoSuchDomainException"/> /// <exception cref="NumberItemAttributesExceededException"/> /// <exception cref="MissingParameterException"/> public BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest batchPutAttributesRequest) { IAsyncResult asyncResult = invokeBatchPutAttributes(batchPutAttributesRequest, null, null, true); return EndBatchPutAttributes(asyncResult); }
IAsyncResult AmazonSimpleDB.BeginBatchPutAttributes(BatchPutAttributesRequest request, AsyncCallback callback, object state) { throw new NotImplementedException(); }
/// <summary> /// Initiates the asynchronous execution of the BatchPutAttributes operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB.BatchPutAttributes"/> /// </summary> /// /// <param name="batchPutAttributesRequest">Container for the necessary parameters to execute the BatchPutAttributes operation on /// AmazonSimpleDB.</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> public IAsyncResult BeginBatchPutAttributes(BatchPutAttributesRequest batchPutAttributesRequest, AsyncCallback callback, object state) { return invokeBatchPutAttributes(batchPutAttributesRequest, callback, state, false); }
/// <summary> /// <para> The <c>BatchPutAttributes</c> operation creates or replaces attributes within one or more items. By using this operation, the client /// can perform multiple PutAttribute operation with a single call. This helps yield savings in round trips and latencies, enabling Amazon /// SimpleDB to optimize requests and generally produce better throughput. </para> <para> The client may specify the item name with the /// <c>Item.X.ItemName</c> parameter. The client may specify new attributes using a combination of the <c>Item.X.Attribute.Y.Name</c> and /// <c>Item.X.Attribute.Y.Value</c> parameters. The client may specify the first attribute for the first item using the parameters /// <c>Item.0.Attribute.0.Name</c> and <c>Item.0.Attribute.0.Value</c> , /// and for the second attribute for the first item by the parameters <c>Item.0.Attribute.1.Name</c> and <c>Item.0.Attribute.1.Value</c> , /// and so on. </para> <para> Attributes are uniquely identified within an item by their name/value combination. For example, a single item /// can have the attributes <c>{ "first_name", "first_value" }</c> and <c>{ "first_name", "second_value" }</c> . /// However, it cannot have two attribute instances where both the <c>Item.X.Attribute.Y.Name</c> and <c>Item.X.Attribute.Y.Value</c> are the /// same. </para> <para> Optionally, the requester can supply the <c>Replace</c> parameter for each individual value. Setting this value to /// <c>true</c> will cause the new attribute values to replace the existing attribute values. For example, if an item <c>I</c> has the /// attributes <c>{ 'a', '1' }, { 'b', '2'}</c> and <c>{ 'b', '3' }</c> and the requester does a BatchPutAttributes of <c>{'I', 'b', '4' }</c> /// with the Replace parameter set to true, the final attributes of the item will be <c>{ 'a', '1' }</c> and <c>{ 'b', '4' }</c> , /// replacing the previous values of the 'b' attribute with the new value. </para> <para><b>NOTE:</b> You cannot specify an empty string as an /// item or as an attribute name. The BatchPutAttributes operation succeeds or fails in its entirety. There are no partial puts. </para> /// <para><b>IMPORTANT:</b> This operation is vulnerable to exceeding the maximum URL size when making a REST request using the HTTP GET method. /// This operation does not support conditions using Expected.X.Name, Expected.X.Value, or Expected.X.Exists. </para> <para> You can execute /// multiple <c>BatchPutAttributes</c> operations and other operations in parallel. However, large numbers of concurrent /// <c>BatchPutAttributes</c> calls can result in Service Unavailable (503) responses. </para> <para> The following limitations are enforced for /// this operation: /// <ul> /// <li>256 attribute name-value pairs per item</li> /// <li>1 MB request size</li> /// <li>1 billion attributes per domain</li> /// <li>10 GB of total user data storage per domain</li> /// <li>25 item limit per <c>BatchPutAttributes</c> operation</li> /// /// </ul> /// </para> /// </summary> /// /// <param name="batchPutAttributesRequest">Container for the necessary parameters to execute the BatchPutAttributes service method on /// AmazonSimpleDB.</param> /// /// <exception cref="T:Amazon.SimpleDB.Model.DuplicateItemNameException" /> /// <exception cref="T:Amazon.SimpleDB.Model.InvalidParameterValueException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberDomainBytesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberSubmittedItemsExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberSubmittedAttributesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberDomainAttributesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NoSuchDomainException" /> /// <exception cref="T:Amazon.SimpleDB.Model.NumberItemAttributesExceededException" /> /// <exception cref="T:Amazon.SimpleDB.Model.MissingParameterException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public async Task<BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest batchPutAttributesRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new BatchPutAttributesRequestMarshaller(); var unmarshaller = BatchPutAttributesResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, BatchPutAttributesRequest, BatchPutAttributesResponse>(batchPutAttributesRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
public static void AmazonBatchPutPost(List<ForumPost> awsPosts,int threadIndex) { SimpleDB.Client.OnSimpleDBResponse += BatchPutAttributeWebResponse; BatchPutAttributesRequest request = new BatchPutAttributesRequest() { DomainName = "coreDB" }; ReplaceableAttribute attributesOne = new ReplaceableAttribute().WithName("votes").WithValue("0").WithReplace(true); ReplaceableAttribute attributesTwo = new ReplaceableAttribute().WithName("module").WithValue(data.modules[data.curModuleIndex].CourseCode.ToString()); ReplaceableAttribute attributesThree = new ReplaceableAttribute().WithName("AWSTimestamp").WithValue(data.modules[data.curModuleIndex].lastUpdated.ToString()).WithReplace(true); ReplaceableAttribute attributesFour; ReplaceableAttribute attributesFive = new ReplaceableAttribute().WithName("root").WithValue(data.modules[data.curModuleIndex].jPosts["Results"][0]["Threads"][threadIndex]["ID"].ToString()); //int forumIndex = 0; //int i = 0; List<ReplaceableItem> replacableItem = request.Items; int t = 0; //List<ForumPostTitle> titles = fetchForumTitles(data.curModuleIndex, data.curForumIndex, 0); foreach (var post in awsPosts) { attributesFour = new ReplaceableAttribute().WithName("title").WithValue(post.Heading.ToString()); //attributesFive = new ReplaceableAttribute().WithName("subscriber").WithValue(data.modules[data.curModuleIndex].lastUpdated.ToString()); ReplaceableItem repItem = new ReplaceableItem() { ItemName = post.ID.ToString() }; repItem.Attribute.Add(attributesOne); repItem.Attribute.Add(attributesTwo); repItem.Attribute.Add(attributesThree); repItem.Attribute.Add(attributesFour); repItem.Attribute.Add(attributesFive); replacableItem.Add(repItem); t++; } SimpleDB.Client.BatchPutAttributes(request); }