/// <summary> /// This method uploads a set of documents onto your cloudsearch search domain. /// Your objects must already have been converted to the cloudsearch upload format /// for document batches ( /// </summary> public bool UploadDocuments(List <AWSCloudSearchDocumentDocumentOperation> documents) { ClearErrorInfo(); try { UploadDocumentsRequest uploadRequest = new UploadDocumentsRequest(); uploadRequest.ContentType = "application/json"; uploadRequest.Documents = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(documents) ?? "")); UploadDocumentsResponse uploadResponse = CloudSearchClient.UploadDocuments(uploadRequest); // Check response for errors if (uploadResponse.HttpStatusCode != HttpStatusCode.OK) { ErrorCode = Convert.ToInt32(uploadResponse.HttpStatusCode); ErrorMessage = "Http Error [" + uploadResponse.HttpStatusCode.ToString() + "]"; } } catch (Exception ex) { ErrorCode = -1; ErrorMessage = ex.Message + "::" + ex.InnerException; } return(ErrorCode == 0); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UploadDocumentsResponse response = new UploadDocumentsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("adds", targetDepth)) { var unmarshaller = LongUnmarshaller.Instance; response.Adds = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("deletes", targetDepth)) { var unmarshaller = LongUnmarshaller.Instance; response.Deletes = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("status", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Status = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("warnings", targetDepth)) { var unmarshaller = new ListUnmarshaller <DocumentServiceWarning, DocumentServiceWarningUnmarshaller>(DocumentServiceWarningUnmarshaller.Instance); response.Warnings = unmarshaller.Unmarshall(context); continue; } } return(response); }