/// <summary> /// Deletes one or more attributes associated with an item. If all attributes of the /// item are deleted, the item is deleted. /// /// /// <para> /// <code>DeleteAttributes</code> is an idempotent operation; running it multiple times /// on the same item or attribute does not result in an error response. /// </para> /// /// <para> /// Because Amazon SimpleDB makes multiple copies of item data and uses an eventual consistency /// update model, performing a <a>GetAttributes</a> or <a>Select</a> operation (read) /// immediately after a <code>DeleteAttributes</code> or <a>PutAttributes</a> operation /// (write) might not return updated item data. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteAttributes service method.</param> /// /// <returns>The response from the DeleteAttributes service method, as returned by SimpleDB.</returns> /// <exception cref="Amazon.SimpleDB.Model.AttributeDoesNotExistException"> /// The specified attribute does not exist. /// </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> public DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request) { var marshaller = new DeleteAttributesRequestMarshaller(); var unmarshaller = DeleteAttributesResponseUnmarshaller.Instance; return(Invoke <DeleteAttributesRequest, DeleteAttributesResponse>(request, marshaller, unmarshaller)); }
internal virtual DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request) { var marshaller = DeleteAttributesRequestMarshaller.Instance; var unmarshaller = DeleteAttributesResponseUnmarshaller.Instance; return(Invoke <DeleteAttributesRequest, DeleteAttributesResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteAttributes operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB.DeleteAttributes"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteAttributes 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 <DeleteAttributesResponse> DeleteAttributesAsync(DeleteAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DeleteAttributesRequestMarshaller(); var unmarshaller = DeleteAttributesResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, DeleteAttributesRequest, DeleteAttributesResponse>(request, marshaller, unmarshaller, signer, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteAttributes operation. /// <seealso cref="M:Amazon.SimpleDB.AmazonSimpleDB.DeleteAttributes"/> /// </summary> /// <param name="request">The DeleteAttributesRequest that defines the parameters of /// the operation.</param> public void BeginDeleteAttributes(DeleteAttributesRequest request) { IDictionary <string, string> parameters = ConvertDeleteAttributes(request); SDBAsyncResult result = new SDBAsyncResult(parameters, null); invoke <DeleteAttributesResponse>(result); }
private void TestDeleteAttributes() { List <string> attributeNames = new List <string>(); attributeNames.Add(FOO_ITEM.Attributes[0].Name); attributeNames.Add(FOO_ITEM.Attributes[1].Name); List <Amazon.SimpleDB.Model.Attribute> attributeList = new List <Amazon.SimpleDB.Model.Attribute>(); foreach (string attributeName in attributeNames) { attributeList.Add(new Amazon.SimpleDB.Model.Attribute() { Name = attributeName }); } Assert.IsTrue(DoAttributesExistForItem(Client, FOO_ITEM.Name, domainName, attributeNames)); DeleteAttributesRequest request = new DeleteAttributesRequest() { DomainName = domainName, ItemName = FOO_ITEM.Name, Attributes = attributeList }; Client.DeleteAttributesAsync(request).Wait(); Assert.IsFalse(DoAttributesExistForItem(Client, FOO_ITEM.Name, domainName, attributeNames)); }
public void DeleteItem(string ItemName, string Domain) { Domain = SetDomain(Domain); DeleteAttributesRequest request = new DeleteAttributesRequest().WithDomainName(Domain).WithItemName(ItemName); client.DeleteAttributes(request); }
/** * Convert DeleteAttributesRequest to name value pairs */ private IDictionary <String, String> ConvertDeleteAttributes(DeleteAttributesRequest request) { IDictionary <String, String> parameters = new Dictionary <String, String>(); parameters.Add("Action", "DeleteAttributes"); if (request.IsSetDomainName()) { parameters.Add("DomainName", request.DomainName); } if (request.IsSetItemName()) { parameters.Add("ItemName", request.ItemName); } List <Attribute> deleteAttributesRequestAttributeList = request.Attribute; int deleteAttributesRequestAttributeListIndex = 1; foreach (Attribute deleteAttributesRequestAttribute in deleteAttributesRequestAttributeList) { if (deleteAttributesRequestAttribute.IsSetName()) { parameters.Add("Attribute" + "." + deleteAttributesRequestAttributeListIndex + "." + "Name", deleteAttributesRequestAttribute.Name); } if (deleteAttributesRequestAttribute.IsSetValue()) { parameters.Add("Attribute" + "." + deleteAttributesRequestAttributeListIndex + "." + "Value", deleteAttributesRequestAttribute.Value); } deleteAttributesRequestAttributeListIndex++; } return(parameters); }
/// <summary> /// Updates single item /// </summary> public async Task UpdateItemAsync(string itemId, Dictionary <string, string> newValues, bool removeUnspecifiedAttributes = false) { var itemAttributes = await RetrieveItemAttributesFromDb(itemId, true); if (!itemAttributes.Any()) { return; } var existingAttributes = itemAttributes.ToDictionary(attr => attr.Name, attr => attr); var attributesToUpdate = new List <ReplaceableAttribute>(); var attributesToDelete = new List <Attribute>(); foreach (var(key, value) in newValues) { if (value == "") //the attribute needs to be deleted { if (existingAttributes.ContainsKey(key)) //otherwise it is already not present { attributesToDelete.Add(existingAttributes[key]); } continue; } //if it is already present replace it's value, otherwise add it var replace = existingAttributes.ContainsKey(key); attributesToUpdate.Add(new ReplaceableAttribute(key, value, replace)); } if (removeUnspecifiedAttributes) { foreach (var(key, value) in existingAttributes) { if (key != ExistsAttributeName && !newValues.ContainsKey(key)) { attributesToDelete.Add(value); } } } try { //update the attributes var putRequest = new PutAttributesRequest(_simpleDbDomain, itemId, attributesToUpdate, new UpdateCondition(ExistsAttributeName, "1", true)); await _client.PutAttributesAsync(putRequest); //delete the attributes that need to be deleted if (attributesToDelete.Any()) { var delRequest = new DeleteAttributesRequest(_simpleDbDomain, itemId, attributesToDelete); await _client.DeleteAttributesAsync(delRequest); } } catch (AmazonSimpleDBException e) { Console.WriteLine(e.StackTrace); throw; } }
/// <summary> /// Initiates the asynchronous execution of the DeleteAttributes operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteAttributes 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 virtual Task <DeleteAttributesResponse> DeleteAttributesAsync(DeleteAttributesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = DeleteAttributesRequestMarshaller.Instance; var unmarshaller = DeleteAttributesResponseUnmarshaller.Instance; return(InvokeAsync <DeleteAttributesRequest, DeleteAttributesResponse>(request, marshaller, unmarshaller, cancellationToken)); }
public void DeleteWorkItem(string workItemId) { var deleteAttributesRequest = new DeleteAttributesRequest { ItemName = workItemId, DomainName = _domain }; _client.DeleteAttributes(deleteAttributesRequest); }
public void DeleteWorkStep(string path) { var deleteAttributesRequest = new DeleteAttributesRequest { ItemName = path, DomainName = _domain }; _client.DeleteAttributes(deleteAttributesRequest); }
internal virtual DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteAttributesRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteAttributesResponseUnmarshaller.Instance; return(Invoke <DeleteAttributesResponse>(request, options)); }
/// <summary> /// Deletes one or more attributes associated with an item. If all attributes of the /// item are deleted, the item is deleted. /// /// /// <para> /// <code>DeleteAttributes</code> is an idempotent operation; running it multiple times /// on the same item or attribute does not result in an error response. /// </para> /// /// <para> /// Because Amazon SimpleDB makes multiple copies of item data and uses an eventual consistency /// update model, performing a <a>GetAttributes</a> or <a>Select</a> operation (read) /// immediately after a <code>DeleteAttributes</code> or <a>PutAttributes</a> operation /// (write) might not return updated item data. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteAttributes 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 DeleteAttributes service method, as returned by SimpleDB.</returns> /// <exception cref="Amazon.SimpleDB.Model.AttributeDoesNotExistException"> /// The specified attribute does not exist. /// </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> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sdb-2009-04-15/DeleteAttributes">REST API Reference for DeleteAttributes Operation</seealso> public virtual Task <DeleteAttributesResponse> DeleteAttributesAsync(DeleteAttributesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteAttributesRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteAttributesResponseUnmarshaller.Instance; return(InvokeAsync <DeleteAttributesResponse>(request, options, cancellationToken)); }
/** * Convert DeleteAttributesRequest to name value pairs */ private static IDictionary <string, string> ConvertDeleteAttributes(DeleteAttributesRequest request) { IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters["Action"] = "DeleteAttributes"; if (request.IsSetDomainName()) { parameters["DomainName"] = request.DomainName; } if (request.IsSetItemName()) { parameters["ItemName"] = request.ItemName; } List <Attribute> deleteAttributesRequestAttributeList = request.Attribute; int deleteAttributesRequestAttributeListIndex = 1; foreach (Attribute deleteAttributesRequestAttribute in deleteAttributesRequestAttributeList) { if (deleteAttributesRequestAttribute.IsSetName()) { parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "Name")] = deleteAttributesRequestAttribute.Name; } if (deleteAttributesRequestAttribute.IsSetValue()) { parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "Value")] = deleteAttributesRequestAttribute.Value; } if (deleteAttributesRequestAttribute.IsSetNameEncoding()) { parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "NameEncoding")] = deleteAttributesRequestAttribute.NameEncoding; } if (deleteAttributesRequestAttribute.IsSetValueEncoding()) { parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "ValueEncoding")] = deleteAttributesRequestAttribute.ValueEncoding; } deleteAttributesRequestAttributeListIndex++; } if (request.IsSetExpected()) { UpdateCondition deleteAttributesRequestExpected = request.Expected; if (deleteAttributesRequestExpected.IsSetName()) { parameters[String.Concat("Expected", ".", "Name")] = deleteAttributesRequestExpected.Name; } if (deleteAttributesRequestExpected.IsSetValue()) { parameters[String.Concat("Expected", ".", "Value")] = deleteAttributesRequestExpected.Value; } if (deleteAttributesRequestExpected.IsSetExists()) { parameters[String.Concat("Expected", ".", "Exists")] = deleteAttributesRequestExpected.Exists.ToString().ToLower(CultureInfo.InvariantCulture); } } return(parameters); }
public void TearDown() { using (AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { DeleteAttributesRequest request = new DeleteAttributesRequest(); request.DomainName = RouteRepository.DomainName; request.ItemName = testRoute.Id.ToString(); client.DeleteAttributes(request); } }
// // RoleProvider.RemoveUsersFromRoles // public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames) { foreach (string username in usernames) { foreach (string rolename in rolenames) { DeleteAttributesRequest request = new DeleteAttributesRequest().WithDomainName(domain).WithItemName(username + "-" + rolename); client.DeleteAttributes(request); } } }
private static IDictionary <string, string> ConvertDeleteAttributes(DeleteAttributesRequest request) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["Action"] = "DeleteAttributes"; if (request.IsSetDomainName()) { dictionary["DomainName"] = request.DomainName; } if (request.IsSetItemName()) { dictionary["ItemName"] = request.ItemName; } List <Amazon.SimpleDB.Model.Attribute> list = request.Attribute; int num = 1; foreach (Amazon.SimpleDB.Model.Attribute attribute in list) { if (attribute.IsSetName()) { dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "Name" })] = attribute.Name; } if (attribute.IsSetValue()) { dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "Value" })] = attribute.Value; } if (attribute.IsSetNameEncoding()) { dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "NameEncoding" })] = attribute.NameEncoding; } if (attribute.IsSetValueEncoding()) { dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "ValueEncoding" })] = attribute.ValueEncoding; } num++; } if (request.IsSetExpected()) { UpdateCondition expected = request.Expected; if (expected.IsSetName()) { dictionary["Expected" + "." + "Name"] = expected.Name; } if (expected.IsSetValue()) { dictionary["Expected" + "." + "Value"] = expected.Value; } if (expected.IsSetExists()) { dictionary["Expected" + "." + "Exists"] = expected.Exists.ToString().ToLower(); } } return(dictionary); }
public override bool DeleteUser(string userName, bool deleteAllRelatedData) { DeleteAttributesRequest request = new DeleteAttributesRequest() { DomainName = Settings.Default.AWSMembershipDomain, ItemName = userName }; this._simpleDBClient.DeleteAttributes(request); return(true); }
/// <summary> /// Deletes single item based on the id /// </summary> public async Task <DeleteAttributesResponse> DeleteItemAsync(string itemId) { try { var deleteAttrRequest = new DeleteAttributesRequest(_simpleDbDomain, itemId); return(await _client.DeleteAttributesAsync(deleteAttrRequest)); } catch (AmazonSimpleDBException e) { Console.WriteLine(e.StackTrace); throw; } }
internal DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request) { var task = DeleteAttributesAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Deletes the attributes. /// </summary> /// <param name="domainName"></param> /// <param name="itemName"></param> /// <param name="names"></param> public void DeleteAttributes(string domainName, string itemName, IEnumerable <string> names) { List <Attribute> attributes = names.Select(name => new Attribute { Name = name }).ToList(); var request = new DeleteAttributesRequest { DomainName = domainName, ItemName = itemName, Attribute = attributes }; Client.DeleteAttributes(request); }
public async Task DeleteTodoItemAsync(TodoItem todoItem) { try { var attributeList = ToSimpleDBAttributes(todoItem); var request = new DeleteAttributesRequest() { DomainName = tableName, ItemName = todoItem.ID, Attributes = attributeList }; await client.DeleteAttributesAsync(request); } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } }
protected void DeletePetButton_Click(object sender, EventArgs e) { DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest() { DomainName = Properties.Settings.Default.PetBoardPublicDomainName, ItemName = this._itemName }; _simpleDBClient.DeleteAttributes(deleteRequest); if (DomainHelper.DoesDomainExist(this._domainName, _simpleDBClient)) { deleteRequest.DomainName = this._domainName; _simpleDBClient.DeleteAttributes(deleteRequest); } Response.Redirect("~/Default.aspx"); }
private void btnDeletetAttributes_Click(object sender, RoutedEventArgs e) { SimpleDBResponseEventHandler <object, ResponseEventArgs> responseHandler = null; responseHandler = delegate(object senderAmazon, ResponseEventArgs args) { SimpleDB.Client.OnSimpleDBResponse -= responseHandler; DeleteAttributesResponse deleteResponse = args.Response as DeleteAttributesResponse; this.Dispatcher.BeginInvoke(() => { this.Attributes.Clear(); string message = string.Empty; if (null != deleteResponse) { message = "Attribute(s) deleted successfully."; } else { AmazonSimpleDBException exception = args.Response as AmazonSimpleDBException; if (null != exception) { message = "Error: " + exception.Message; } } this.FetchingOrDeletingAttributeMessage = message; }); }; SimpleDB.Client.OnSimpleDBResponse += responseHandler; DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest() { DomainName = this.DomainName, ItemName = this.ItemName }; List <Amazon.SimpleDB.Model.Attribute> deleteItem = deleteRequest.Attribute; List <AttributeAndValue> aAndV = GetListAttributeAndValueFromString(this.AttributesAndValuesToPut); aAndV.ForEach(a => deleteItem.Add(new Amazon.SimpleDB.Model.Attribute().WithName(a.Attribute).WithValue(a.Value))); //deleteItem.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Category").WithValue("Clothes")); //deleteItem.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Subcategory").WithValue("Sweater")); SimpleDB.Client.DeleteAttributes(deleteRequest); }
public async Task DeleteNewsItem(string id) { var client = GetClient(); DeleteAttributesRequest request = new DeleteAttributesRequest(); //request.Attributes.Add(new Amazon.SimpleDB.Model.Attribute { Name = id }); request.DomainName = Domain; request.ItemName = id; try { DeleteAttributesResponse response = await client.DeleteAttributesAsync(request); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
public override int DeleteProfiles(string[] usernames) { // I think we can make sure of a new sdb feature, grouped requests. // It will be in the next update. int deleted = 0; foreach (string username in usernames) { try { DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest().WithDomainName(domain).WithItemName(username); client.DeleteAttributes(deleteRequest); deleted++; } catch (Exception err) { WriteToEventLog(err, "DeleteProfiles"); } } return(deleted); }
// // MembershipProvider.DeleteUser // public override bool DeleteUser(string username, bool deleteAllRelatedData) { try { DeleteAttributesRequest request = new DeleteAttributesRequest().WithDomainName(domain).WithItemName(username); client.DeleteAttributes(request); return(true); } catch (Exception e) { if (WriteExceptionsToEventLog) { WriteToEventLog(e, "DeleteUser"); throw new ProviderException(exceptionMessage); } else { throw e; } } return(false); }
/// <summary> /// Delete Attributes /// </summary> /// <param name="request">Delete Attributes request</param> /// <returns>Delete Attributes Response from the service</returns> /// <remarks> /// Deletes one or more attributes associated with the item. If all attributes of an item are deleted, the item is /// deleted. /// /// </remarks> public DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request) { return(Invoke <DeleteAttributesResponse>("DeleteAttributesResponse.xml")); }
public void Put(string domainName, string itemName, bool isPublic, AmazonSimpleDBClient sdbClient) { if (String.IsNullOrEmpty(domainName) || String.IsNullOrEmpty(itemName)) { return; } DomainHelper.CheckForDomain(domainName, sdbClient); PutAttributesRequest putAttrRequest = new PutAttributesRequest() { DomainName = domainName, ItemName = itemName }; putAttrRequest.Attributes = new List <ReplaceableAttribute>() { new ReplaceableAttribute { Name = "Public", Value = isPublic.ToString(), Replace = true }, new ReplaceableAttribute { Name = "PhotoThumbUrl", Value = !String.IsNullOrEmpty(this.PhotoThumbUrl) ? this.PhotoThumbUrl : String.Empty, Replace = true }, new ReplaceableAttribute { Name = "Name", Value = this.Name, Replace = true }, new ReplaceableAttribute { Name = "Type", Value = this.Type, Replace = true }, new ReplaceableAttribute { Name = "Breed", Value = this.Breed, Replace = true }, new ReplaceableAttribute { Name = "Sex", Value = this.Sex, Replace = true }, new ReplaceableAttribute { Name = "Birthdate", Value = this.Birthdate, Replace = true }, new ReplaceableAttribute { Name = "Likes", Value = this.Likes, Replace = true }, new ReplaceableAttribute { Name = "Dislikes", Value = this.Dislikes, Replace = true } }; sdbClient.PutAttributes(putAttrRequest); if (isPublic) { DomainHelper.CheckForDomain(Settings.Default.PetBoardPublicDomainName, sdbClient); putAttrRequest.DomainName = Settings.Default.PetBoardPublicDomainName; sdbClient.PutAttributes(putAttrRequest); } else { DeleteAttributesRequest deleteAttributeRequest = new DeleteAttributesRequest() { DomainName = Settings.Default.PetBoardPublicDomainName, ItemName = itemName }; sdbClient.DeleteAttributes(deleteAttributeRequest); } }
/// <summary> /// Delete Attributes /// </summary> /// <param name="request">Delete Attributes request</param> /// <returns>Delete Attributes Response from the service</returns> /// <remarks> /// Deletes one or more attributes associated with the item. If all attributes of an item are deleted, the item is /// deleted. /// /// </remarks> public DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request) { return(Invoke <DeleteAttributesResponse>(ConvertDeleteAttributes(request))); }