99using System . Threading . Tasks ;
1010using Azure . Core ;
1111using Azure . Core . Pipeline ;
12+ using Azure . ResourceManager . Resources . Models ;
1213
1314[ assembly: CodeGenSuppressType ( "GenericResourceFilter" ) ]
1415[ assembly: CodeGenSuppressType ( "GenericResource" ) ]
@@ -192,9 +193,8 @@ public async virtual Task<Response<GenericResource>> AddTagAsync(string key, str
192193 try
193194 {
194195 var apiVersion = await GetApiVersionAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
195- var originalTags = await GetTagResource ( ) . GetAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
196- originalTags . Value . Data . Properties . TagValues [ key ] = value ;
197- await GetTagResource ( ) . CreateOrUpdateAsync ( WaitUntil . Completed , originalTags . Value . Data , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
196+ var tagPatch = new TagResourcePatch ( TagPatchMode . Merge , new Tag ( new Dictionary < string , string > { { key , value } } , null ) , null ) ;
197+ await GetTagResource ( ) . UpdateAsync ( WaitUntil . Completed , tagPatch , cancellationToken ) . ConfigureAwait ( false ) ;
198198 var originalResponse = await _resourcesRestClient . GetByIdAsync ( Id , apiVersion , cancellationToken ) . ConfigureAwait ( false ) ;
199199 return Response . FromValue ( new GenericResource ( Client , originalResponse . Value ) , originalResponse . GetRawResponse ( ) ) ;
200200 }
@@ -222,9 +222,8 @@ public virtual Response<GenericResource> AddTag(string key, string value, Cancel
222222 try
223223 {
224224 var apiVersion = GetApiVersion ( cancellationToken ) ;
225- var originalTags = GetTagResource ( ) . Get ( cancellationToken ) ;
226- originalTags . Value . Data . Properties . TagValues [ key ] = value ;
227- GetTagResource ( ) . CreateOrUpdate ( WaitUntil . Completed , originalTags . Value . Data , cancellationToken : cancellationToken ) ;
225+ var tagPatch = new TagResourcePatch ( TagPatchMode . Merge , new Tag ( new Dictionary < string , string > { { key , value } } , null ) , null ) ;
226+ GetTagResource ( ) . Update ( WaitUntil . Completed , tagPatch , cancellationToken : cancellationToken ) ;
228227 var originalResponse = _resourcesRestClient . GetById ( Id , apiVersion , cancellationToken ) ;
229228 return Response . FromValue ( new GenericResource ( Client , originalResponse . Value ) , originalResponse . GetRawResponse ( ) ) ;
230229 }
@@ -251,10 +250,7 @@ public async virtual Task<Response<GenericResource>> SetTagsAsync(IDictionary<st
251250 try
252251 {
253252 var apiVersion = await GetApiVersionAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
254- await GetTagResource ( ) . DeleteAsync ( WaitUntil . Completed , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
255- var originalTags = await GetTagResource ( ) . GetAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
256- originalTags . Value . Data . Properties . TagValues . ReplaceWith ( tags ) ;
257- await GetTagResource ( ) . CreateOrUpdateAsync ( WaitUntil . Completed , originalTags . Value . Data , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
253+ await GetTagResource ( ) . CreateOrUpdateAsync ( WaitUntil . Completed , new TagResourceData ( new Tag ( tags , null ) ) , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
258254 var originalResponse = await _resourcesRestClient . GetByIdAsync ( Id , apiVersion , cancellationToken ) . ConfigureAwait ( false ) ;
259255 return Response . FromValue ( new GenericResource ( Client , originalResponse . Value ) , originalResponse . GetRawResponse ( ) ) ;
260256 }
@@ -281,10 +277,7 @@ public virtual Response<GenericResource> SetTags(IDictionary<string, string> tag
281277 try
282278 {
283279 var apiVersion = GetApiVersion ( cancellationToken ) ;
284- GetTagResource ( ) . Delete ( WaitUntil . Completed , cancellationToken : cancellationToken ) ;
285- var originalTags = GetTagResource ( ) . Get ( cancellationToken ) ;
286- originalTags . Value . Data . Properties . TagValues . ReplaceWith ( tags ) ;
287- GetTagResource ( ) . CreateOrUpdate ( WaitUntil . Completed , originalTags . Value . Data , cancellationToken : cancellationToken ) ;
280+ GetTagResource ( ) . CreateOrUpdate ( WaitUntil . Completed , new TagResourceData ( new Tag ( tags , null ) ) , cancellationToken : cancellationToken ) ;
288281 var originalResponse = _resourcesRestClient . GetById ( Id , apiVersion , cancellationToken ) ;
289282 return Response . FromValue ( new GenericResource ( Client , originalResponse . Value ) , originalResponse . GetRawResponse ( ) ) ;
290283 }
@@ -311,9 +304,8 @@ public async virtual Task<Response<GenericResource>> RemoveTagAsync(string key,
311304 try
312305 {
313306 var apiVersion = await GetApiVersionAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
314- var originalTags = await GetTagResource ( ) . GetAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
315- originalTags . Value . Data . Properties . TagValues . Remove ( key ) ;
316- await GetTagResource ( ) . CreateOrUpdateAsync ( WaitUntil . Completed , originalTags . Value . Data , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
307+ var tagPatch = new TagResourcePatch ( TagPatchMode . Delete , new Tag ( new Dictionary < string , string > { { key , string . Empty } } , null ) , null ) ;
308+ await GetTagResource ( ) . UpdateAsync ( WaitUntil . Completed , tagPatch , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
317309 var originalResponse = await _resourcesRestClient . GetByIdAsync ( Id , apiVersion , cancellationToken ) . ConfigureAwait ( false ) ;
318310 return Response . FromValue ( new GenericResource ( Client , originalResponse . Value ) , originalResponse . GetRawResponse ( ) ) ;
319311 }
@@ -340,9 +332,8 @@ public virtual Response<GenericResource> RemoveTag(string key, CancellationToken
340332 try
341333 {
342334 var apiVersion = GetApiVersion ( cancellationToken ) ;
343- var originalTags = GetTagResource ( ) . Get ( cancellationToken ) ;
344- originalTags . Value . Data . Properties . TagValues . Remove ( key ) ;
345- GetTagResource ( ) . CreateOrUpdate ( WaitUntil . Completed , originalTags . Value . Data , cancellationToken : cancellationToken ) ;
335+ var tagPatch = new TagResourcePatch ( TagPatchMode . Delete , new Tag ( new Dictionary < string , string > { { key , string . Empty } } , null ) , null ) ;
336+ GetTagResource ( ) . Update ( WaitUntil . Completed , tagPatch , cancellationToken : cancellationToken ) ;
346337 var originalResponse = _resourcesRestClient . GetById ( Id , apiVersion , cancellationToken ) ;
347338 return Response . FromValue ( new GenericResource ( Client , originalResponse . Value ) , originalResponse . GetRawResponse ( ) ) ;
348339 }
0 commit comments