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 <DataCollectionRuleResource> Update(ResourceForUpdate body, CancellationToken cancellationToken = default) { Argument.AssertNotNull(body, nameof(body)); using var scope = _dataCollectionRuleClientDiagnostics.CreateScope("DataCollectionRuleResource.Update"); scope.Start(); try { var response = _dataCollectionRuleRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken); return(Response.FromValue(new DataCollectionRuleResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Executes the cmdlet. Update-AzDataCollectionRule /// </summary> protected override void ProcessRecordInternal() { switch (ParameterSetName) { case ByName: break; case ByInputObject: RuleId = InputObject.Id; SetNameAndResourceFromResourceId(); break; case ByResourceId: SetNameAndResourceFromResourceId(); break; default: throw new Exception("Unkown ParameterSetName"); } var resourceForUpdate = new ResourceForUpdate(); if (Tag != null) { resourceForUpdate.Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); } if (ShouldProcess( target: string.Format("Data collection rule '{0}' in resource group '{1}'", RuleName, ResourceGroupName), action: "Update a data collection rule")) { var dcrRespone = this.MonitorManagementClient.DataCollectionRules.Update( resourceGroupName: ResourceGroupName, dataCollectionRuleName: RuleName, body: resourceForUpdate ); var output = new PSDataCollectionRuleResource(dcrRespone); WriteObject(sendToPipeline: output); } }
/// <summary> /// Updates part of a data collection rule. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='dataCollectionRuleName'> /// The name of the data collection rule. The name is case insensitive. /// </param> /// <param name='body'> /// The payload /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataCollectionRuleResource> UpdateAsync(this IDataCollectionRules operations, string resourceGroupName, string dataCollectionRuleName, ResourceForUpdate body = default(ResourceForUpdate), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, dataCollectionRuleName, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates part of a data collection rule. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='dataCollectionRuleName'> /// The name of the data collection rule. The name is case insensitive. /// </param> /// <param name='body'> /// The payload /// </param> public static DataCollectionRuleResource Update(this IDataCollectionRules operations, string resourceGroupName, string dataCollectionRuleName, ResourceForUpdate body = default(ResourceForUpdate)) { return(operations.UpdateAsync(resourceGroupName, dataCollectionRuleName, body).GetAwaiter().GetResult()); }