internal virtual BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = BatchPutAttributesRequestMarshaller.Instance; options.ResponseUnmarshaller = BatchPutAttributesResponseUnmarshaller.Instance; return(Invoke <BatchPutAttributesResponse>(request, options)); }
/// <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> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the BatchPutAttributes service method, as returned by SimpleDB.</returns> /// <exception cref="Amazon.SimpleDB.Model.DuplicateItemNameException"> /// The item name was specified more than once. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.InvalidParameterValueException"> /// The value for a parameter is invalid. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.MissingParameterException"> /// The request must contain the specified missing parameter. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.NoSuchDomainException"> /// The specified domain does not exist. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.NumberDomainAttributesExceededException"> /// Too many attributes in this domain. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.NumberDomainBytesExceededException"> /// Too many bytes in this domain. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.NumberItemAttributesExceededException"> /// Too many attributes in this item. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.NumberSubmittedAttributesExceededException"> /// Too many attributes exist in a single call. /// </exception> /// <exception cref="Amazon.SimpleDB.Model.NumberSubmittedItemsExceededException"> /// Too many items exist in a single call. /// </exception> public virtual Task <BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = BatchPutAttributesRequestMarshaller.Instance; options.ResponseUnmarshaller = BatchPutAttributesResponseUnmarshaller.Instance; return(InvokeAsync <BatchPutAttributesResponse>(request, options, cancellationToken)); }
public async Task AddOrUpdateMember(Member member) { var client = GetClient(); if (member.IsNewItem) { member.DbKey = member.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Name", Value = member.Name, Replace = true }, new ReplaceableAttribute { Name = "MembershipNumber", Value = member.MembershipNumber.ToString(), Replace = true }, new ReplaceableAttribute { Name = "Admin", Value = member.Admin ? "1" : "0", Replace = true }, new ReplaceableAttribute { Name = "LastPaid", Value = dateToString(member.LastPaid), Replace = true }, new ReplaceableAttribute { Name = "Enabled", Value = member.Enabled ? "1" : "0", Replace = true }, new ReplaceableAttribute { Name = "Pin", Value = member.Pin.ToString(), Replace = true }, }; request.Items.Add( new ReplaceableItem { Name = member.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Member added: {member.DbKey} - {member.Name}"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
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); }
private void TestBatchPutAttributes() { BatchPutAttributesRequest request = new BatchPutAttributesRequest() { DomainName = domainName, Items = ITEM_LIST }; Client.BatchPutAttributes(request); assertItemsStoredInDomain(Client, ITEM_LIST, domainName); }
internal BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { var task = BatchPutAttributesAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
public async Task AddOrUpdateNewsItem(NewsItem newsItem) { var client = GetClient(); if (newsItem.IsNewItem) { newsItem.DbKey = newsItem.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Date", Value = dateToString(newsItem.Date), Replace = true }, new ReplaceableAttribute { Name = "Title", Value = newsItem.Title, Replace = true }, new ReplaceableAttribute { Name = "Body", Value = newsItem.Body, Replace = true }, }; request.Items.Add( new ReplaceableItem { Name = newsItem.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"News Item added: {newsItem.DbKey} - {newsItem.Title}"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
/** * Convert BatchPutAttributesRequest to name value pairs */ private static IDictionary <string, string> ConvertBatchPutAttributes(BatchPutAttributesRequest request) { IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters["Action"] = "BatchPutAttributes"; if (request.IsSetDomainName()) { parameters["DomainName"] = request.DomainName; } List <ReplaceableItem> batchPutAttributesRequestItemList = request.Items; int batchPutAttributesRequestItemListIndex = 1; foreach (ReplaceableItem batchPutAttributesRequestItem in batchPutAttributesRequestItemList) { if (batchPutAttributesRequestItem.IsSetItemName()) { parameters[String.Concat("Item", ".", batchPutAttributesRequestItemListIndex, ".", "ItemName")] = batchPutAttributesRequestItem.ItemName; } List <ReplaceableAttribute> itemAttributeList = batchPutAttributesRequestItem.Attribute; int itemAttributeListIndex = 1; foreach (ReplaceableAttribute itemAttribute in itemAttributeList) { if (itemAttribute.IsSetName()) { parameters[String.Concat("Item", ".", batchPutAttributesRequestItemListIndex, ".", "Attribute", ".", itemAttributeListIndex, ".", "Name")] = itemAttribute.Name; } if (itemAttribute.IsSetValue()) { parameters[String.Concat("Item", ".", batchPutAttributesRequestItemListIndex, ".", "Attribute", ".", itemAttributeListIndex, ".", "Value")] = itemAttribute.Value; } if (itemAttribute.IsSetReplace()) { parameters[String.Concat("Item", ".", batchPutAttributesRequestItemListIndex, ".", "Attribute", ".", itemAttributeListIndex, ".", "Replace")] = itemAttribute.Replace.ToString().ToLowerInvariant(); } itemAttributeListIndex++; } batchPutAttributesRequestItemListIndex++; } return(parameters); }
/** * Convert BatchPutAttributesRequest to name value pairs */ private IDictionary <String, String> ConvertBatchPutAttributes(BatchPutAttributesRequest request) { IDictionary <String, String> parameters = new Dictionary <String, String>(); parameters.Add("Action", "BatchPutAttributes"); if (request.IsSetDomainName()) { parameters.Add("DomainName", request.DomainName); } List <ReplaceableItem> batchPutAttributesRequestItemList = request.Item; int batchPutAttributesRequestItemListIndex = 1; foreach (ReplaceableItem batchPutAttributesRequestItem in batchPutAttributesRequestItemList) { if (batchPutAttributesRequestItem.IsSetItemName()) { parameters.Add("Item" + "." + batchPutAttributesRequestItemListIndex + "." + "ItemName", batchPutAttributesRequestItem.ItemName); } List <ReplaceableAttribute> itemAttributeList = batchPutAttributesRequestItem.Attribute; int itemAttributeListIndex = 1; foreach (ReplaceableAttribute itemAttribute in itemAttributeList) { if (itemAttribute.IsSetName()) { parameters.Add("Item" + "." + batchPutAttributesRequestItemListIndex + "." + "Attribute" + "." + itemAttributeListIndex + "." + "Name", itemAttribute.Name); } if (itemAttribute.IsSetValue()) { parameters.Add("Item" + "." + batchPutAttributesRequestItemListIndex + "." + "Attribute" + "." + itemAttributeListIndex + "." + "Value", itemAttribute.Value); } if (itemAttribute.IsSetReplace()) { parameters.Add("Item" + "." + batchPutAttributesRequestItemListIndex + "." + "Attribute" + "." + itemAttributeListIndex + "." + "Replace", itemAttribute.Replace + ""); } itemAttributeListIndex++; } batchPutAttributesRequestItemListIndex++; } return(parameters); }
private static IDictionary <string, string> ConvertBatchPutAttributes(BatchPutAttributesRequest request) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["Action"] = "BatchPutAttributes"; if (request.IsSetDomainName()) { dictionary["DomainName"] = request.DomainName; } List <ReplaceableItem> list = request.Item; int num = 1; foreach (ReplaceableItem item in list) { if (item.IsSetItemName()) { dictionary[string.Concat(new object[] { "Item", ".", num, ".", "ItemName" })] = item.ItemName; } List <ReplaceableAttribute> list2 = item.Attribute; int num2 = 1; foreach (ReplaceableAttribute attribute in list2) { if (attribute.IsSetName()) { dictionary[string.Concat(new object[] { "Item", ".", num, ".", "Attribute", ".", num2, ".", "Name" })] = attribute.Name; } if (attribute.IsSetValue()) { dictionary[string.Concat(new object[] { "Item", ".", num, ".", "Attribute", ".", num2, ".", "Value" })] = attribute.Value; } if (attribute.IsSetReplace()) { dictionary[string.Concat(new object[] { "Item", ".", num, ".", "Attribute", ".", num2, ".", "Replace" })] = attribute.Replace.ToString().ToLower(); } num2++; } num++; } return(dictionary); }
/// <summary> /// Creates multiple items simultaneously /// </summary> public async Task BatchCreateItemsAsync(IEnumerable <SdbItem> items) { var replaceableItems = new List <ReplaceableItem>(); foreach (var item in items) { //Add additional attribute for the Exists flag on the newly created item item.Attributes = item.Attributes.Concat(new[] { new SdbItemAttribute(ExistsAttributeName, "1"), }); var convertedAttributes = SimpleDbHelper.ConvertItemAttributesToReplaceableAttributes(item.Attributes); replaceableItems.Add(new ReplaceableItem(item.ItemName, convertedAttributes.ToList())); } try { var batchPutRequest = new BatchPutAttributesRequest(_simpleDbDomain, replaceableItems); await _client.BatchPutAttributesAsync(batchPutRequest); } catch (AmazonSimpleDBException e) { Console.WriteLine(e.StackTrace); throw; } }
/// <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 Task<BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest batchPutAttributesRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new BatchPutAttributesRequestMarshaller(); var unmarshaller = BatchPutAttributesResponseUnmarshaller.GetInstance(); return Invoke<IRequest, BatchPutAttributesRequest, BatchPutAttributesResponse>(batchPutAttributesRequest, marshaller, unmarshaller, signer, cancellationToken); }
public async Task AddOrUpdateEvent(ClubEvent clubEvent) { var client = GetClient(); if (clubEvent.IsNewItem) { clubEvent.DbKey = clubEvent.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Id", Value = clubEvent.Id, Replace = true }, new ReplaceableAttribute { Name = "Season", Value = ((int)clubEvent.Season).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Date", Value = dateToString(clubEvent.Date), Replace = true }, new ReplaceableAttribute { Name = "EventType", Value = ((int)clubEvent.EventType).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Description", Value = clubEvent.Description, Replace = true } }; // Optional properties if (clubEvent.MatchType != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchType", Value = ((int)clubEvent.MatchType.Value).ToString(), Replace = true }); } if (clubEvent.MatchDraw != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchDraw", Value = dateToString(clubEvent.MatchDraw.Value), Replace = true }); } if (clubEvent.MatchStart != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchStart", Value = dateToString(clubEvent.MatchStart.Value), Replace = true }); } if (clubEvent.MatchEnd != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchEnd", Value = dateToString(clubEvent.MatchEnd.Value), Replace = true }); } if (clubEvent.Number != null) { attributes.Add(new ReplaceableAttribute { Name = "Number", Value = numberToString(clubEvent.Number.Value), Replace = true }); } if (clubEvent.Cup != null) { attributes.Add(new ReplaceableAttribute { Name = "Cup", Value = clubEvent.Cup, Replace = true }); } request.Items.Add( new ReplaceableItem { Name = clubEvent.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Event added: {clubEvent.DbKey} - {clubEvent.Description}"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
/// <summary> /// Batch add data to domain (table) and row (item). /// </summary> /// <param name="batchAttributes">Batch put attributes request.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The async task.</returns> public async Task <BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest batchAttributes, CancellationToken cancellationToken) { return(await _client.BatchPutAttributesAsync(batchAttributes, cancellationToken)); }
public async Task AddOrUpdateMatchResult(MatchResult result) { var client = GetClient(); // Validate MatchId { if (!(await _eventRepository.GetEvents()).Any(x => x.Id == result.MatchId)) { throw new KeyNotFoundException($"Match '{result.MatchId}' does not exist"); } } // Validate MembershipNumber { if (!(await _memberRepository.GetMembers()).Any(x => x.MembershipNumber == result.MembershipNumber)) { throw new KeyNotFoundException($"Member '{result.MembershipNumber}' does not exist"); } } if (result.IsNewItem) { result.DbKey = result.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "MatchId", Value = result.MatchId, Replace = true }, new ReplaceableAttribute { Name = "MembershipNumber", Value = result.MembershipNumber.ToString(), Replace = true }, new ReplaceableAttribute { Name = "Peg", Value = result.Peg, Replace = true }, new ReplaceableAttribute { Name = "WeightDecimal", Value = weightToString(result.WeightDecimal), Replace = true }, new ReplaceableAttribute { Name = "Points", Value = pointsToString(result.Points), Replace = true } }; request.Items.Add( new ReplaceableItem { Name = result.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Match result added"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
public async Task AddOrUpdateWater(Water water) { var client = GetClient(); if (water.IsNewItem) { water.DbKey = water.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory Properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Id", Value = water.Id.ToString(), Replace = true }, new ReplaceableAttribute { Name = "Name", Value = water.Name, Replace = true }, new ReplaceableAttribute { Name = "Type", Value = ((int)water.Type).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Access", Value = ((int)water.Access).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Description", Value = water.Description, Replace = true }, new ReplaceableAttribute { Name = "Species", Value = water.Species, Replace = true }, new ReplaceableAttribute { Name = "Directions", Value = water.Directions, Replace = true }, new ReplaceableAttribute { Name = "Markers", Value = water.Markers, Replace = true }, new ReplaceableAttribute { Name = "MarkerIcons", Value = water.MarkerIcons, Replace = true }, new ReplaceableAttribute { Name = "MarkerLabels", Value = water.MarkerLabels, Replace = true }, new ReplaceableAttribute { Name = "Destination", Value = water.Destination, Replace = true }, new ReplaceableAttribute { Name = "Path", Value = water.Path, Replace = true }, }; request.Items.Add( new ReplaceableItem { Name = water.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Water added"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
/// <summary> /// Batch Put Attributes. /// <seealso cref="M:Amazon.SimpleDB.AmazonSimpleDB.BatchPutAttributes"/> /// </summary> /// <param name="request">The BatchPutAttributesRequest that defines the parameters of /// the operation.</param> public void BatchPutAttributes(BatchPutAttributesRequest request) { BeginBatchPutAttributes(request); }
/// <summary> /// Batch Put Attributes /// </summary> /// <param name="request">Batch Put Attributes request</param> /// <returns>Batch Put Attributes Response from the service</returns> /// <remarks> /// The BatchPutAttributes operation creates or replaces attributes within one or more items. /// You specify the item name with the Item.X.ItemName parameter. /// You specify new attributes using a combination of the Item.X.Attribute.Y.Name and Item.X.Attribute.Y.Value parameters. /// You specify the first attribute for the first item by the parameters Item.0.Attribute.0.Name and Item.0.Attribute.0.Value, /// the second attribute for the first item by the parameters Item.0.Attribute.1.Name and Item.0.Attribute.1.Value, and so on. /// Attributes are uniquely identified within an item by their name/value combination. For example, a single /// item can have the attributes { "first_name", "first_value" } and { "first_name", /// second_value" }. However, it cannot have two attribute instances where both the Item.X.Attribute.Y.Name and /// Item.X.Attribute.Y.Value are the same. /// Optionally, the requestor can supply the Replace parameter for each individual value. Setting this value /// to true will cause the new attribute value to replace the existing attribute value(s). For example, if an /// item 'I' has the attributes { 'a', '1' }, { 'b', '2'} and { 'b', '3' } and the requestor does a /// BacthPutAttributes of {'I', 'b', '4' } with the Replace parameter set to true, the final attributes of the /// item will be { 'a', '1' } and { 'b', '4' }, replacing the previous values of the 'b' attribute /// with the new value. /// /// </remarks> public BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { return(Invoke <BatchPutAttributesResponse>("BatchPutAttributesResponse.xml")); }
/// <summary> /// Batch Put Attributes /// </summary> /// <param name="request">Batch Put Attributes request</param> /// <returns>Batch Put Attributes Response from the service</returns> /// <remarks> /// The BatchPutAttributes operation creates or replaces attributes within one or more items. /// You specify the item name with the Item.X.ItemName parameter. /// You specify new attributes using a combination of the Item.X.Attribute.Y.Name and Item.X.Attribute.Y.Value parameters. /// You specify the first attribute for the first item by the parameters Item.0.Attribute.0.Name and Item.0.Attribute.0.Value, /// the second attribute for the first item by the parameters Item.0.Attribute.1.Name and Item.0.Attribute.1.Value, and so on. /// Attributes are uniquely identified within an item by their name/value combination. For example, a single /// item can have the attributes { "first_name", "first_value" } and { "first_name", /// second_value" }. However, it cannot have two attribute instances where both the Item.X.Attribute.Y.Name and /// Item.X.Attribute.Y.Value are the same. /// Optionally, the requestor can supply the Replace parameter for each individual value. Setting this value /// to true will cause the new attribute value to replace the existing attribute value(s). For example, if an /// item 'I' has the attributes { 'a', '1' }, { 'b', '2'} and { 'b', '3' } and the requestor does a /// BacthPutAttributes of {'I', 'b', '4' } with the Replace parameter set to true, the final attributes of the /// item will be { 'a', '1' } and { 'b', '4' }, replacing the previous values of the 'b' attribute /// with the new value. /// /// </remarks> public BatchPutAttributesResponse BatchPutAttributes(BatchPutAttributesRequest request) { return(Invoke <BatchPutAttributesResponse>(ConvertBatchPutAttributes(request))); }
/// <summary> /// Batch add data to domain (table) and row (item). /// </summary> /// <param name="batchAttributes">Batch put attributes request.</param> /// <returns>The async task.</returns> public async Task <BatchPutAttributesResponse> BatchPutAttributesAsync(BatchPutAttributesRequest batchAttributes) { return(await _client.BatchPutAttributesAsync(batchAttributes)); }