public void UpdateActionGroupTest()
        {
            ActionGroupResource expectedParameters = GetCreateOrUpdateActionGroupParameter();

            var handler          = new RecordedDelegatingHandler();
            var insightsClient   = GetMonitorManagementClient(handler);
            var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedParameters, insightsClient.SerializationSettings);

            serializedObject = serializedObject.Replace("{", "{\"name\":\"" + expectedParameters.Name + "\",\"id\":\"" + expectedParameters.Id + "\",");
            var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(serializedObject)
            };

            handler        = new RecordedDelegatingHandler(expectedResponse);
            insightsClient = GetMonitorManagementClient(handler);

            ActionGroupPatchBody bodyParameter = new ActionGroupPatchBody
            {
                Enabled = true,
                Tags    = null
            };

            var result = insightsClient.ActionGroups.Update(
                resourceGroupName: "rg1",
                actionGroupName: expectedParameters.Name,
                actionGroupPatch: bodyParameter);

            AreEqual(expectedParameters, result);
        }
Esempio n. 2
0
        public void UpdateDataCollectionRuleTest()
        {
            var expectedResult = new ResourceForUpdate(new Dictionary <string, string>
            {
                { "tag1", "value1" },
                { "tag2", "value2" }
            });

            var handler          = new RecordedDelegatingHandler();
            var insightsClient   = GetMonitorManagementClient(handler);
            var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expectedResult, insightsClient.SerializationSettings);

            var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(serializedObject)
            };

            handler        = new RecordedDelegatingHandler(expectedResponse);
            insightsClient = GetMonitorManagementClient(handler);

            ActionGroupPatchBody bodyParameter = new ActionGroupPatchBody
            {
                Enabled = true,
                Tags    = null
            };

            var result = insightsClient.DataCollectionRules.Update("rg-amcs-test", "dcrUpdateDataCollectionRuleTest", expectedResult);

            Utilities.AreEqual(expectedResult.Tags, result.Tags);
        }
 public virtual Response <ActionGroupResource> Update(string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("ActionGroupsOperations.Update");
     scope.Start();
     try
     {
         return(RestClient.Update(resourceGroupName, actionGroupName, actionGroupPatch, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 /// <summary>
 /// Updates an existing action group's tags. To update other fields use the
 /// CreateOrUpdate method.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='actionGroupName'>
 /// The name of the action group.
 /// </param>
 /// <param name='actionGroupPatch'>
 /// Parameters supplied to the operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ActionGroupResourceInner> UpdateAsync(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, actionGroupName, actionGroupPatch, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates an existing action group's tags. To update other fields use the
 /// CreateOrUpdate method.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='actionGroupName'>
 /// The name of the action group.
 /// </param>
 /// <param name='actionGroupPatch'>
 /// Parameters supplied to the operation.
 /// </param>
 public static ActionGroupResource Update(this IActionGroupsOperations operations, string resourceGroupName, string actionGroupName, ActionGroupPatchBody actionGroupPatch)
 {
     return(operations.UpdateAsync(resourceGroupName, actionGroupName, actionGroupPatch).GetAwaiter().GetResult());
 }