Example #1
0
        private static async Task DeleteTrigger(IDocumentClient client, string triggerId)
        {
            Uri triggerUri = UriFactory.CreateTriggerUri("mydb", "mystore", triggerId);

            await client.DeleteTriggerAsync(triggerUri);

            Console.WriteLine($"Deleted trigger: {triggerId}");
        }
Example #2
0
        private static async Task DeleteTriggers(IDocumentClient client, Uri collectionUri)
        {
            Console.WriteLine("Deleting triggers");
            IEnumerable <Trigger> triggers = client.CreateTriggerQuery(collectionUri).AsEnumerable();

            foreach (Trigger trigger in triggers)
            {
                await client.DeleteTriggerAsync(trigger.SelfLink);
            }
        }
        /// <summary>
        /// Deletes the trigger.
        /// </summary>
        /// <param name="dbId">The id of the Database to search for, or create.</param>
        /// <param name="collectionId">The id of the document db collection.</param>
        /// <param name="triggerId">The trigger to get or create.</param>
        /// <returns>True if operation is successful, false otherwise</returns>
        public Task DeleteTriggerAsync(string dbId, string collectionId, string triggerId)
        {
            Code.ExpectsNotNullOrWhiteSpaceArgument(dbId, nameof(dbId), TaggingUtilities.ReserveTag(0x2381b156 /* tag_961fw */));
            Code.ExpectsNotNullOrWhiteSpaceArgument(collectionId, nameof(collectionId), TaggingUtilities.ReserveTag(0x2381b157 /* tag_961fx */));
            Code.ExpectsNotNullOrWhiteSpaceArgument(triggerId, nameof(triggerId), TaggingUtilities.ReserveTag(0x2381b158 /* tag_961fy */));

            return(DocumentDbAdapter.ExecuteAndLogAsync(TaggingUtilities.ReserveTag(0x2381b159 /* tag_961fz */),
                                                        async() =>
            {
                IDocumentClient client = await GetDocumentClientAsync().ConfigureAwait(false);

                try
                {
                    await client.DeleteTriggerAsync(UriFactory.CreateTriggerUri(dbId, collectionId, triggerId))
                    .ConfigureAwait(false);
                }
                catch (DocumentClientException clientEx) when(clientEx.StatusCode == HttpStatusCode.NotFound)
                {
                }
            }));
        }