/// <summary> /// Formats and adds the parameter to the <see cref="PutItemRequest"/>. /// </summary> /// <param name="request">The request.</param> /// <param name="loggingEvent">The logging event.</param> /// <returns>Chainable reference to the original request.</returns> public virtual PutItemRequest AddFormatParameter(PutItemRequest request, LoggingEvent loggingEvent) { request.CheckNull("request"); loggingEvent.CheckNull("loggingEvent"); object formattedValue = Layout.Format(loggingEvent); return AddToItemsIfNotNullOrEmpty(request, formattedValue); }
internal Document PutItemHelper(Document doc, PutItemOperationConfig config, bool isAsync) { var currentConfig = config ?? new PutItemOperationConfig(); PutItemRequest req = new PutItemRequest { TableName = TableName, Item = doc.ToAttributeMap() }; req.BeforeRequestEvent += isAsync ? new RequestEventHandler(UserAgentRequestEventHandlerAsync) : new RequestEventHandler(UserAgentRequestEventHandlerSync); if (currentConfig.Expected != null) req.Expected = currentConfig.Expected.ToExpectedAttributeMap(); if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes) { req.ReturnValues = EnumToStringMapper.Convert(currentConfig.ReturnValues); } var resp = DDBClient.PutItem(req); doc.CommitChanges(); Document ret = null; if (currentConfig.ReturnValues == ReturnValues.AllOldAttributes) { ret = Document.FromAttributeMap(resp.PutItemResult.Attributes); } return ret; }
IAsyncResult invokePutItem(PutItemRequest putItemRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new PutItemRequestMarshaller().Marshall(putItemRequest); var unmarshaller = PutItemResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// <para>Creates a new item, or replaces an old item with a new item (including all the attributes).</para> <para>If an item already exists in /// the specified table with the same primary key, the new item completely replaces the existing item. You can perform a conditional put (insert /// a new item if one with the specified primary key doesn't exist), or replace an existing item if it has certain attribute values.</para> /// </summary> /// /// <param name="putItemRequest">Container for the necessary parameters to execute the PutItem service method on AmazonDynamoDB.</param> /// /// <returns>The response from the PutItem service method, as returned by AmazonDynamoDB.</returns> /// /// <exception cref="ProvisionedThroughputExceededException"/> /// <exception cref="ConditionalCheckFailedException"/> /// <exception cref="InternalServerErrorException"/> /// <exception cref="ResourceNotFoundException"/> public PutItemResponse PutItem(PutItemRequest putItemRequest) { IAsyncResult asyncResult = invokePutItem(putItemRequest, null, null, true); return EndPutItem(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the PutItem operation. /// <seealso cref="Amazon.DynamoDB.AmazonDynamoDB.PutItem"/> /// </summary> /// /// <param name="putItemRequest">Container for the necessary parameters to execute the PutItem operation on AmazonDynamoDB.</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 EndPutItem /// operation.</returns> public IAsyncResult BeginPutItem(PutItemRequest putItemRequest, AsyncCallback callback, object state) { return invokePutItem(putItemRequest, callback, state, false); }
/// <summary> /// <para> Creates a new item, or replaces an old item with a new item (including all the attributes). If an item already exists in the /// specified table with the same primary key, the new item completely replaces the existing item. You can perform a conditional put (insert a /// new item if one with the specified primary key doesn't exist), or replace an existing item if it has certain attribute values. </para> /// </summary> /// /// <param name="putItemRequest">Container for the necessary parameters to execute the PutItem service method on AmazonDynamoDB.</param> /// /// <returns>The response from the PutItem service method, as returned by AmazonDynamoDB.</returns> /// /// <exception cref="ProvisionedThroughputExceededException"/> /// <exception cref="ConditionalCheckFailedException"/> /// <exception cref="InternalServerErrorException"/> /// <exception cref="ResourceNotFoundException"/> public PutItemResponse PutItem(PutItemRequest putItemRequest) { IRequest<PutItemRequest> request = new PutItemRequestMarshaller().Marshall(putItemRequest); PutItemResponse response = Invoke<PutItemRequest, PutItemResponse> (request, this.signer, PutItemResponseUnmarshaller.GetInstance()); return response; }
/// <summary> /// Add the specifed string item to the <c>Request.Items</c> collection if it is not empty. /// </summary> /// <param name="request">The <see cref="PutItemRequest"/>.</param> /// <param name="logItem">The log item.</param> /// <returns>Chainable reference to the original request.</returns> protected virtual PutItemRequest AddToItemsIfNotNullOrEmpty(PutItemRequest request, object logItem) { request.CheckNull("request"); if (null != logItem && !string.IsNullOrEmpty(logItem.ToString())) { DynamoDbAttributeBuilder builder = new DynamoDbAttributeBuilder(); switch (Type) { case ParameterType.B: request.Item.Add(Name, builder.BuildAttributeForTypeBinary(logItem)); break; case ParameterType.N: request.Item.Add(Name, builder.BuildAttributeForTypeNumeric(logItem)); break; default: request.Item.Add(Name, builder.BuildAttributeForTypeString(logItem)); break; } } return request; }