public virtual async Task <Response <ConfigurationStore> > SetTagsAsync(IDictionary <string, string> tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); using var scope = _configurationStoreClientDiagnostics.CreateScope("ConfigurationStore.SetTags"); scope.Start(); try { await TagHelper.DeleteAsync(WaitUntil.Completed, cancellationToken : cancellationToken).ConfigureAwait(false); var originalTags = await TagHelper.GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); await TagHelper.CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken : cancellationToken).ConfigureAwait(false); var originalResponse = await _configurationStoreRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); return(Response.FromValue(new ConfigurationStore(Client, originalResponse.Value), originalResponse.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <HciCluster> > RemoveTagAsync(string key, CancellationToken cancellationToken = default) { Argument.AssertNotNull(key, nameof(key)); using var scope = _hciClusterClustersClientDiagnostics.CreateScope("HciCluster.RemoveTag"); scope.Start(); try { var originalTags = await TagHelper.GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); await TagHelper.CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken : cancellationToken).ConfigureAwait(false); var originalResponse = await _hciClusterClustersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); return(Response.FromValue(new HciCluster(Client, originalResponse.Value), originalResponse.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <CdnWebApplicationFirewallPolicy> > AddTagAsync(string key, string value, CancellationToken cancellationToken = default) { Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); using var scope = _cdnWebApplicationFirewallPolicyPoliciesClientDiagnostics.CreateScope("CdnWebApplicationFirewallPolicy.AddTag"); scope.Start(); try { var originalTags = await TagHelper.GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; await TagHelper.CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken : cancellationToken).ConfigureAwait(false); var originalResponse = await _cdnWebApplicationFirewallPolicyPoliciesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); return(Response.FromValue(new CdnWebApplicationFirewallPolicy(Client, originalResponse.Value), originalResponse.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }