protected override void ProcessRecord()
 {
     AmazonSimpleDB client = base.GetClient();
     Amazon.SimpleDB.Model.DeleteAttributesRequest request = new Amazon.SimpleDB.Model.DeleteAttributesRequest();
     request.DomainName = this._DomainName;
     request.ItemName = this._ItemName;
     Amazon.SimpleDB.Model.DeleteAttributesResponse response = client.DeleteAttributes(request);
 }
        protected void DeletePetButton_Click(object sender, EventArgs e)
        {
            DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest()
                .WithDomainName(Properties.Settings.Default.PetBoardPublicDomainName)
                .WithItemName(this._itemName);
            _simpleDBClient.DeleteAttributes(deleteRequest);

            if (DomainHelper.DoesDomainExist(this._domainName, _simpleDBClient))
            {
                deleteRequest.DomainName = this._domainName;
                _simpleDBClient.DeleteAttributes(deleteRequest);
            }

            Response.Redirect("~/Default.aspx");
        }
		internal DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request)
        {
            var task = DeleteAttributesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
	    DeleteAttributesResponse AmazonSimpleDB.DeleteAttributes(DeleteAttributesRequest request)
	    {
	        throw new NotImplementedException();
	    }
Exemple #5
0
        public static void Main(string[] args)
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                Console.WriteLine("===========================================");
                Console.WriteLine("Getting Started with Amazon SimpleDB");
                Console.WriteLine("===========================================\n");

                // Creating a domain
                Console.WriteLine("Creating domain called MyStore.\n");
                String domainName = "MyStore";
                CreateDomainRequest createDomain = (new CreateDomainRequest()).WithDomainName(domainName);
                sdb.CreateDomain(createDomain);

                // Listing domains
                ListDomainsResponse sdbListDomainsResponse = sdb.ListDomains(new ListDomainsRequest());
                if (sdbListDomainsResponse.IsSetListDomainsResult())
                {
                    ListDomainsResult listDomainsResult = sdbListDomainsResponse.ListDomainsResult;
                    Console.WriteLine("List of domains:\n");
                    foreach (String domain in listDomainsResult.DomainName)
                    {
                        Console.WriteLine("  " + domain);
                    }
                }
                Console.WriteLine();

                // Putting data into a domain
                Console.WriteLine("Putting data into MyStore domain.\n");
                String itemNameOne = "Item_01";
                PutAttributesRequest putAttributesActionOne = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameOne);
                List<ReplaceableAttribute> attributesOne = putAttributesActionOne.Attribute;
                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"));
                attributesOne.Add(new ReplaceableAttribute().WithName("Color").WithValue("Siamese"));
                attributesOne.Add(new ReplaceableAttribute().WithName("Size").WithValue("Small"));
                attributesOne.Add(new ReplaceableAttribute().WithName("Size").WithValue("Medium"));
                attributesOne.Add(new ReplaceableAttribute().WithName("Size").WithValue("Large"));
                sdb.PutAttributes(putAttributesActionOne);

                String itemNameTwo = "Item_02";
                PutAttributesRequest putAttributesActionTwo = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameTwo);
                List<ReplaceableAttribute> attributesTwo = putAttributesActionTwo.Attribute;
                attributesTwo.Add(new ReplaceableAttribute().WithName("Category").WithValue("Clothes"));
                attributesTwo.Add(new ReplaceableAttribute().WithName("Subcategory").WithValue("Pants"));
                attributesTwo.Add(new ReplaceableAttribute().WithName("Name").WithValue("Designer Jeans"));
                attributesTwo.Add(new ReplaceableAttribute().WithName("Color").WithValue("Paisley Acid Wash"));
                attributesTwo.Add(new ReplaceableAttribute().WithName("Size").WithValue("30x32"));
                attributesTwo.Add(new ReplaceableAttribute().WithName("Size").WithValue("32x32"));
                attributesTwo.Add(new ReplaceableAttribute().WithName("Size").WithValue("32x34"));
                sdb.PutAttributes(putAttributesActionTwo);

                String itemNameThree = "Item_03";
                PutAttributesRequest putAttributesActionThree = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameThree);
                List<ReplaceableAttribute> attributesThree = putAttributesActionThree.Attribute;
                attributesThree.Add(new ReplaceableAttribute().WithName("Category").WithValue("Clothes"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Subcategory").WithValue("Pants"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Name").WithValue("Sweatpants"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Color").WithValue("Blue"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Color").WithValue("Yellow"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Color").WithValue("Pink"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Size").WithValue("Large"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Year").WithValue("2006"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Year").WithValue("2007"));

                sdb.PutAttributes(putAttributesActionThree);

                String itemNameFour = "Item_04";
                PutAttributesRequest putAttributesActionFour = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameFour);
                List<ReplaceableAttribute> attributesFour = putAttributesActionFour.Attribute;
                attributesFour.Add(new ReplaceableAttribute().WithName("Category").WithValue("Car Parts"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Subcategory").WithValue("Engine"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Name").WithValue("Turbos"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Make").WithValue("Audi"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Model").WithValue("S4"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Year").WithValue("2000"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Year").WithValue("2001"));
                attributesFour.Add(new ReplaceableAttribute().WithName("Year").WithValue("2002"));
                sdb.PutAttributes(putAttributesActionFour);

                String itemNameFive = "Item_05";
                PutAttributesRequest putAttributesActionFive = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameFive);
                List<ReplaceableAttribute> attributesFive = putAttributesActionFive.Attribute;
                attributesFive.Add(new ReplaceableAttribute().WithName("Category").WithValue("Car Parts"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Subcategory").WithValue("Emissions"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Name").WithValue("O2 Sensor"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Make").WithValue("Audi"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Model").WithValue("S4"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Year").WithValue("2000"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Year").WithValue("2001"));
                attributesFive.Add(new ReplaceableAttribute().WithName("Year").WithValue("2002"));
                sdb.PutAttributes(putAttributesActionFive);

                // Getting data from a domain
                Console.WriteLine("Print attributes with the attribute Category that contain the value Clothes.\n");
                String selectExpression = "Select * From MyStore Where Category = 'Clothes'";
                SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression);
                SelectResponse selectResponse = sdb.Select(selectRequestAction);

                if (selectResponse.IsSetSelectResult())
                {
                    SelectResult selectResult = selectResponse.SelectResult;
                    foreach (Item item in selectResult.Item)
                    {
                        Console.WriteLine("  Item");
                        if (item.IsSetName())
                        {
                            Console.WriteLine("    Name: {0}", item.Name);
                        }
                        foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute)
                        {
                            Console.WriteLine("      Attribute");
                            if (attribute.IsSetName())
                            {
                                Console.WriteLine("        Name: {0}", attribute.Name);
                            }
                            if (attribute.IsSetValue())
                            {
                                Console.WriteLine("        Value: {0}", attribute.Value);
                            }
                        }
                    }
                }
                Console.WriteLine();

                // Deleting values from an attribute
                Console.WriteLine("Deleting Blue attributes in Item_O3.\n");
                Amazon.SimpleDB.Model.Attribute deleteValueAttribute = new Amazon.SimpleDB.Model.Attribute().WithName("Color").WithValue("Blue");
                DeleteAttributesRequest deleteValueAction = new DeleteAttributesRequest().WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(deleteValueAttribute);
                sdb.DeleteAttributes(deleteValueAction);

                //Deleting an attribute
                Console.WriteLine("Deleting attribute Year in Item_O3.\n");
                Amazon.SimpleDB.Model.Attribute deleteAttribute = new Amazon.SimpleDB.Model.Attribute().WithName("Year");
                DeleteAttributesRequest deleteAttributeAction = new DeleteAttributesRequest().WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(deleteAttribute);
                sdb.DeleteAttributes(deleteAttributeAction);

                //Replacing an attribute
                Console.WriteLine("Replace Size of Item_03 with Medium.\n");
                ReplaceableAttribute replaceableAttribute = new ReplaceableAttribute().WithName("Size").WithValue("Medium").WithReplace(true);
                PutAttributesRequest replaceAction = new PutAttributesRequest().WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(replaceableAttribute);
                sdb.PutAttributes(replaceAction);

                //Deleting an item
                Console.WriteLine("Deleting Item_03 item.\n");
                DeleteAttributesRequest deleteItemAction = new DeleteAttributesRequest().WithDomainName("MyStore").WithItemName("Item_03");
                sdb.DeleteAttributes(deleteAttributeAction);

                //Deleting a domain
                Console.WriteLine("Deleting MyStore domain.\n");
                DeleteDomainRequest deleteDomainAction = new DeleteDomainRequest().WithDomainName("MyStore");
                sdb.DeleteDomain(deleteDomainAction);

            }
            catch (AmazonSimpleDBException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
        /// <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="AttributeDoesNotExistException">
        /// The specified attribute does not exist.
        /// </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>
        public DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request)
        {
            var marshaller = new DeleteAttributesRequestMarshaller();
            var unmarshaller = DeleteAttributesResponseUnmarshaller.Instance;

            return Invoke<DeleteAttributesRequest,DeleteAttributesResponse>(request, marshaller, unmarshaller);
        }
        public void TearDown()
        {
            //A post-requisite for testing SimpleDB objects. Ensure that all the Domains and Item created are deleted before we exit the test-class.
            bool hasCallbackArrived = false;
            //1. Remove the attribute (that was set during one of the test cases) as well.
            hasCallbackArrived = false;

            SimpleDBResponseEventHandler<object, ResponseEventArgs> handler2 = null;
            handler2 = delegate(object sender, ResponseEventArgs args)
            {
                //Unhook from event.
                _client.OnSimpleDBResponse -= handler2;
                hasCallbackArrived = true;
            };
            _client.OnSimpleDBResponse += handler2;

            DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest()
            {
                DomainName = _domainName_UnitTesting,
                ItemName = _itemName_UnitTesting
            };

            deleteRequest.Attribute.Add(
                new Amazon.SimpleDB.Model.Attribute
                    {
                        Name = "Name",
                        Value = "Name_1"
                    }
            );
            deleteRequest.Attribute.Add(
                new Amazon.SimpleDB.Model.Attribute
                {
                    Name = "Color",
                    Value = "blue"
                }
            );
            deleteRequest.Attribute.Add(
                new Amazon.SimpleDB.Model.Attribute
                {
                    Name = "Size",
                    Value = "Small"
                }
            );
            deleteRequest.Attribute.Add(
                new Amazon.SimpleDB.Model.Attribute
                {
                    Name = "Size",
                    Value = "Medium"
                }
            );

            _client.DeleteAttributes(deleteRequest);

            //Wait till the request is actually carried out.
            EnqueueConditional(() => hasCallbackArrived);

            //2.. Delete the normal domain.
            hasCallbackArrived = false;
            SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null;
            handler = delegate(object sender, ResponseEventArgs args)
            {
                //Unhook from event.
                _client.OnSimpleDBResponse -= handler;
                hasCallbackArrived = true;
            };
            _client.OnSimpleDBResponse += handler;

            _client.BeginDeleteDomain(new Amazon.SimpleDB.Model.DeleteDomainRequest { DomainName = _domainName_UnitTesting });

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueTestComplete();
        }
        public void AttributeTestB_DeleteAttribute_ForException_WithoutItem()
        {
            bool hasCallbackArrived = false;
            string actualValue = string.Empty;
            string expectedValue = "The request must contain the parameter ItemName";
            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;
            DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest()
            {
                DomainName = _domainName_UnitTesting
            };
            _client.DeleteAttributes(deleteRequest);

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue));
            EnqueueTestComplete();
        }
Exemple #9
0
        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().WithDomainName(domainName).WithItemName(itemName);
            putAttrRequest.WithAttribute(
                    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().WithDomainName(Settings.Default.PetBoardPublicDomainName).WithItemName(itemName);
                sdbClient.DeleteAttributes(deleteAttributeRequest);
            }
        }
        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);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteAttributes operation.
        /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteAttributes 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 EndDeleteAttributes
        ///         operation.</returns>
        public IAsyncResult BeginDeleteAttributes(DeleteAttributesRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DeleteAttributesRequestMarshaller();
            var unmarshaller = DeleteAttributesResponseUnmarshaller.Instance;

            return BeginInvoke<DeleteAttributesRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
		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);
			}
		}
Exemple #13
0
 //
 // 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);
         }
     }
 }
        /// <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);
        }
        /// <summary>
        /// <para> Deletes one or more attributes associated with an item. If all attributes of the item are deleted, the item is deleted. </para>
        /// <para><b>NOTE:</b> If DeleteAttributes is called without being passed any attributes or values specified, all the attributes for the item
        /// are deleted. </para> <para> <c>DeleteAttributes</c> 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 GetAttributes or Select operation (read) immediately after a <c>DeleteAttributes</c> or PutAttributes operation
        /// (write) might not return updated item data. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteAttributes service method on
        /// AmazonSimpleDB.</param>
        /// 
        /// <exception cref="T:Amazon.SimpleDB.Model.InvalidParameterValueException" />
        /// <exception cref="T:Amazon.SimpleDB.Model.NoSuchDomainException" />
        /// <exception cref="T:Amazon.SimpleDB.Model.AttributeDoesNotExistException" />
        /// <exception cref="T:Amazon.SimpleDB.Model.MissingParameterException" />
		public DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest request)
        {
            var task = DeleteAttributesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        public void AttributeTestB_DeleteAttribute()
        {
            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;
                DeleteAttributesResponse response = args.Response as DeleteAttributesResponse;
                if (null != response)
                {
                    actualValue = true;
                }
                hasCallbackArrived = true;
            };

            //Hook to event
            _client.OnSimpleDBResponse += handler;
            DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest()
            {
                DomainName = _domainName_UnitTesting,
                ItemName = "ItemB"
            };
            List<Amazon.SimpleDB.Model.Attribute> deleteItem = deleteRequest.Attribute;

            deleteItem.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Location").WithValue("Hydrabad"));

            _client.DeleteAttributes(deleteRequest);

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue));
            EnqueueTestComplete();
        }
        /// <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);
        }
        public void AttributeTestB_DeleteAttribute_WithWrongItemName()
        {
            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;
                DeleteAttributesResponse response = args.Response as DeleteAttributesResponse;
                if (null != response)
                {
                    actualValue = true;
                }
                hasCallbackArrived = true;
            };

            //Hook to event
            _client.OnSimpleDBResponse += handler;
            DeleteAttributesRequest deleteRequest = new DeleteAttributesRequest()
            {
                DomainName = _domainName_UnitTesting,
                ItemName = "WrongName"
            };
            _client.DeleteAttributes(deleteRequest);

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue));
            EnqueueTestComplete();
        }
Exemple #19
0
 public override void DeleteItem(string ItemName,string Domain)
 {
     Domain = SetDomain(Domain);
     DeleteAttributesRequest request = new DeleteAttributesRequest().WithDomainName(Domain).WithItemName(ItemName);
     client.DeleteAttributes(request);
 }
Exemple #20
0
        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;
        }
Exemple #21
0
        //
        // 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>
        /// Initiates the asynchronous execution of the DeleteAttributes operation.
        /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB"/>
        /// </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, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteAttributesRequestMarshaller();
            var unmarshaller = DeleteAttributesResponseUnmarshaller.Instance;

            return InvokeAsync<DeleteAttributesRequest,DeleteAttributesResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 /// <summary>
 /// <para> Deletes one or more attributes associated with an item. If all attributes of the item are deleted, the item is deleted. </para>
 /// <para><b>NOTE:</b> If DeleteAttributes is called without being passed any attributes or values specified, all the attributes for the item
 /// are deleted. </para> <para> <c>DeleteAttributes</c> 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 GetAttributes or Select operation (read) immediately after a <c>DeleteAttributes</c> or PutAttributes operation
 /// (write) might not return updated item data. </para>
 /// </summary>
 /// 
 /// <param name="deleteAttributesRequest">Container for the necessary parameters to execute the DeleteAttributes service method on
 ///          AmazonSimpleDB.</param>
 /// 
 /// <exception cref="InvalidParameterValueException"/>
 /// <exception cref="NoSuchDomainException"/>
 /// <exception cref="AttributeDoesNotExistException"/>
 /// <exception cref="MissingParameterException"/>
 public DeleteAttributesResponse DeleteAttributes(DeleteAttributesRequest deleteAttributesRequest)
 {
     IAsyncResult asyncResult = invokeDeleteAttributes(deleteAttributesRequest, null, null, true);
     return EndDeleteAttributes(asyncResult);
 }
	    IAsyncResult AmazonSimpleDB.BeginDeleteAttributes(DeleteAttributesRequest request, AsyncCallback callback, object state)
	    {
	        throw new NotImplementedException();
	    }
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteAttributes operation.
 /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB.DeleteAttributes"/>
 /// </summary>
 /// 
 /// <param name="deleteAttributesRequest">Container for the necessary parameters to execute the DeleteAttributes 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 BeginDeleteAttributes(DeleteAttributesRequest deleteAttributesRequest, AsyncCallback callback, object state)
 {
     return invokeDeleteAttributes(deleteAttributesRequest, callback, state, false);
 }
 public override bool DeleteUser(string userName, bool deleteAllRelatedData)
 {
     DeleteAttributesRequest request = new DeleteAttributesRequest()
         .WithDomainName(Settings.Default.AWSMembershipDomain)
         .WithItemName(userName);
     this._simpleDBClient.DeleteAttributes(request);
     return true;
 }
 IAsyncResult invokeDeleteAttributes(DeleteAttributesRequest deleteAttributesRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DeleteAttributesRequestMarshaller().Marshall(deleteAttributesRequest);
     var unmarshaller = DeleteAttributesResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
        /// <summary>
        /// <para> Deletes one or more attributes associated with an item. If all attributes of the item are deleted, the item is deleted. </para>
        /// <para><b>NOTE:</b> If DeleteAttributes is called without being passed any attributes or values specified, all the attributes for the item
        /// are deleted. </para> <para> <c>DeleteAttributes</c> 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 GetAttributes or Select operation (read) immediately after a <c>DeleteAttributes</c> or PutAttributes operation
        /// (write) might not return updated item data. </para>
        /// </summary>
        /// 
        /// <param name="deleteAttributesRequest">Container for the necessary parameters to execute the DeleteAttributes service method on
        /// AmazonSimpleDB.</param>
        /// 
        /// <exception cref="T:Amazon.SimpleDB.Model.InvalidParameterValueException" />
        /// <exception cref="T:Amazon.SimpleDB.Model.NoSuchDomainException" />
        /// <exception cref="T:Amazon.SimpleDB.Model.AttributeDoesNotExistException" />
        /// <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<DeleteAttributesResponse> DeleteAttributesAsync(DeleteAttributesRequest deleteAttributesRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteAttributesRequestMarshaller();
            var unmarshaller = DeleteAttributesResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DeleteAttributesRequest, DeleteAttributesResponse>(deleteAttributesRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
 public void DeleteWorkStep(string path)
 {
     var deleteAttributesRequest = new DeleteAttributesRequest { ItemName = path, DomainName = _domain};
     _client.DeleteAttributes(deleteAttributesRequest);
 }