Example #1
0
        public async Task UpdateForwardingRule()
        {
            // ARRANGE
            var forwardingRuleData = new ForwardingRuleData();

            forwardingRuleData.DomainName = "test.com.";
            forwardingRuleData.TargetDnsServers.Add(new TargetDnsServer()
            {
                IPAddress = "10.0.0.3",
            });

            var forwardingRuleName    = Recording.GenerateAssetName("forwardingRule-");
            var createdForwardingRule = await dnsForwardingRuleset.GetForwardingRules().CreateOrUpdateAsync(WaitUntil.Completed, forwardingRuleName, forwardingRuleData);

            var newTagKey   = Recording.GenerateAlphaNumericId("tagKey");
            var newTagValue = Recording.GenerateAlphaNumericId("tagValue");

            var patchableForwardingRuleData = new ForwardingRulePatch();

            patchableForwardingRuleData.Metadata.Add(newTagKey, newTagValue);

            // ACT
            var patchedForwardingRule = await createdForwardingRule.Value.UpdateAsync(patchableForwardingRuleData);

            // ASSERT
            CollectionAssert.AreEquivalent(patchedForwardingRule.Value.Data.Metadata, patchableForwardingRuleData.Metadata);
        }
        public virtual Response <ForwardingRuleResource> Update(ForwardingRulePatch patch, string ifMatch = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _forwardingRuleClientDiagnostics.CreateScope("ForwardingRuleResource.Update");
            scope.Start();
            try
            {
                var response = _forwardingRuleRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, ifMatch, cancellationToken);
                return(Response.FromValue(new ForwardingRuleResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }